Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Sprite
- var player = {grid_x = 256, grid_y = 256, act_x = 250, act_y = 250, speed = .1}
- var playerstart = Vector2(256,0)
- func _ready():
- set_process_input(true)
- set_process(true)
- set_pos(playerstart)
- func _process(delta):
- pass
- player.act_x = player.act_x - (player.act_x - player.grid_x) * player.speed * delta
- player.act_y = player.act_y - (player.act_y - player.grid_y) * player.speed * delta
- set_pos(Vector2(player.act_x,player.act_y))
- print(player.act_x)
- func _input(event):
- if Input.is_action_pressed("ui_left"):
- player.grid_x = player.grid_x - 64
- if Input.is_action_pressed("ui_right"):
- player.grid_x = player.grid_x + 64
- if Input.is_action_pressed("ui_down"):
- player.grid_y = player.grid_y + 64
- if Input.is_action_pressed("ui_up"):
- player.grid_y = player.grid_y - 64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement