reimu_movement.gd 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. extends CharacterBody2D
  2. var speed = 200.0
  3. # Get the gravity from the project settings to be synced with RigidBody nodes.
  4. var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
  5. func _physics_process(delta):
  6. # Add the gravity.
  7. #if not is_on_floor():
  8. #velocity.y += gravity * delta
  9. # Handle jump.
  10. #if Input.is_action_just_pressed("ui_accept") and is_on_floor():
  11. #velocity.y = JUMP_VELOCITY
  12. # Get the input direction and handle the movement/deceleration.
  13. # As good practice, you should replace UI actions with custom gameplay actions.
  14. var direction = Input.get_axis("ui_left", "ui_right")
  15. var directiony = Input.get_axis("ui_up", "ui_down")
  16. if direction:
  17. velocity.x = direction * speed
  18. else:
  19. velocity.x = move_toward(velocity.x, 0, speed)
  20. if directiony:
  21. velocity.y = directiony*speed
  22. else:
  23. velocity.y = move_toward(velocity.y, 0, speed)
  24. if Input.is_physical_key_pressed(KEY_SHIFT):
  25. speed = 100.0
  26. print(speed)
  27. else:
  28. speed=200
  29. move_and_slide()