struct Prism::Clock
- Prism::Clock
- Struct
- Value
- Object
Overview
Represents a scalable game clock.
With the Clock
you can use the concept of 24 hour time in your game in a natural way.
The Clock
has a dual purpose. It can represent a point of time or a length of time.
This is because all it does is produce a single float value.
Therefore 1:30
could mean one thirty am or one hour and 30 minutes. It all depends on your context.
Defined in:
prism/clock.crConstant Summary
-
REAL_DAY_LENGTH =
((24 * 60) * 60).to_f64
-
The length of a regular day in seconds
Constructors
-
.new(hour : Int32 = 0, minute : Int32 = 0, second : Int32 = 0, day_length : Float64 = @@day_length)
Creates a new
Clock
instance that corresponds to the given time.
Class Method Summary
- .day_length
- .day_length=(day_length : Float64)
-
.now(day_length : Float64 = @@day_length)
Creates a new
Clock
instance that corresponds to the current game time. -
.set_time(clock : Prism::Clock)
Changes the current time.
Instance Method Summary
Constructor Detail
Creates a new Clock
instance that corresponds to the given time.
By default the Clock
will use a standard day length. Meaning, the clock will use a 24 hour day.
You can scale the day down to a smaller time frame by a number of seconds to day_length.
Example
Here we set the day length to 10 seconds. So noon would occur at 5 seconds.
clock = Clock.new(hour: 12, day_length: 10)
clock.real_seconds # => 5
Class Method Detail
Creates a new Clock
instance that corresponds to the current game time.