Reworked the dialouge system. Now the main.rb function can register and delete the dialouges.
This commit is contained in:
+5
-14
@@ -18,7 +18,8 @@ class Consumer
|
||||
# Create consumer at a position with the number and rate specified
|
||||
# @param x [Integer] X position to start at
|
||||
# @param y [Integer] Y position to start at
|
||||
def initialize(x, y, box_size, screen_width, screen_height)
|
||||
def initialize(parent, x, y, box_size, screen_width, screen_height)
|
||||
@parent = parent
|
||||
@x = x - SIZE / 2
|
||||
@y = y - SIZE / 2
|
||||
@box_size = box_size
|
||||
@@ -28,8 +29,7 @@ class Consumer
|
||||
Gosu.draw_rect(0, 0, (SIZE * @box_size) - (2 * BORDER), (SIZE * @box_size) - (2 * BORDER), Gosu::Color::GREEN, 0)
|
||||
}
|
||||
@task_index = 0
|
||||
@tooltip_timer = 0
|
||||
@tooltip = DialougeBox.new(@x, @y, WIDTH, HEIGHT, TASKS[@task_index])
|
||||
@tooltip = @parent.register_dialouge(@x, @y, @box_size * SIZE, @box_size * SIZE, TASKS[@task_index], 500)
|
||||
end
|
||||
|
||||
# Consumes numbers created
|
||||
@@ -41,16 +41,8 @@ class Consumer
|
||||
@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 !mouse_used && 0 < mouse_x - @draw_x && mouse_x - @draw_x < (SIZE * @box_size * @camera_zoom) && 0 < mouse_y - @draw_y && mouse_y - @draw_y < (SIZE * @box_size * @camera_zoom)
|
||||
@tooltip_timer += 60.0 * delta_mult
|
||||
if @tooltip_timer > HOVER_TIME
|
||||
@tooltip.show = true
|
||||
@tooltip.update(@draw_x, @draw_y, @camera_zoom)
|
||||
end
|
||||
else
|
||||
@tooltip_timer = 0
|
||||
@tooltip.show = false
|
||||
end
|
||||
|
||||
@tooltip.move(@draw_x, @draw_y)
|
||||
end
|
||||
|
||||
# Draw the consumer. Uses the camera x and y to shift where it should draw
|
||||
@@ -59,6 +51,5 @@ class Consumer
|
||||
puts "Drawing at #{@x - camera_x}, #{@y - camera_y}"
|
||||
end
|
||||
@image.draw(@draw_x, @draw_y, 0, @camera_zoom, @camera_zoom)
|
||||
@tooltip.draw()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user