forked from bionickatana/number_factory
Finished allowing placement and collision detection. However, the placement is very inconsistent. Thinking about redoing coordinates again...
This commit is contained in:
+9
-7
@@ -4,19 +4,21 @@
|
||||
# conveyer belts that are adjacent to it.
|
||||
|
||||
class Extractor
|
||||
attr_reader :draw_x, :draw_y, :size_x, :size_y
|
||||
def initialize(x, y, box_size)
|
||||
@x = x
|
||||
@y = y
|
||||
@size_x = @size_y = 3
|
||||
@x = x - @size_x / 2
|
||||
@y = y - @size_y / 2
|
||||
@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)
|
||||
@image = Gosu.render((@size_x * @box_size) - (2 * BORDER), (@size_y * @box_size) - (2 * BORDER)) {
|
||||
Gosu::Image.new('assets/images/extractor.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)
|
||||
def update(delta_mult, camera_x, camera_y, camera_zoom)
|
||||
@draw_x = (((((WIDTH / @box_size.to_f) / 2.0) + (@x - camera_x) * camera_zoom) * @box_size) + BORDER * camera_zoom)
|
||||
@draw_y = (((((HEIGHT / @box_size.to_f) / 2.0) + (@y - camera_y) * camera_zoom) * @box_size) + BORDER * camera_zoom)
|
||||
@camera_zoom = camera_zoom
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user