class SpaceInvaders::App
Constants
- DEFAULT_FONT
- DYNAMICS
- RELATIVE_DEFAULT_FONT
- STATICS
- TRACKERS
Public Class Methods
new(width=800, height=600, fullscreen=false)
click to toggle source
Calls superclass method
# File lib/space_invaders/app.rb, line 43 def initialize width=800, height=600, fullscreen=false super self.caption = "Space Invaders" initialize_statics initialize_dynamics_and_trackers end
Public Instance Methods
draw()
click to toggle source
# File lib/space_invaders/app.rb, line 62 def draw if game_status.hasnt_started? welcome_screen.draw elsif game_status.next_level? next_level_screen.draw elsif game_status.drowned_ship? or game_status.being_played? draw_dynamics draw_trackers elsif game_status.finished? game_over_screen.draw end end
draw_dynamics()
click to toggle source
# File lib/space_invaders/app.rb, line 83 def draw_dynamics DYNAMICS.each {|dynamic_element| self.send(dynamic_element).draw} end
draw_trackers()
click to toggle source
# File lib/space_invaders/app.rb, line 87 def draw_trackers TRACKERS.each {|tracker_element| self.send(tracker_element).draw} end
initialize_dynamics_and_trackers()
click to toggle source
# File lib/space_invaders/app.rb, line 79 def initialize_dynamics_and_trackers define_properties *DYNAMICS, *TRACKERS end
initialize_statics()
click to toggle source
# File lib/space_invaders/app.rb, line 75 def initialize_statics define_properties *STATICS end
update()
click to toggle source
# File lib/space_invaders/app.rb, line 54 def update if game_status.drowned_ship? ship.update elsif game_status.being_played? update_dynamics end end
update_dynamics()
click to toggle source
# File lib/space_invaders/app.rb, line 91 def update_dynamics DYNAMICS.each {|dynamic_element| self.send(dynamic_element).update} end
Private Instance Methods
define_properties(*properties)
click to toggle source
# File lib/space_invaders/app.rb, line 97 def define_properties(*properties) properties.each do |property| instance_variable_set "@#{property}", Utils.to_klass(property).new(self) end end