How would I implement a player movement based on a grid? I tried to find this on docs but no success... I'm very new to Game design.
I have a standard movement code, which works:
func _move(direction: int, delta: float)->void:
velocity = Vector2()
in_movement = true
if direction == Direction.UP:
_player.play('walk_up')
velocity.y -= 1
elif direction == Direction.RIGHT:
_player.play('walk_right')
velocity.x += 1
elif direction == Direction.DOWN:
_player.play('walk_down')
velocity.y += 1
elif direction == Direction.LEFT:
_player.play('walk_left')
velocity.x -= 1
velocity = velocity.normalized() * speed
_player.position += velocity * delta
What I'm trying to do is simple: think of the old Pokémon games, the character always walks 1 full tile (NxN) when you input, and can't be interrupted in the middle of the process (4-way movement)
If anyone could help I'd appreciate it! Thanks.