Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const TOP = Vector2(0,-1)
- const LEFT = Vector2(-1,0)
- const RIGHT = Vector2(1,0)
- const DOWN = Vector2(0,1)
- const NONE = Vector2(0,0)
- var motion = NONE
- func _ready():
- pass
- func _physics_process(delta):
- if Input.is_action_just_released('move_up'):
- if motion == TOP:
- motion = NONE
- if Input.is_action_just_released('move_left'):
- if motion == LEFT:
- motion = NONE
- if Input.is_action_just_released('move_right'):
- if motion == RIGHT:
- motion = NONE
- if Input.is_action_just_released('move_down'):
- if motion == DOWN:
- motion = NONE
- if Input.is_action_just_pressed('move_up'):
- motion = TOP
- if Input.is_action_just_pressed('move_left'):
- motion = LEFT
- if Input.is_action_just_pressed('move_right'):
- motion = RIGHT
- if Input.is_action_just_pressed('move_down'):
- motion = DOWN
- move_and_slide(motion*40)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement