Added actual images and prepared to add extractors
This commit is contained in:
@@ -1,3 +1,36 @@
|
|||||||
# number_factory
|
# number_factory
|
||||||
|
|
||||||
A game where you create combinations of numbers!
|
A game where you create combinations of numbers!
|
||||||
|
|
||||||
|
# UI elements
|
||||||
|
|
||||||
|
If you hover over the producers you will see the speed at which it produces.
|
||||||
|
|
||||||
|
If you hover over the consumer, you can see your next goal or quest
|
||||||
|
|
||||||
|
## tools
|
||||||
|
|
||||||
|
### Extractor
|
||||||
|
|
||||||
|
Extracts numbers. It is a three by three square and populates numbers from any
|
||||||
|
side (max 12) every time the producer ticks.
|
||||||
|
|
||||||
|
### Conveyer belt
|
||||||
|
|
||||||
|
Can move numbers around.
|
||||||
|
|
||||||
|
### Adder
|
||||||
|
|
||||||
|
Can output to either side but will only output to one space. Prefers the slot
|
||||||
|
on the left. If it is full though it will use the slots to the right
|
||||||
|
|
||||||
|
|
||||||
|
### Multiplier
|
||||||
|
|
||||||
|
### Subtractor
|
||||||
|
|
||||||
|
### Divider
|
||||||
|
|
||||||
|
### Exponent
|
||||||
|
|
||||||
|
### Logarithm
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 653 B After Width: | Height: | Size: 754 B |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 335 B |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 434 B |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
+2
-2
@@ -37,11 +37,11 @@ class Consumer
|
|||||||
# @param camera_x [Integer] The camera X position
|
# @param camera_x [Integer] The camera X position
|
||||||
# @param camera_y [Integer] The camera Y position
|
# @param camera_y [Integer] The camera Y position
|
||||||
# @param camera_zoom [Float] The camera zoom
|
# @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_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)
|
@draw_y = (((((@screen_height / @box_size.to_f) / 2.0) + (@y - camera_y) * camera_zoom) * @box_size) + BORDER * camera_zoom)
|
||||||
@camera_zoom = 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)
|
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
|
@tooltip_timer += 60.0 * delta_mult
|
||||||
if @tooltip_timer > HOVER_TIME
|
if @tooltip_timer > HOVER_TIME
|
||||||
@tooltip.show = true
|
@tooltip.show = true
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Nathan Hinton
|
||||||
|
#
|
||||||
|
# When placed it will extract numbers at a specified rate and place them on any
|
||||||
|
# conveyer belts that are adjacent to it.
|
||||||
|
|
||||||
|
class Extractor
|
||||||
|
def initialize(x, y, box_size)
|
||||||
|
@x = x
|
||||||
|
@y = y
|
||||||
|
@box_size = box_size
|
||||||
|
@image = Gosu.render(@box_size - (2 * BORDER), @box_size - (2 * BORDER)) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(delta_mult, camera_x, camera_y)
|
||||||
|
@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
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw()
|
||||||
|
@image.draw(@draw_x, @draw_y, 0, @camera_zoom, @camera_zoom)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -7,7 +7,7 @@ require 'yaml'
|
|||||||
|
|
||||||
require './producer.rb'
|
require './producer.rb'
|
||||||
require './consumer.rb'
|
require './consumer.rb'
|
||||||
require './dialouge_box.rb'
|
require './ui.rb'
|
||||||
|
|
||||||
FONT_PATH = 'assets/font/Cousine-Regular.ttf'
|
FONT_PATH = 'assets/font/Cousine-Regular.ttf'
|
||||||
|
|
||||||
@@ -45,9 +45,8 @@ class NumFactory < Gosu::Window
|
|||||||
@camera_x_zoom_offset = WIDTH.to_f / (@camera_boxes * BOX_SIZE * 2).to_f
|
@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
|
@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!")
|
@ui = UI.new(WIDTH, HEIGHT)
|
||||||
@dialouges = []
|
|
||||||
|
|
||||||
# Load from file or initialize a new game
|
# Load from file or initialize a new game
|
||||||
begin
|
begin
|
||||||
game_save_data = YAML.load_file("#{GAME_SAVE_DIRECTORY}/positions.yaml")
|
game_save_data = YAML.load_file("#{GAME_SAVE_DIRECTORY}/positions.yaml")
|
||||||
@@ -188,8 +187,10 @@ class NumFactory < Gosu::Window
|
|||||||
@camera_y = [@camera_y, @game_width].min
|
@camera_y = [@camera_y, @game_width].min
|
||||||
|
|
||||||
### ITEMS ###
|
### ITEMS ###
|
||||||
|
mouse_used = @ui.update(self.mouse_x, self.mouse_y)
|
||||||
|
|
||||||
@producers.each do |producer|
|
@producers.each do |producer|
|
||||||
producer.update(delta_mult, @camera_x, @camera_y, @camera_zoom, self.mouse_x, self.mouse_y)
|
producer.update(delta_mult, @camera_x, @camera_y, @camera_zoom, self.mouse_x, self.mouse_y, mouse_used)
|
||||||
end
|
end
|
||||||
|
|
||||||
@belts.each do |belt|
|
@belts.each do |belt|
|
||||||
@@ -197,10 +198,7 @@ class NumFactory < Gosu::Window
|
|||||||
end
|
end
|
||||||
|
|
||||||
@consumers.each do |consumer|
|
@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, self.mouse_x, self.mouse_y, mouse_used)
|
||||||
end
|
|
||||||
@dialouges.each do |dialouge|
|
|
||||||
dialouge.update(0, 0, newtext: "My new text is: #{delta_mult}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -209,9 +207,11 @@ class NumFactory < Gosu::Window
|
|||||||
def draw
|
def draw
|
||||||
# Draw mouse coords:
|
# Draw mouse coords:
|
||||||
onscreen_items = 0
|
onscreen_items = 0
|
||||||
|
# TODO: The background does *not* actually need to move. It can just stay
|
||||||
|
# in one spot and scale... This would make the program load so much faster
|
||||||
|
# as well as allow for larger maps.
|
||||||
@background.draw(
|
@background.draw(
|
||||||
(((((WIDTH / BOX_SIZE.to_f) / 2.0) - (@camera_x * @camera_zoom)) * (BOX_SIZE))),
|
(((((WIDTH / BOX_SIZE.to_f) / 2.0) - (@camera_x * @camera_zoom)) * (BOX_SIZE))),
|
||||||
|
|
||||||
((((HEIGHT / BOX_SIZE.to_f) / 2.0) - (@camera_y * @camera_zoom)) * (BOX_SIZE)),
|
((((HEIGHT / BOX_SIZE.to_f) / 2.0) - (@camera_y * @camera_zoom)) * (BOX_SIZE)),
|
||||||
0,
|
0,
|
||||||
@camera_zoom,
|
@camera_zoom,
|
||||||
@@ -236,9 +236,7 @@ class NumFactory < Gosu::Window
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@dialouges.each do |dialouge|
|
@ui.draw()
|
||||||
dialouge.draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
Gosu::Image.from_text("#{width}, #{height}", 20, font: FONT_PATH).draw(1600, 0, 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("#{mouse_x}, #{mouse_y}", 20, font: FONT_PATH).draw(1600, 100, 1)
|
||||||
|
|||||||
+10
-5
@@ -7,7 +7,6 @@ PRODUCER_DEBUG = false
|
|||||||
BORDER = 2
|
BORDER = 2
|
||||||
HOVER_TIME = 500 # ms
|
HOVER_TIME = 500 # ms
|
||||||
|
|
||||||
|
|
||||||
class Producer
|
class Producer
|
||||||
attr_reader :draw_x, :draw_y
|
attr_reader :draw_x, :draw_y
|
||||||
# Create producer at a position with the number and rate specified
|
# Create producer at a position with the number and rate specified
|
||||||
@@ -25,8 +24,8 @@ class Producer
|
|||||||
@screen_height = screen_height
|
@screen_height = screen_height
|
||||||
@image = Gosu.render(@box_size - (2 * BORDER), @box_size - (2 * BORDER)) {
|
@image = Gosu.render(@box_size - (2 * BORDER), @box_size - (2 * BORDER)) {
|
||||||
# Render the item
|
# Render the item
|
||||||
Gosu.draw_rect(0, 0, @box_size - (2 * BORDER), @box_size - (2 * BORDER), Gosu::Color::RED, 0)
|
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(5, 5, 1)
|
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")
|
@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_x [Integer] The camera X position
|
||||||
# @param camera_y [Integer] The camera Y position
|
# @param camera_y [Integer] The camera Y position
|
||||||
# @param camera_zoom [Float] The camera zoom
|
# @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_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)
|
@draw_y = (((((@screen_height / @box_size.to_f) / 2.0) + (@y - camera_y) * camera_zoom) * @box_size) + BORDER * camera_zoom)
|
||||||
@camera_zoom = 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
|
@tooltip_timer += 60.0 * delta_mult
|
||||||
if @tooltip_timer > HOVER_TIME
|
if @tooltip_timer > HOVER_TIME
|
||||||
@tooltip.show = true
|
@tooltip.show = true
|
||||||
@@ -53,6 +52,9 @@ class Producer
|
|||||||
@tooltip_timer = 0
|
@tooltip_timer = 0
|
||||||
@tooltip.show = false
|
@tooltip.show = false
|
||||||
end
|
end
|
||||||
|
if @extractor
|
||||||
|
@extractor.update()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Draw the producer. Uses the camera x and y to shift where it should draw
|
# Draw the producer. Uses the camera x and y to shift where it should draw
|
||||||
@@ -62,5 +64,8 @@ class Producer
|
|||||||
end
|
end
|
||||||
@image.draw(@draw_x, @draw_y, 0, @camera_zoom, @camera_zoom)
|
@image.draw(@draw_x, @draw_y, 0, @camera_zoom, @camera_zoom)
|
||||||
@tooltip.draw()
|
@tooltip.draw()
|
||||||
|
if @extractor
|
||||||
|
@extractor.update()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Nathan Hinton
|
||||||
|
# This is the UI for the game and will contain all of the sub elements required.
|
||||||
|
|
||||||
|
# There will be three main areas that we will be in charge of. First, the
|
||||||
|
# bottom bar has the selector of item types. There will be a menu in the top
|
||||||
|
# right as well as any store things that we need/
|
||||||
|
class UI
|
||||||
|
# Setup for the UI
|
||||||
|
# @param width [Integer] Width of screen in pixels
|
||||||
|
# @param height [Integer] Height of the screen in pixels
|
||||||
|
def initialize(width, height)
|
||||||
|
@width = width
|
||||||
|
@height = height
|
||||||
|
@tool_selector = []
|
||||||
|
@toolbar_width = width / 2
|
||||||
|
@toolbar_height = height / 9
|
||||||
|
@tool_selector_image = Gosu.render(@toolbar_width, @toolbar_height) {
|
||||||
|
Gosu.draw_rect(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
@toolbar_width,
|
||||||
|
@toolbar_height,
|
||||||
|
Gosu::Color.new(0xC0, 0xFF, 0xFF, 0xFF),
|
||||||
|
0)
|
||||||
|
Gosu::Image.from_text('tool selector', TEXT_SIZE, font: FONT_PATH).draw(TEXT_MARGIN, TEXT_MARGIN)
|
||||||
|
}
|
||||||
|
@x = (@width / 2) - (@toolbar_width / 2)
|
||||||
|
@y = @height - @toolbar_height
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(mouse_x, mouse_y)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw()
|
||||||
|
@tool_selector_image.draw(@x, @y)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user