forked from bionickatana/number_factory
Finished camera and rendering of objects on screen.
This commit is contained in:
+17
-4
@@ -1,6 +1,8 @@
|
||||
## Nathan Hinton
|
||||
## A number producer that will create numbers when an extractor is placed on it.
|
||||
|
||||
PRODUCER_DEBUG = false
|
||||
|
||||
class Producer
|
||||
attr_reader :x, :y
|
||||
# Create producer at a position with the number and rate specified
|
||||
@@ -13,10 +15,19 @@ class Producer
|
||||
@y = y
|
||||
@number = number
|
||||
@rate = (30/rate).to_i
|
||||
@image = Gosu.render(30, 30) {
|
||||
# Render the item
|
||||
Gosu.draw_rect(0, 0, 30, 30, Gosu::Color::RED, 0)
|
||||
Gosu::Image.from_text("#{@number}", 20).draw(5, 5, 1)
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
# Creates numbers depending on the rate. This is done with knowing that the game is 30 fps so we use that for a counter
|
||||
def update
|
||||
# Creates numbers depending on the rate. This is done with knowing that the
|
||||
# game is 30 fps so we use that for a counter
|
||||
|
||||
# @param delta_mult [Float] The delta multiplier for any actions
|
||||
def update(delta_mult)
|
||||
|
||||
end
|
||||
|
||||
@@ -25,7 +36,9 @@ class Producer
|
||||
# @param camera_y [Integer] The camera Y position
|
||||
# @param camera_zoom [Float] The camera zoom
|
||||
def draw(camera_x, camera_y, camera_zoom)
|
||||
puts "Drawing at #{@x - camera_x}, #{@y - camera_y}"
|
||||
Gosu.draw_rect(@x - camera_x, @y - camera_y, camera_zoom * 30, camera_zoom * 30, Gosu::Color::RED, 0)
|
||||
if PRODUCER_DEBUG
|
||||
puts "Drawing at #{@x - camera_x}, #{@y - camera_y}"
|
||||
end
|
||||
@image.draw(camera_zoom * (@x - camera_x), camera_zoom * (@y - camera_y), 0, camera_zoom, camera_zoom)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user