Window
class Game < Chingu::Window
def initialize
super
self.input = { :escape => :exit }
end
def update
super
self.caption = "FPS: #{self.fps}"
end
end
space, → | next slide |
← | previous slide |
d | debug mode |
## <ret> | go to slide # |
c | table of contents (vi) |
f | toggle footer |
r | reload slides |
z | toggle help (this) |
Chingu::Window
Chingu::GameObject
class Game < Chingu::Window
def initialize
super
self.input = { :escape => :exit }
end
def update
super
self.caption = "FPS: #{self.fps}"
end
end
class Player < Chingu::GameObject
def initialize
super
self.x, self.y = 200, 200
self.image = Image["ship.png"]
self.input = {
:holding_left => :move_left,
:holding_right => :move_right }
end
def move_left; @x -= 3; end
def move_right; @x += 3; end
end
Player.create
self.input => {:holding_x => :command}
:holding_x = 'every frame'
:x = 'key down'
:released_x = 'key up'
class SpaceShip < Chingu::GameObject
def initialize
self.input = {:space => :pewpew}
end
def pewpew
Sound["blaster.wav"].play
end
end
class Asteroid < Chingu::GameObject
traits :bounding_circle,
:collision_detection
end
# in your gamestate or window
def update
Player.each_collision(Asteroid) do |p,a|
p.destroy
end
end
class Level < Chingu::GameState
# initialize/update here
end
class Game < Chingu::Window
def initialize
push_game_state(Level)
# A built in editor!
push_game_state(Chingu::GameStates::Edit)
end
end
class Level < Chingu::GameState
def initialize
load_game_objects
self.input = {:s => :save_game_objects}
end
end
Chingu (And some finished game links)
Sound
Music
Graphics
Thanks!