Przeglądaj źródła

Keep the rings at least 3.5 ball diameters above the paddle

At high levels the outer rings reached the paddle and even went below
it (level 75: 12 rings out to a 500 px radius). Rings are now made
thinner when needed so the outermost one stays at least 3.5 ball
diameters (105 px) above the paddle. Each level keeps its ring count,
so difficulty is unchanged; taller screens get thicker rings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gabriel Capella 5 dni temu
rodzic
commit
68a90eade8
3 zmienionych plików z 8 dodań i 3 usunięć
  1. 5 2
      scripts/blocks.gd
  2. 2 1
      scripts/game.gd
  3. 1 0
      scripts/params.gd

+ 5 - 2
scripts/blocks.gd

@@ -10,10 +10,13 @@ var _rings: Array[Node2D] = []
 var _speeds: Array[float] = []
 
 
-func build(level: int) -> void:
+## Builds the level's rings. Rings are made thinner when needed so they all fit within
+## [param max_radius]; the ring count, and so the difficulty, stays the same.
+func build(level: int, max_radius: float) -> void:
 	var layout := _layout(level)
+	var size := minf(layout.size, (max_radius - Params.CORE_RADIUS) / layout.rings)
 	for index in range(layout.rings - 1, -1, -1):
-		_add_ring(layout.size, index, layout.indestructible_chance)
+		_add_ring(size, index, layout.indestructible_chance)
 	core = Core.new()
 	add_child(core)
 

+ 2 - 1
scripts/game.gd

@@ -29,8 +29,9 @@ func _ready() -> void:
 	$HUD/Level.text = "Level %d" % level
 
 	blocks.position = screen / 2.0
-	blocks.build(level)
 	paddle.position = Vector2(screen.x / 2.0, screen.y - Params.PADDLE_ALTITUDE - Params.PADDLE_HEIGHT / 2.0)
+	var paddle_top := paddle.position.y - Params.PADDLE_HEIGHT / 2.0
+	blocks.build(level, paddle_top - blocks.position.y - Params.PADDLE_CLEARANCE)
 	end_button.pressed.connect(_restart)
 
 	get_tree().create_timer(10.0).timeout.connect(_drop_level_save)

+ 1 - 0
scripts/params.gd

@@ -15,6 +15,7 @@ const CORE_RADIUS := 50.0
 const PADDLE_WIDTH := 120.0
 const PADDLE_HEIGHT := 10.0
 const PADDLE_ALTITUDE := 90.0 # distance from the bottom of the screen
+const PADDLE_CLEARANCE := 3.5 * 2.0 * BALL_RADIUS # min space between the outer ring and the paddle
 
 # Colors
 const COLOR_PINK := Color("#f92672")