Spark01

Untitled

Jul 3rd, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. func _process(delta):
  2. if steps_remaining == 0:
  3. if Input.is_action_pressed("move_up"):
  4. current_direction = Vector2(0, -1)
  5. steps_remaining = tile_size/speed
  6. elif Input.is_action_pressed("move_down"):
  7. current_direction = Vector2(0, 1)
  8. steps_remaining = tile_size/speed
  9. elif Input.is_action_pressed("move_left"):
  10. current_direction = Vector2(-1, 0)
  11. steps_remaining = tile_size/speed
  12. elif Input.is_action_pressed("move_right"):
  13. current_direction = Vector2(1, 0)
  14. steps_remaining = tile_size/speed
  15.  
  16. if steps_remaining > 0:
  17. collision.set_pos((current_direction*speed))
  18. if collision.get_overlapping_bodies().empty():
  19. self.set_pos(self.get_pos()+collision.get_pos())
  20. steps_remaining-=1
  21. else:
  22. steps_remaining = 0
  23.  
  24. collision.set_pos(Vector2(0,0))
Advertisement
Add Comment
Please, Sign In to add comment