A game created for the Godot Wild Jam #21
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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. extends KinematicBody2D
  2. export var degrees_per_second:float = 180.0
  3. export var ease_in:float = 0.2
  4. export var ease_out:float = 0.4
  5. export var active:bool = true setget _set_active
  6. var _easing_in = false
  7. var _easing_out = false
  8. var _easing = 0.0
  9. var _running = false
  10. var _volume_on = 0
  11. var _pitch_on = 1.0
  12. func _set_active(b):
  13. if active != b:
  14. if active:
  15. _easing_out = true
  16. _easing = ease_out
  17. else:
  18. _easing_in = true
  19. _easing = ease_in
  20. active = b
  21. # Called when the node enters the scene tree for the first time.
  22. func _ready():
  23. _volume_on = $audio.volume_db
  24. _pitch_on = $audio.pitch_scale
  25. set_physics_process(true)
  26. if active and _easing == 0.0:
  27. _running = true
  28. func _physics_process(delta):
  29. if _easing_in or _easing_out:
  30. _easing -= delta
  31. if _easing <= 0.0:
  32. _running = _easing_in
  33. _easing_in = false
  34. _easing_out = false
  35. _easing = 0.0
  36. if not _running:
  37. $audio.stop()
  38. $audio.volume_db = _volume_on
  39. $audio.pitch_scale = _pitch_on
  40. else:
  41. if not $audio.playing:
  42. $audio.play()
  43. var adj
  44. var vol
  45. if _easing_in:
  46. adj = 1.0 - (_easing / ease_in)
  47. vol = adj
  48. else:
  49. vol = (_easing / ease_out)
  50. adj = vol
  51. $audio.volume_db = (-80 + ((_volume_on + 80) * vol))
  52. $audio.pitch_scale = 0.1 + ((_pitch_on - 0.1) * vol)
  53. rotate(deg2rad(degrees_per_second * adj * delta))
  54. elif _running:
  55. if not $audio.playing:
  56. $audio.play()
  57. rotate(deg2rad(degrees_per_second * delta))