Class: Fet::Ui::Game

Inherits:
Object
  • Object
show all
Includes:
GameLoopHandler, GameSetupHelper
Defined in:
lib/fet/ui/game.rb

Overview

Holds the state of the current game

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GameLoopHandler

#handle_event_loop, #handle_update_loop, #set_level_complete_event_flag, #set_level_started_event_flag, #set_note_selected_event_flag

Constructor Details

#initialize(tempo:, degrees:, key_type:, next_on_correct:, limit_degrees: []) ⇒ Game

Returns a new instance of Game.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fet/ui/game.rb', line 21

def initialize(tempo:, degrees:, key_type:, next_on_correct:, limit_degrees: [])
  self.note_range = Fet::REDUCED_BY_OCTAVE_PIANO_RANGE
  self.tempo = tempo
  self.key_type = key_type
  self.number_of_degrees = degrees
  self.next_on_correct = next_on_correct
  self.limit_degrees = limit_degrees
  self.tmp_directory = Dir.mktmpdir
  initialize_ui_objects
  validate!
  setup_window
end

Instance Attribute Details

#key_typeObject

Returns the value of attribute key_type.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def key_type
  @key_type
end

#levelObject

Returns the value of attribute level.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def level
  @level
end

#limit_degreesObject

Returns the value of attribute limit_degrees.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def limit_degrees
  @limit_degrees
end

#next_on_correctObject

Returns the value of attribute next_on_correct.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def next_on_correct
  @next_on_correct
end

#note_rangeObject

Returns the value of attribute note_range.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def note_range
  @note_range
end

#number_of_degreesObject

Returns the value of attribute number_of_degrees.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def number_of_degrees
  @number_of_degrees
end

#scoreObject

Returns the value of attribute score.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def score
  @score
end

#tempoObject

Returns the value of attribute tempo.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def tempo
  @tempo
end

#timerObject

Returns the value of attribute timer.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def timer
  @timer
end

#tmp_directoryObject

Returns the value of attribute tmp_directory.



18
19
20
# File 'lib/fet/ui/game.rb', line 18

def tmp_directory
  @tmp_directory
end

Instance Method Details

#startObject



34
35
36
37
38
39
40
# File 'lib/fet/ui/game.rb', line 34

def start
  score.start
  level.start
  timer.start
  show_window
  Fet::ScoreSummary.add_entry(self)
end

#stopObject



42
43
44
# File 'lib/fet/ui/game.rb', line 42

def stop
  close_window
end