mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2026-11-04 16:33:52 +00:00
Added all the callbacks to Window and GameState, removed all but one usage of global variables ().
This commit is contained in:
@@ -9,7 +9,7 @@ module CyberarmEngine
|
||||
@options = options
|
||||
@game_objects = []
|
||||
@global_pause = false
|
||||
$window.text_input = nil unless options[:preserve_text_input]
|
||||
window.text_input = nil unless options[:preserve_text_input]
|
||||
|
||||
@down_keys = {}
|
||||
end
|
||||
@@ -30,48 +30,23 @@ module CyberarmEngine
|
||||
@game_objects.each(&:update)
|
||||
end
|
||||
|
||||
def draw_bounding_box(box)
|
||||
x = box.x
|
||||
y = box.y
|
||||
max_x = box.max_x
|
||||
max_y = box.max_y
|
||||
|
||||
color = Gosu::Color.rgba(255, 127, 64, 240)
|
||||
|
||||
# pipe = 4
|
||||
# Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY)
|
||||
# puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}"
|
||||
# Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY)
|
||||
|
||||
# TOP LEFT to BOTTOM LEFT
|
||||
$window.draw_line(
|
||||
x, y, color,
|
||||
x, max_y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
# BOTTOM LEFT to BOTTOM RIGHT
|
||||
$window.draw_line(
|
||||
x, max_y, color,
|
||||
max_x, max_y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
# BOTTOM RIGHT to TOP RIGHT
|
||||
$window.draw_line(
|
||||
max_x, max_y, color,
|
||||
max_x, y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
# TOP RIGHT to TOP LEFT
|
||||
$window.draw_line(
|
||||
max_x, y, color,
|
||||
x, y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
def needs_redraw?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
@options.clear
|
||||
@game_objects.clear
|
||||
def drop(filename)
|
||||
end
|
||||
|
||||
def gamepad_connected(index)
|
||||
end
|
||||
|
||||
def gamepad_disconnected(index)
|
||||
end
|
||||
|
||||
def gain_focus
|
||||
end
|
||||
|
||||
def lose_focus
|
||||
end
|
||||
|
||||
def button_down(id)
|
||||
@@ -90,6 +65,54 @@ module CyberarmEngine
|
||||
end
|
||||
end
|
||||
|
||||
def close
|
||||
window.close!
|
||||
end
|
||||
|
||||
def draw_bounding_box(box)
|
||||
x = box.x
|
||||
y = box.y
|
||||
max_x = box.max_x
|
||||
max_y = box.max_y
|
||||
|
||||
color = Gosu::Color.rgba(255, 127, 64, 240)
|
||||
|
||||
# pipe = 4
|
||||
# Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY)
|
||||
# puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}"
|
||||
# Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY)
|
||||
|
||||
# TOP LEFT to BOTTOM LEFT
|
||||
Gosu.draw_line(
|
||||
x, y, color,
|
||||
x, max_y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
# BOTTOM LEFT to BOTTOM RIGHT
|
||||
Gosu.draw_line(
|
||||
x, max_y, color,
|
||||
max_x, max_y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
# BOTTOM RIGHT to TOP RIGHT
|
||||
Gosu.draw_line(
|
||||
max_x, max_y, color,
|
||||
max_x, y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
# TOP RIGHT to TOP LEFT
|
||||
Gosu.draw_line(
|
||||
max_x, y, color,
|
||||
x, y, color,
|
||||
Float::INFINITY
|
||||
)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@options.clear
|
||||
@game_objects.clear
|
||||
end
|
||||
|
||||
def add_game_object(object)
|
||||
@game_objects << object
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user