Add dialouge boxes/tooltips (#10)
- [x] Update objects so they know when the mouse is on them - [x] Remove testing code - [x] Add into the producers - [x] Add into the consumer - [x] Standardize fonts --------- Co-authored-by: leah <leah@hintonclan.org> Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
@@ -7,6 +7,9 @@ require 'yaml'
|
||||
|
||||
require './producer.rb'
|
||||
require './consumer.rb'
|
||||
require './dialouge_box.rb'
|
||||
|
||||
FONT_PATH = 'assets/font/Cousine-Regular.ttf'
|
||||
|
||||
# Viewport resolution
|
||||
WIDTH = Gosu::screen_width
|
||||
@@ -42,6 +45,9 @@ class NumFactory < Gosu::Window
|
||||
@camera_x_zoom_offset = WIDTH.to_f / (@camera_boxes * BOX_SIZE * 2).to_f
|
||||
@camera_y_zoom_offset = HEIGHT.to_f / (@camera_boxes * BOX_SIZE * 2).to_f
|
||||
|
||||
@dd = DialougeBox.new(0, 0, WIDTH, HEIGHT, "This is a really really really really really really really really really really string\nof test text!")
|
||||
@dialouges = []
|
||||
|
||||
# Load from file or initialize a new game
|
||||
begin
|
||||
game_save_data = YAML.load_file("#{GAME_SAVE_DIRECTORY}/positions.yaml")
|
||||
@@ -164,15 +170,15 @@ class NumFactory < Gosu::Window
|
||||
### CAMERA ###
|
||||
# Move the camera if needed
|
||||
if self.mouse_x < CAMERA_MOVE_RANGE
|
||||
@camera_x -= ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_x ) / 5)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
@camera_x -= ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_x ) / 5)), CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
elsif self.mouse_x > WIDTH - CAMERA_MOVE_RANGE
|
||||
@camera_x += ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (WIDTH - self.mouse_x) ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
@camera_x += ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (WIDTH - self.mouse_x + 1)) / 5)), CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
end
|
||||
|
||||
if self.mouse_y < CAMERA_MOVE_RANGE
|
||||
@camera_y -= ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_y ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
@camera_y -= ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_y ) / 5)), CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
elsif self.mouse_y > HEIGHT - CAMERA_MOVE_RANGE
|
||||
@camera_y += ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (HEIGHT - (self.mouse_y + 1)) ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
@camera_y += ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (HEIGHT - (self.mouse_y + 1)) ) / 5)), CAMERA_MOVE_MAX_SPEED].min * delta_mult)
|
||||
end
|
||||
|
||||
# Prevent camera from leaving the screen
|
||||
@@ -183,7 +189,7 @@ class NumFactory < Gosu::Window
|
||||
|
||||
### ITEMS ###
|
||||
@producers.each do |producer|
|
||||
producer.update(delta_mult, @camera_x, @camera_y, @camera_zoom)
|
||||
producer.update(delta_mult, @camera_x, @camera_y, @camera_zoom, self.mouse_x, self.mouse_y)
|
||||
end
|
||||
|
||||
@belts.each do |belt|
|
||||
@@ -191,8 +197,12 @@ class NumFactory < Gosu::Window
|
||||
end
|
||||
|
||||
@consumers.each do |consumer|
|
||||
consumer.update(delta_mult, @camera_x, @camera_y, @camera_zoom)
|
||||
consumer.update(delta_mult, @camera_x, @camera_y, @camera_zoom, self.mouse_x, self.mouse_y)
|
||||
end
|
||||
@dialouges.each do |dialouge|
|
||||
dialouge.update(0, 0, newtext: "My new text is: #{delta_mult}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
## Called when OS wants to update window.
|
||||
@@ -225,15 +235,20 @@ class NumFactory < Gosu::Window
|
||||
end
|
||||
end
|
||||
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("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)
|
||||
|
||||
@dialouges.each do |dialouge|
|
||||
dialouge.draw()
|
||||
end
|
||||
|
||||
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, font: FONT_PATH).draw(1600, 75, 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user