Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Area2D
- # member variables here, example:
- # var a=2
- # var b="textvar"
- const SPEED = 200
- func _ready():
- set_process(true)
- pass
- func _process(delta):
- var motion = Vector2()
- if Input.is_action_pressed("ui_up"):
- motion+=Vector2(0,-1)
- if Input.is_action_pressed("ui_down"):
- motion+=Vector2(0,1)
- if Input.is_action_pressed("ui_left"):
- motion+=Vector2(-1,0)
- if Input.is_action_pressed("ui_right"):
- motion+=Vector2(1,0)
- var pos = get_pos()
- pos+=motion*delta*SPEED
- set_pos(pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement