mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2026-11-04 16:33:52 +00:00
Fixed crash due to old code from initial import, various clean up.
This commit is contained in:
@@ -1,64 +1,51 @@
|
||||
class GameState
|
||||
SCALE_X_BASE = 1920.0
|
||||
SCALE_Y_BASE = 1080.0
|
||||
attr_accessor :options, :global_pause
|
||||
attr_reader :game_objects
|
||||
module CyberarmEngine
|
||||
class GameState
|
||||
include Common
|
||||
|
||||
def initialize(options={})
|
||||
$window.set_game_state(self)
|
||||
@options = options unless @options
|
||||
@game_objects = []
|
||||
@global_pause = false
|
||||
SCALE_X_BASE = 1920.0
|
||||
SCALE_Y_BASE = 1080.0
|
||||
attr_accessor :options, :global_pause
|
||||
attr_reader :game_objects
|
||||
|
||||
setup
|
||||
@_4ship = Ship.all.first if Ship.all.is_a?(Array)
|
||||
end
|
||||
def initialize(options={})
|
||||
@options = options unless @options
|
||||
@game_objects = []
|
||||
@global_pause = false
|
||||
|
||||
def setup
|
||||
end
|
||||
|
||||
def draw
|
||||
# count = 0
|
||||
@game_objects.each do |o|
|
||||
o.draw if o.visible
|
||||
# p o.class if o.visible
|
||||
# count+=1 if o.visible
|
||||
setup
|
||||
end
|
||||
# puts "Num visible objects: #{count} of #{@game_objects.count}"
|
||||
end
|
||||
|
||||
def update
|
||||
@game_objects.each do |o|
|
||||
unless o.paused || @global_pause
|
||||
o.world_center_point.x = @_4ship.x
|
||||
o.world_center_point.y = @_4ship.y
|
||||
def setup
|
||||
end
|
||||
|
||||
o.update
|
||||
o.update_debug_text if $debug
|
||||
def draw
|
||||
@game_objects.each do |o|
|
||||
o.draw if o.visible
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@options = nil
|
||||
@game_objects = nil
|
||||
end
|
||||
def update
|
||||
@game_objects.each do |o|
|
||||
unless o.paused || @global_pause
|
||||
o.update
|
||||
o.update_debug_text if $debug
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
@game_objects.each do |o|
|
||||
o.button_up(id) unless o.paused
|
||||
def destroy
|
||||
@options = nil
|
||||
@game_objects = nil
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
@game_objects.each do |o|
|
||||
o.button_up(id) unless o.paused
|
||||
end
|
||||
end
|
||||
|
||||
def add_game_object(object)
|
||||
@game_objects << object
|
||||
end
|
||||
end
|
||||
|
||||
def push_game_state(klass, options={})
|
||||
$window.push_game_state(klass, options)
|
||||
end
|
||||
|
||||
def draw_rect(x, y, width, height, color, z = 0)
|
||||
$window.draw_rect(x,y,width,height,color,z)
|
||||
end
|
||||
|
||||
def add_game_object(object)
|
||||
@game_objects << object
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user