Class: Core::States::StartMenu

Inherits:
State show all
Includes:
Core
Defined in:
lib/states/menus/start.rb

Constant Summary

Constants included from Core

CURSOR_Z, DEFAULT_CONFIG, DEFAULT_FONT, FOG_Z, GUI_Z, HOME_PATH, LIBRARY_PATH, MAPOBJECT_Z, MAP_Z, PARTICLE_Z, RELEASE, Core::SAVE_DIR, VERSION

Instance Attribute Summary

Attributes inherited from State

#window, #x, #y

Instance Method Summary collapse

Methods included from Core

anim, animations, animations=, between?, config, exit, font, inside?, load_game, mouse_inside?, multiline, particles, particles=, save_game, silently, sprite, tiles, window, window=

Methods inherited from State

#draw_cursor, #finish, #update_cursor

Constructor Details

#initialize(window) ⇒ StartMenu

Returns a new instance of StartMenu.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/states/menus/start.rb', line 8

def initialize(window)
  super(window)
  @background = Core.sprite("menu/start_background") # FIXME use window background
  @w = Core::GUI::Window.new(0, 0, 1024, 768, Trans.menu(:titlescreen_title), false)
  @w.add(:newgame, Core::GUI::Button.new(160, 544, 256, 64, Trans.menu(:newgame), lambda { Core.window.advance(GameState.new(Core.window)); @song.stop }, false))
  #@w.add(:loadgame, Core::GUI::Button.new(608, 544, 256, 64, Trans.menu(:loadgame), lambda { Core.window.advance(LoadMenu.new(Core.window)) }, false))
  @w.add(:loadgame, Core::GUI::Button.new(608, 544, 256, 64, Trans.menu(:loadgame), lambda { Core.load_game }))
  @w.add(:options, Core::GUI::Button.new(160, 640, 256, 64, Trans.menu(:options), lambda { Core.window.advance(OptionMenu.new(Core.window)) }, false))
  @w.add(:update, Core::GUI::Button.new(608, 640, 256, 64, Trans.menu(:update), lambda { Core.window.advance(UpdateMenu.new(Core.window)) }, false))
  @leaves = Core::Particles.new(:title_leaves, 512, 0)
  @song = Core::Song.new("Greendjohn - Rebirth")
  @song.play(true)
  @w.get(:loadgame).disable if Dir.entries("#{Core::SAVE_DIR}").join == "..."
end

Instance Method Details

#drawObject



29
30
31
32
33
34
# File 'lib/states/menus/start.rb', line 29

def draw
  @background.draw(0, 0, 0)
  @w.draw
  @leaves.draw
  draw_cursor
end

#updateObject



23
24
25
26
27
# File 'lib/states/menus/start.rb', line 23

def update
  update_cursor
  @w.update
  @leaves.update
end