Class: Brawl::Clock

Inherits:
Object
  • Object
show all
Defined in:
lib/brawl/clock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tick_rate = 0.05) ⇒ Clock

Returns a new instance of Clock.



7
8
9
10
11
# File 'lib/brawl/clock.rb', line 7

def initialize(tick_rate=0.05)
  @tick_rate  = tick_rate
  @state      = :wait
  @ticks      = 0
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



5
6
7
# File 'lib/brawl/clock.rb', line 5

def state
  @state
end

#tick_rateObject (readonly)

Returns the value of attribute tick_rate.



5
6
7
# File 'lib/brawl/clock.rb', line 5

def tick_rate
  @tick_rate
end

#ticksObject (readonly)

Returns the value of attribute ticks.



5
6
7
# File 'lib/brawl/clock.rb', line 5

def ticks
  @ticks
end

Instance Method Details

#startObject



13
14
15
16
# File 'lib/brawl/clock.rb', line 13

def start
  @state = :running
  ticking
end

#stopObject



18
19
20
# File 'lib/brawl/clock.rb', line 18

def stop
  @state = :stopping
end