Added font file and changed font to be monospace

This commit is contained in:
2026-06-14 20:49:33 -06:00
parent f8d69be2ad
commit 7aea94c224
4 changed files with 15 additions and 13 deletions
Binary file not shown.
+3 -3
View File
@@ -7,7 +7,7 @@ class DialougeBox
attr_accessor :show
def initialize(parent_x, parent_y, screen_width, screen_height, text)
@text = text
@longest_line = ((@text.split("\n").map { |ss| ss.length}.max) / 3).to_i
@longest_line = ((@text.split("\n").map { |ss| ss.length}.max) / 2.25).to_i
@line_count = @text.split("\n").length
@x = parent_x
@@ -24,7 +24,7 @@ class DialougeBox
Gosu::Color.new(0xC0, 0xFF, 0xFF, 0xFF),
0,
)
Gosu::Image.from_text(text, TEXT_SIZE).draw(TEXT_MARGIN, TEXT_MARGIN)
Gosu::Image.from_text(text, TEXT_SIZE, font: FONT_PATH).draw(TEXT_MARGIN, TEXT_MARGIN)
}
end
@@ -43,7 +43,7 @@ class DialougeBox
Gosu::Color.new(0xC0, 0xFF, 0xFF, 0xFF),
0,
)
Gosu::Image.from_text(newtext, TEXT_SIZE).draw(TEXT_MARGIN, TEXT_MARGIN)
Gosu::Image.from_text(newtext, TEXT_SIZE, font: FONT_PATH).draw(TEXT_MARGIN, TEXT_MARGIN)
}
end
@camera_zoom = camera_zoom
+10 -8
View File
@@ -9,6 +9,8 @@ require './producer.rb'
require './consumer.rb'
require './dialouge_box.rb'
FONT_PATH = 'assets/font/Cousine-Regular.ttf'
# Viewport resolution
WIDTH = Gosu::screen_width
HEIGHT = Gosu::screen_height
@@ -238,15 +240,15 @@ class NumFactory < Gosu::Window
dialouge.draw()
end
Gosu::Image.from_text("#{width}, #{height}", 20).draw(1600, 0, 1)
Gosu::Image.from_text("#{mouse_x}, #{mouse_y}", 20).draw(1600, 100, 1)
Gosu::Image.from_text("Tick time: #{((Time.now() - @tick_time).to_f * 1000).to_i}", 20).draw(1600, 25, 1)
Gosu::Image.from_text("FPS: #{Gosu.fps}", 20).draw(1600, 50, 1)
Gosu::Image.from_text("#{width}, #{height}", 20, font: FONT_PATH).draw(1600, 0, 1)
Gosu::Image.from_text("#{mouse_x}, #{mouse_y}", 20, font: FONT_PATH).draw(1600, 100, 1)
Gosu::Image.from_text("Tick time: #{((Time.now() - @tick_time).to_f * 1000).to_i}", 20, font: FONT_PATH).draw(1600, 25, 1)
Gosu::Image.from_text("FPS: #{Gosu.fps}", 20, font: FONT_PATH).draw(1600, 50, 1)
Gosu::Image.from_text("items on screen: #{onscreen_items}", 20).draw(1600, 75, 1)
Gosu::Image.from_text("Camera boxes: #{@camera_boxes}", 20).draw(1600, 175, 1)
Gosu::Image.from_text("Camera location: #{@camera_x}, #{@camera_y}", 20).draw(1600, 200, 1)
Gosu::Image.from_text("Camera zoom: #{@camera_zoom}, #{@camera_x_zoom_offset}", 20).draw(1600, 225, 1)
Gosu::Image.from_text("Camera viewport: (#{@camera_min_x}, #{@camera_min_y}) to (#{@camera_max_x}, #{@camera_max_y})", 20).draw(1600, 250, 1)
Gosu::Image.from_text("Camera boxes: #{@camera_boxes}", 20, font: FONT_PATH).draw(1600, 175, 1)
Gosu::Image.from_text("Camera location: #{@camera_x}, #{@camera_y}", 20, font: FONT_PATH).draw(1600, 200, 1)
Gosu::Image.from_text("Camera zoom: #{@camera_zoom}, #{@camera_x_zoom_offset}", 20, font: FONT_PATH).draw(1600, 225, 1)
Gosu::Image.from_text("Camera viewport: (#{@camera_min_x}, #{@camera_min_y}) to (#{@camera_max_x}, #{@camera_max_y})", 20, font: FONT_PATH).draw(1600, 250, 1)
end
end
+2 -2
View File
@@ -20,7 +20,7 @@ class Producer
@x = x
@y = y
@number = [number, 1].max
@rate = (30/rate).to_i
@rate = rate
@box_size = box_size
@screen_width = screen_width
@screen_height = screen_height
@@ -30,7 +30,7 @@ class Producer
Gosu::Image.from_text("#{@number}", 20).draw(5, 5, 1)
}
@tooltip = DialougeBox.new(@x, @y, WIDTH, HEIGHT, "This is a string\nof test text!")
@tooltip = DialougeBox.new(@x, @y, WIDTH, HEIGHT, "Produces #{@rate} number per second")
puts @tooltip.methods.sort
end