Side scrolling creepy puzzle game.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Player.gd 954B

12345678910111213141516171819202122232425262728293031323334353637383940
  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