Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3.  
  4. # Declare member variables here. Examples:
  5. # var a = 2
  6. # var b = "text"
  7. var jump_power = 500.0
  8. var jump_released = false
  9. var velocity = Vector2()
  10. const grav = 9.8
  11. var grav_scale = 50.0
  12. var on_floor = false
  13.  
  14. # Called when the node enters the scene tree for the first time.
  15. func _ready():
  16. pass # Replace with function body.
  17.  
  18.  
  19. # Called every frame. 'delta' is the elapsed time since the previous frame.
  20. func _process(delta):
  21. if Input.is_action_just_released("ui_accept"):
  22. jump_released = true
  23.  
  24. velocity += Vector2.DOWN * grav * grav_scale * delta
  25.  
  26. if velocity.y > 0 or (velocity < 0 and jump_released):
  27. velocity += Vector2.DOWN * grav * grav_scale * delta
  28.  
  29. if on_floor:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement