Advertisement
otorp2

smooth grid

Dec 20th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. extends Sprite
  2.  
  3. var player = {grid_x = 256, grid_y = 256, act_x = 250, act_y = 250, speed = .5}
  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. set_pos(Vector2(player.act_x,0))
  15. print(player.act_x)
  16. func _input(event):
  17.  
  18. if Input.is_action_pressed("ui_left"):
  19. player.grid_x = player.grid_x - 64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement