Advertisement
otorp2

smoothgrid2

Dec 30th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. extends Sprite
  2.  
  3. var player = {grid_x = 256, grid_y = 256, act_x = 250, act_y = 250, speed = .1}
  4. var playerstart = Vector2(256,0)
  5.  
  6. func _ready():
  7. set_process_input(true)
  8. set_process(true)
  9. set_pos(playerstart)
  10.  
  11. func _process(delta):
  12. pass
  13. player.act_x = player.act_x - (player.act_x - player.grid_x) * player.speed * delta
  14. player.act_y = player.act_y - (player.act_y - player.grid_y) * player.speed * delta
  15. set_pos(Vector2(player.act_x,player.act_y))
  16. print(player.act_x)
  17. func _input(event):
  18.  
  19. if Input.is_action_pressed("ui_left"):
  20. player.grid_x = player.grid_x - 64
  21. if Input.is_action_pressed("ui_right"):
  22. player.grid_x = player.grid_x + 64
  23. if Input.is_action_pressed("ui_down"):
  24. player.grid_y = player.grid_y + 64
  25. if Input.is_action_pressed("ui_up"):
  26. player.grid_y = player.grid_y - 64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement