Added actual images and prepared to add extractors
This commit is contained in:
+10
-5
@@ -7,7 +7,6 @@ PRODUCER_DEBUG = false
|
||||
BORDER = 2
|
||||
HOVER_TIME = 500 # ms
|
||||
|
||||
|
||||
class Producer
|
||||
attr_reader :draw_x, :draw_y
|
||||
# Create producer at a position with the number and rate specified
|
||||
@@ -25,8 +24,8 @@ class Producer
|
||||
@screen_height = screen_height
|
||||
@image = Gosu.render(@box_size - (2 * BORDER), @box_size - (2 * BORDER)) {
|
||||
# Render the item
|
||||
Gosu.draw_rect(0, 0, @box_size - (2 * BORDER), @box_size - (2 * BORDER), Gosu::Color::RED, 0)
|
||||
Gosu::Image.from_text("#{@number}", 20, font: FONT_PATH).draw(5, 5, 1)
|
||||
Gosu::Image.new('assets/images/producer.png').draw(0, 0, 0, @box_size / 32.0, @box_size / 32.0)
|
||||
Gosu::Image.from_text("#{@number}", 20, font: FONT_PATH).draw(10 / 32.0 * @box_size, (8 / 32.0 * @box_size), 1, 2, 2, 0xFFFA32C0)
|
||||
}
|
||||
|
||||
@tooltip = DialougeBox.new(@x, @y, WIDTH, HEIGHT, "Produces #{@rate} number per second")
|
||||
@@ -39,11 +38,11 @@ class Producer
|
||||
# @param camera_x [Integer] The camera X position
|
||||
# @param camera_y [Integer] The camera Y position
|
||||
# @param camera_zoom [Float] The camera zoom
|
||||
def update(delta_mult, camera_x, camera_y, camera_zoom, mouse_x, mouse_y)
|
||||
def update(delta_mult, camera_x, camera_y, camera_zoom, mouse_x, mouse_y, mouse_used)
|
||||
@draw_x = (((((@screen_width / @box_size.to_f) / 2.0) + (@x - camera_x) * camera_zoom) * @box_size) + BORDER * camera_zoom)
|
||||
@draw_y = (((((@screen_height / @box_size.to_f) / 2.0) + (@y - camera_y) * camera_zoom) * @box_size) + BORDER * camera_zoom)
|
||||
@camera_zoom = camera_zoom
|
||||
if 0 < mouse_x - @draw_x && mouse_x - @draw_x < (@box_size * @camera_zoom) && 0 < mouse_y - @draw_y && mouse_y - @draw_y < (@box_size * @camera_zoom)
|
||||
if !mouse_used && 0 < mouse_x - @draw_x && mouse_x - @draw_x < (@box_size * @camera_zoom) && 0 < mouse_y - @draw_y && mouse_y - @draw_y < (@box_size * @camera_zoom)
|
||||
@tooltip_timer += 60.0 * delta_mult
|
||||
if @tooltip_timer > HOVER_TIME
|
||||
@tooltip.show = true
|
||||
@@ -53,6 +52,9 @@ class Producer
|
||||
@tooltip_timer = 0
|
||||
@tooltip.show = false
|
||||
end
|
||||
if @extractor
|
||||
@extractor.update()
|
||||
end
|
||||
end
|
||||
|
||||
# Draw the producer. Uses the camera x and y to shift where it should draw
|
||||
@@ -62,5 +64,8 @@ class Producer
|
||||
end
|
||||
@image.draw(@draw_x, @draw_y, 0, @camera_zoom, @camera_zoom)
|
||||
@tooltip.draw()
|
||||
if @extractor
|
||||
@extractor.update()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user