From f629454f45aa08541a27e8aef09d04f0beb83d17 Mon Sep 17 00:00:00 2001 From: bionickatana Date: Sat, 13 Jun 2026 15:34:33 -0600 Subject: [PATCH] Fixed zooming issue with camera and ensured producers produce at least one. --- consumer.rb | 3 ++- main.rb | 18 +++++++++++++++--- producer.rb | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/consumer.rb b/consumer.rb index c1922ae..dc95b54 100644 --- a/consumer.rb +++ b/consumer.rb @@ -13,7 +13,8 @@ class Consumer def initialize(x, y) @x = x @y = y - @image = Gosu::Image.new('assets/images/background_square.png', {:tileable => true}) + @image = Gosu.render(30, 30) {Gosu.draw_rect(0, 0, 30, 30, Gosu::Color::GREEN, 0)} + #Gosu::Image.new('assets/images/background_square.png', {:tileable => true}) end # Creates numbers depending on the rate. This is done with knowing that the diff --git a/main.rb b/main.rb index f37e95e..ee8d242 100644 --- a/main.rb +++ b/main.rb @@ -22,10 +22,10 @@ GAME_PRODUCER_BASE_SPEED = 1 # Camera settings CAMERA_MOVE_RANGE = 10 -CAMERA_MOVE_SPEED = 30 +CAMERA_MOVE_SPEED = 1 CAMERA_MOVE_MAX_SPEED = (CAMERA_MOVE_RANGE * CAMERA_MOVE_SPEED / 2).to_i -CAMERA_MIN_ZOOM = 0.3 -CAMERA_MAX_ZOOM = 20 +CAMERA_MIN_ZOOM = 0.7 +CAMERA_MAX_ZOOM = 5 class NumFactory < Gosu::Window def initialize @@ -104,8 +104,20 @@ class NumFactory < Gosu::Window close elsif id == Gosu::MS_WHEEL_UP @camera_zoom *= 1.1 + if @camera_zoom > CAMERA_MAX_ZOOM + @camera_zoom = CAMERA_MAX_ZOOM + else + @camera_x *= 1.0125 + @camera_y *= 1.0125 + end elsif id == Gosu::MS_WHEEL_DOWN @camera_zoom *= 0.9 + if @camera_zoom < CAMERA_MIN_ZOOM + @camera_zoom = CAMERA_MIN_ZOOM + else + @camera_x *= 0.985 + @camera_y *= 0.985 + end elsif id == Gosu::KB_SPACE @camera_zoom = 1.0 else diff --git a/producer.rb b/producer.rb index 8458846..e58c264 100644 --- a/producer.rb +++ b/producer.rb @@ -13,7 +13,7 @@ class Producer def initialize(x, y, number, rate) @x = x @y = y - @number = number + @number = [number, 1].max @rate = (30/rate).to_i @image = Gosu.render(30, 30) { # Render the item