6 Commits

Author SHA1 Message Date
leah 52f3ad0d48 mend
checked that all fonts are uniform
2026-06-14 22:23:16 -06:00
leah 509d30f6ad checked that all fonts are uniform 2026-06-14 22:21:30 -06:00
bionickatana 7aea94c224 Added font file and changed font to be monospace 2026-06-14 20:49:33 -06:00
bionickatana f8d69be2ad created dialouge boxes for the producers 2026-06-14 20:36:01 -06:00
bionickatana 1b1696becd Fixed scrolling speed issue 2026-06-14 20:35:45 -06:00
bionickatana c099fd5a19 Added test dialouge boxes 2026-06-14 16:03:31 -06:00
4 changed files with 7 additions and 24 deletions
+2 -23
View File
@@ -1,17 +1,9 @@
## Nathan Hinton
## A number consumer that will create numbers when an extractor is placed on it.
require './dialouge_box.rb'
CONSUMER_DEBUG = false
BORDER = 2
SIZE = 3
HOVER_TIME = 500 # ms
# This actually should be stored somewhere else. This is the goals/quests for the game
TASKS = [
"Collect 10 1's"
]
class Consumer
attr_reader :draw_x, :draw_y
@@ -27,9 +19,6 @@ class Consumer
@image = Gosu.render((SIZE * @box_size) - (2 * BORDER), (SIZE * @box_size) - (2 * BORDER)) {
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])
end
# Consumes numbers created
@@ -37,20 +26,11 @@ class Consumer
# @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)
@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 < (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
end
# Draw the consumer. Uses the camera x and y to shift where it should draw
@@ -59,6 +39,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
+1
View File
@@ -53,6 +53,7 @@ class DialougeBox
def draw()
if @show
puts "Drawing tooltip at #{@x}, #{@y}"
@image.draw(@x, @y, 0, @camera_zoom, @camera_zoom)
end
end
+1 -1
View File
@@ -197,7 +197,7 @@ class NumFactory < Gosu::Window
end
@consumers.each do |consumer|
consumer.update(delta_mult, @camera_x, @camera_y, @camera_zoom, self.mouse_x, self.mouse_y)
consumer.update(delta_mult, @camera_x, @camera_y, @camera_zoom)
end
@dialouges.each do |dialouge|
dialouge.update(0, 0, newtext: "My new text is: #{delta_mult}")
+3
View File
@@ -3,6 +3,7 @@
require './dialouge_box.rb'
PRODUCER_DEBUG = false
BORDER = 2
HOVER_TIME = 500 # ms
@@ -30,6 +31,7 @@ class Producer
}
@tooltip = DialougeBox.new(@x, @y, WIDTH, HEIGHT, "Produces #{@rate} number per second")
puts @tooltip.methods.sort
end
# Creates numbers depending on the rate. This is done with knowing that the
@@ -45,6 +47,7 @@ class Producer
@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)
@tooltip_timer += 60.0 * delta_mult
puts @tooltip_timer
if @tooltip_timer > HOVER_TIME
@tooltip.show = true
@tooltip.update(@draw_x, @draw_y, @camera_zoom)