Untitled
Anonymous
Plain Text
01/26/2024 11:12 AM
436 B
20
Indexable
Never
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
Editor is loading...
Leave a Comment