Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- # Declare member variables here. Examples:
- # var a = 2
- # var b = "text"
- var jump_power = 500.0
- var jump_released = false
- var velocity = Vector2()
- const grav = 9.8
- var grav_scale = 50.0
- var on_floor = false
- # Called when the node enters the scene tree for the first time.
- func _ready():
- pass # Replace with function body.
- # Called every frame. 'delta' is the elapsed time since the previous frame.
- func _process(delta):
- if Input.is_action_just_released("ui_accept"):
- jump_released = true
- velocity += Vector2.DOWN * grav * grav_scale * delta
- if velocity.y > 0 or (velocity < 0 and jump_released):
- velocity += Vector2.DOWN * grav * grav_scale * delta
- if on_floor:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement