Class: Game

Inherits:
Object
  • Object
show all
Defined in:
lib/delve/game.rb

Instance Method Summary collapse

Constructor Details

#initialize(display, screen_manager, input) ⇒ Game

Returns a new instance of Game.



2
3
4
5
6
7
8
9
# File 'lib/delve/game.rb', line 2

def initialize(display, screen_manager, input)
  raise 'Unable to initialize game when display is nil' unless display
  raise 'Unable to initialize game when screen manager is nil' unless screen_manager
  raise 'Unable to initalize game when input is nil' unless input
  @display = display
  @screen_manager = screen_manager
  @input = input
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/delve/game.rb', line 11

def start
  raise 'Unable to start game when screen_manager is empty' if @screen_manager.empty?
  quit = false
  while !quit
    @screen_manager.render @display
    @display.render

    quit = @screen_manager.update @input
  end
end