Hello
I mapped the names of my four custom actions as strings with vector2 values for the four directions.
var dir = {"left":Vector2(-1, 0), "right":Vector2(1, 0), "up":Vector2(0, -1), "down":Vector2(0, 1)}
How can i now react on anything pressed and output the matching action to put it into a variable to do this (the variable, i want to store that, is key)?
if step == 0:
old_pos = position
direction = dir[key]
if grid.is_valid_move(pos, direction) || step > 0:
move = true
step += 1
pos += STEP * direction
if step == 144:
move = false
step = 0
pos = Vector2(round(pos.x), round(pos.y))
grid.update_child_pos(self)
position = pos
else:
direction = Vector2(0, 0)