Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const GRAVITY = 20
- const SPEED = 300
- const JUMP_HEIGHT = -600
- const FLOOR_NORMAL = Vector2(0, -1)
- var velocity = Vector2()
- func _physics_process(delta):
- velocity.y += GRAVITY
- velocity.x = 0
- if Input.is_action_pressed('ui_left'):
- velocity.x = -SPEED
- elif Input.is_action_pressed('ui_right'):
- velocity.x = SPEED
- if Input.is_action_just_pressed('ui_cancel'):
- position = Vector2(512, 80)
- velocity = Vector2()
- if is_on_floor():
- velocity.y += GRAVITY * 10
- if is_on_floor() and Input.is_action_just_pressed('ui_select'):
- velocity.y = JUMP_HEIGHT
- velocity = move_and_slide(velocity, FLOOR_NORMAL, 25)
Advertisement
Add Comment
Please, Sign In to add comment