Class: Kawaii::Game
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Kawaii::Game
- Defined in:
- lib/kawaii/game.rb
Constant Summary collapse
- CONFIG_PATH =
File.(".") +'/config.yml'
- CONFIG =
YAML.load_file(CONFIG_PATH)
Instance Attribute Summary collapse
-
#content_root ⇒ Object
Returns the value of attribute content_root.
-
#font ⇒ Object
Returns the value of attribute font.
-
#fullscreen ⇒ Object
Returns the value of attribute fullscreen.
-
#height ⇒ Object
Returns the value of attribute height.
-
#show_fps ⇒ Object
Returns the value of attribute show_fps.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #before_update ⇒ Object
- #delta ⇒ Object
- #draw ⇒ Object
- #get_fps ⇒ Object
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #update ⇒ Object
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kawaii/game.rb', line 12 def initialize super CONFIG['resolution']['width'], CONFIG['resolution']['height'], CONFIG['fullscreen'] @width, @height, @fullscreen = CONFIG['resolution']['width'], CONFIG['resolution']['height'], CONFIG['fullscreen'] @content_root = CONFIG['content_root'] @scene_manager = Kawaii::SceneManager.new(self) # load intro scene @scene_manager.push_scene Kawaii::Intro.new @scene_manager # stats @top_color = Gosu::Color.new(0xFF1EB1FA) @bottom_color = Gosu::Color.new(0xFF1D4DB5) @font = Gosu::Font.new(self, Gosu::default_font_name, 18) @debug = CONFIG['debug'] if @debug puts "Game settings:" puts "\tResolution: #{width}:#{height}" puts "\tFullscreen: #{fullscreen}" puts "\tContent root: #{content_root}" end end |
Instance Attribute Details
#content_root ⇒ Object
Returns the value of attribute content_root.
10 11 12 |
# File 'lib/kawaii/game.rb', line 10 def content_root @content_root end |
#font ⇒ Object
Returns the value of attribute font.
10 11 12 |
# File 'lib/kawaii/game.rb', line 10 def font @font end |
#fullscreen ⇒ Object
Returns the value of attribute fullscreen.
10 11 12 |
# File 'lib/kawaii/game.rb', line 10 def fullscreen @fullscreen end |
#height ⇒ Object
Returns the value of attribute height.
10 11 12 |
# File 'lib/kawaii/game.rb', line 10 def height @height end |
#show_fps ⇒ Object
Returns the value of attribute show_fps.
10 11 12 |
# File 'lib/kawaii/game.rb', line 10 def show_fps @show_fps end |
#width ⇒ Object
Returns the value of attribute width.
10 11 12 |
# File 'lib/kawaii/game.rb', line 10 def width @width end |
Instance Method Details
#before_update ⇒ Object
41 42 |
# File 'lib/kawaii/game.rb', line 41 def before_update end |
#delta ⇒ Object
44 45 46 |
# File 'lib/kawaii/game.rb', line 44 def delta 16.0 # TODO: real delta end |
#draw ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/kawaii/game.rb', line 52 def draw draw_quad( 0, 0, @top_color, @width, 0, @top_color, @width, @height, @bottom_color, 0, @height, @bottom_color, ) @scene_manager.draw if @debug @font.draw("FPS: #{get_fps}", 14, 14, 0) end end |
#get_fps ⇒ Object
48 49 50 |
# File 'lib/kawaii/game.rb', line 48 def get_fps 1000.0 / delta end |
#update ⇒ Object
35 36 37 38 39 |
# File 'lib/kawaii/game.rb', line 35 def update before_update() @dt = delta() @scene_manager.update @dt end |