Untitled

 avatar
unknown
plain_text
a year ago
436 B
4
Indexable
extends Area2D

var grid_size: int = 32
var inputs = {"up": Vector2.UP,
 "down": Vector2.DOWN,
 "left": Vector2.LEFT,
 "right": Vector2.RIGHT}


func _ready():
	position = position.snapped(Vector2.ONE * grid_size)
	position += Vector2.ONE * grid_size/2 


func _unhandled_input(event):
	for dir in inputs.keys():
		if event.is_action_pressed(dir):
			move(dir)

func move(dir):
	position += inputs[dir] * grid_size
Leave a Comment