params.gd 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. class_name Params
  2. ## Game tuning values, ported from the cocos2d-x params.h.
  3. # Ball
  4. const BALL_RADIUS := 15.0
  5. const THROW_ANGLE := 20.0 # degrees either side of straight up
  6. const INITIAL_SPEED := 500.0
  7. const BALL_BOUNCE := 1.005 # every bounce speeds the ball up a little
  8. const BALL_GRAVITY := 250.0 # px/s², pulls sideways-bouncing balls back to the paddle
  9. # Core
  10. const CORE_RADIUS := 50.0
  11. # Paddle
  12. const PADDLE_WIDTH := 120.0
  13. const PADDLE_HEIGHT := 10.0
  14. const PADDLE_ALTITUDE := 90.0 # distance from the bottom of the screen
  15. const PADDLE_MAX_ANGLE := 60.0 # degrees from vertical when the ball leaves the paddle's tip
  16. const PADDLE_CLEARANCE := 6.0 * 2.0 * BALL_RADIUS # min space between the outer ring and the paddle
  17. const RING_SIZE := CORE_RADIUS * 0.75 # ring thickness when there is room for it
  18. const HIGHEST_CORE := 0.36 # the core moves up to this fraction of the screen height to make room
  19. # Colors
  20. const COLOR_PINK := Color("#f92672")
  21. const COLOR_BLUE := Color("#66d9ef")
  22. const COLOR_GREEN := Color("#a6e22e")
  23. const COLOR_ORANGE := Color("#fd971f")
  24. const COLOR_GREY := Color("#787878")
  25. const COLOR_RED := Color(0.988, 0.147, 0.030)
  26. const COLOR_FIRE := Color("#ff5a1f")
  27. const COLOR_BACK := Color("#272822")
  28. const COLOR_BOMB := Color("#4a4a44")
  29. # Physics layers (bit values)
  30. const LAYER_WALLS := 1
  31. const LAYER_PADDLE := 2
  32. const LAYER_BLOCKS := 4
  33. const LAYER_BALLS := 8
  34. const LAYER_POWER_UPS := 16
  35. # Power-ups. Every POWER_UP_INTERVAL seconds a drop is rolled (power_up_chance), and the
  36. # kind is picked by the weights in PowerUp.KINDS. Triple balls roll separately.
  37. const DROP_TRIPLE_BALL := 0.06 # multiplied by seconds since a ball last touched anything
  38. const POWER_UP_INTERVAL := 2.5
  39. const POWER_UP_PADDLE_SECONDS := 10.0
  40. const SLOW_SCALE := 0.6
  41. const SLOW_SECONDS := 8.0
  42. const RUSH_SCALE := 1.35
  43. const RUSH_SECONDS := 6.0
  44. const CATCH_SECONDS := 12.0
  45. const CATCH_HOLD_SECONDS := 2.0 # a caught ball leaves by itself after this
  46. const SHIELD_CHARGES := 1
  47. const BIG_BALL_SECONDS := 10.0
  48. const FIREBALL_SECONDS := 5.0
  49. const LASER_SECONDS := 6.0
  50. const FREEZE_SECONDS := 8.0
  51. const BOMB_RADIUS := 90.0
  52. const HOMING_SECONDS := 6.0
  53. # Core pull: as segments run out, the core draws nearby balls in so levels don't drag.
  54. const CORE_PULL := 450.0 # px/s² when every breakable segment is gone
  55. const CORE_PULL_REACH := 120.0 # px beyond the outer ring
  56. # Score: points per break, times a combo multiplier that grows with breaks in a row
  57. # (without the ball touching the paddle).
  58. const POINTS_PER_BREAK := 10
  59. const BREAKS_PER_COMBO_STEP := 3
  60. const MAX_COMBO := 5
  61. # Feel
  62. const SHAKE_MAX := 14.0 # px at full trauma
  63. const SHAKE_DECAY := 1.6 # trauma lost per second
  64. # Hours without playing before the saved level drops by one
  65. const LOSE_HOURS := 12
  66. # Text
  67. const MSG_TRIPLE_BALLS := "Triple Balls!"
  68. const MSG_OVER := "Game Over..."
  69. const MSG_DOUBLE_PADDLE := "Doubled paddle!"
  70. const MSG_HALF_PADDLE := "Half paddle :("
  71. const MSG_LEVEL_BACK := "You are at level %d. Play within %.1f hour(s) or you will drop back a level."
  72. const MSG_NEXT_LEVEL := "Next Level"
  73. const MSG_LEVEL_DONE := "Level %d complete"
  74. const MSG_RESTART := "Restart"
  75. const MSG_SUPER_BALL := "Super Ball!"
  76. const MSG_SLOW := "Slow motion"
  77. const MSG_CATCH := "Catch! Lift your finger to throw"
  78. const MSG_SHIELD := "Shield!"
  79. const MSG_SHIELD_USED := "Shield saved you!"
  80. const MSG_BIG_BALL := "Big ball!"
  81. const MSG_FIREBALL := "Fireball!"
  82. const MSG_RUSH := "Rush! :("
  83. const MSG_LASER := "Lasers!"
  84. const MSG_FREEZE := "Rings frozen"
  85. const MSG_BOMB := "Bomb ball!"
  86. const MSG_HOMING := "Homing ball!"
  87. # Progression: how the game gets harder level by level. Every curve only goes up.
  88. const MAX_RINGS := 14
  89. const FIRST_SPECIAL_LEVEL := 15 # water arrives here; the rest every 50 levels after
  90. ## Rings around the core: 1 at level 0, 3 at level 12, 6 at 75, 10 at 243, 14 from 507.
  91. static func ring_count(level: int) -> int:
  92. return mini(MAX_RINGS, 1 + int(sqrt(level / 3.0)))
  93. ## Share of segments that are indestructible.
  94. static func indestructible_chance(level: int) -> float:
  95. return minf(0.3, level * 0.004)
  96. ## Bounces and speed-ups stop at this speed, in px/s.
  97. static func max_ball_speed(level: int) -> float:
  98. return 850.0 + minf(150.0, level * 0.3)
  99. ## Fastest a ring can turn, in degrees per second.
  100. static func ring_speed(level: int) -> float:
  101. return 30.0 + minf(40.0, level * 0.25)
  102. ## Launch speed of a new ball.
  103. static func launch_speed(level: int) -> float:
  104. return INITIAL_SPEED + minf(150.0, level * 1.0)
  105. ## Share of segments that are a special kind (water, ice, ...), once the first has unlocked.
  106. static func special_segment_share(level: int) -> float:
  107. if level < FIRST_SPECIAL_LEVEL:
  108. return 0.0
  109. return minf(0.5, 0.06 + (level - FIRST_SPECIAL_LEVEL) * 0.0012)
  110. ## Seconds to win a level within for three stars; twice that for two.
  111. static func par_seconds(level: int) -> float:
  112. return 60.0 + minf(60.0, level * 0.8)
  113. ## Chance of a power-up drop every POWER_UP_INTERVAL seconds.
  114. static func power_up_chance(level: int) -> float:
  115. return 0.12 + minf(0.06, level * 0.0006)
  116. ## Multiplier on power-down weights: they get likelier as the levels go up.
  117. static func power_down_factor(level: int) -> float:
  118. return 1.0 + minf(2.0, level / 100.0)