tetris-mobile/GameBoard.gd

40 lines
729 B
GDScript

extends Node2D
onready var active_shape: Node2D = $ShapeSquare
const RASTER_SIZE = 64
func _ready():
$GravityTimer.connect("timeout", self, "update_board")
func update_board():
if active_shape.position.y == RASTER_SIZE * 9:
# TODO: Turn into static blocks
return
active_shape.position.y += RASTER_SIZE
func move_left():
# TODO: Check for collision
active_shape.position.x -= RASTER_SIZE
func move_right():
# TODO: Check for collision
active_shape.position.x += RASTER_SIZE
func _input(event):
if event.is_action_pressed("move_left"):
move_left()
elif event.is_action_pressed("move_right"):
move_right()
elif event.is_action_pressed("rotate"):
pass
elif event.is_action_pressed("drop"):
pass