Side scrolling creepy puzzle game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
954B

  1. extends KinematicBody2D
  2. onready var _anim_tree = $AnimationTree
  3. export var max_velocity = 150
  4. export var base_lateral_friction_coeff = 1.0
  5. var movement_velocity = Vector2.ZERO
  6. var grav_velocity = Vector2.ZERO
  7. var component_h = 0
  8. var component_v = 0
  9. var on_floor = false
  10. func _ready():
  11. self.set_physics_process(true)
  12. func _physics_process(delta):
  13. var gravity_vector = ProjectSettings.get_setting("physics/2d/default_gravity_vector")
  14. var gravity_magnitude = ProjectSettings.get_setting("physics/2d/default_gravity") * 10 * delta
  15. var up_vector = gravity_vector * -1
  16. if on_floor == false:
  17. grav_velocity += (gravity_vector * gravity_magnitude)
  18. var velocity = movement_velocity + grav_velocity
  19. if velocity.length() > max_velocity:
  20. velocity = velocity.normalized() * max_velocity
  21. move_and_slide(velocity, up_vector)
  22. if is_on_floor() and on_floor == false:
  23. grav_velocity = Vector2.ZERO
  24. on_floor = true
  25. func _input(event):
  26. pass