Class: AdventureRL::Deltatime

Inherits:
Object
  • Object
show all
Defined in:
lib/AdventureRL/Deltatime.rb

Constant Summary collapse

DELTATIMES =

This Array is filled with all initialized Deltatime instances. The point of it is, that they are all reset once the Window opens ( Window#show ).

[]

Instance Method Summary collapse

Constructor Details

#initializeDeltatime

Returns a new instance of Deltatime.



7
8
9
10
11
12
13
# File 'lib/AdventureRL/Deltatime.rb', line 7

def initialize
  @last_update_at = nil
  @deltatime      = nil
  set_last_update_at
  set_deltatime
  DELTATIMES << self
end

Instance Method Details

#get_deltatimeObject Also known as: get, dt

Returns the value of the last calculated deltatime.



16
17
18
# File 'lib/AdventureRL/Deltatime.rb', line 16

def get_deltatime
  return @deltatime
end

#resetObject

Resets last updated deltatime. Used when wanting to pause this deltatime’s calculations, so when resumed, deltatime isn’t a large number.



32
33
34
# File 'lib/AdventureRL/Deltatime.rb', line 32

def reset
  set_last_update_at
end

#updateObject

Call this method every tick / frame to update the deltatime value.



24
25
26
27
# File 'lib/AdventureRL/Deltatime.rb', line 24

def update
  set_deltatime
  set_last_update_at
end