Class: Yeah::Ticker

Inherits:
Object
  • Object
show all
Defined in:
lib/yeah/_platform/ticker.rb

Overview

Note:

Provided by a Platform.

The Ticker provides a way to start a game loop.

Examples:

Print elapsed time between each tick

Ticker.new.on_tick { |elapsed| puts elapsed }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Ticker

Returns a new instance of Ticker.

Options Hash (options):

  • :rate (Numeric) — default: 60

    at ticks per second

Raises:

  • (NotImplementedError)

10
11
12
# File 'lib/yeah/_platform/ticker.rb', line 10

def initialize(options = {})
  raise NotImplementedError
end

Instance Attribute Details

#rateInteger


# File 'lib/yeah/_platform/ticker.rb', line 14

#tick_countInteger (readonly)


# File 'lib/yeah/_platform/ticker.rb', line 21

#ticks_per_secondInteger (readonly)


# File 'lib/yeah/_platform/ticker.rb', line 18

Instance Method Details

#on_tick {|elapsed| ... } ⇒ Object

Yields:

  • (elapsed)

    block to execute per tick

Yield Parameters:

  • elapsed (Numeric)

    time since last tick


# File 'lib/yeah/_platform/ticker.rb', line 24