Class: AdventureRL::Deltatime
- Inherits:
-
Object
- Object
- AdventureRL::Deltatime
- 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
-
#get_deltatime ⇒ Object
(also: #get, #dt)
Returns the value of the last calculated deltatime.
-
#initialize ⇒ Deltatime
constructor
A new instance of Deltatime.
-
#reset ⇒ Object
Resets last updated deltatime.
-
#update ⇒ Object
Call this method every tick / frame to update the deltatime value.
Constructor Details
#initialize ⇒ Deltatime
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_deltatime ⇒ Object 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 |
#reset ⇒ Object
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 |
#update ⇒ Object
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 |