Fixed zooming issue with camera and ensured producers produce at least one.
This commit is contained in:
+2
-1
@@ -13,7 +13,8 @@ class Consumer
|
|||||||
def initialize(x, y)
|
def initialize(x, y)
|
||||||
@x = x
|
@x = x
|
||||||
@y = y
|
@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
|
end
|
||||||
|
|
||||||
# Creates numbers depending on the rate. This is done with knowing that the
|
# Creates numbers depending on the rate. This is done with knowing that the
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ GAME_PRODUCER_BASE_SPEED = 1
|
|||||||
|
|
||||||
# Camera settings
|
# Camera settings
|
||||||
CAMERA_MOVE_RANGE = 10
|
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_MOVE_MAX_SPEED = (CAMERA_MOVE_RANGE * CAMERA_MOVE_SPEED / 2).to_i
|
||||||
CAMERA_MIN_ZOOM = 0.3
|
CAMERA_MIN_ZOOM = 0.7
|
||||||
CAMERA_MAX_ZOOM = 20
|
CAMERA_MAX_ZOOM = 5
|
||||||
|
|
||||||
class NumFactory < Gosu::Window
|
class NumFactory < Gosu::Window
|
||||||
def initialize
|
def initialize
|
||||||
@@ -104,8 +104,20 @@ class NumFactory < Gosu::Window
|
|||||||
close
|
close
|
||||||
elsif id == Gosu::MS_WHEEL_UP
|
elsif id == Gosu::MS_WHEEL_UP
|
||||||
@camera_zoom *= 1.1
|
@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
|
elsif id == Gosu::MS_WHEEL_DOWN
|
||||||
@camera_zoom *= 0.9
|
@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
|
elsif id == Gosu::KB_SPACE
|
||||||
@camera_zoom = 1.0
|
@camera_zoom = 1.0
|
||||||
else
|
else
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ class Producer
|
|||||||
def initialize(x, y, number, rate)
|
def initialize(x, y, number, rate)
|
||||||
@x = x
|
@x = x
|
||||||
@y = y
|
@y = y
|
||||||
@number = number
|
@number = [number, 1].max
|
||||||
@rate = (30/rate).to_i
|
@rate = (30/rate).to_i
|
||||||
@image = Gosu.render(30, 30) {
|
@image = Gosu.render(30, 30) {
|
||||||
# Render the item
|
# Render the item
|
||||||
|
|||||||
Reference in New Issue
Block a user