Engine Miscellaneous
Here you'll find various engine classes.
Counting Time
Cave Engine provides two useful classes for you to count Time: Timer
and SceneTimer
. They have the exact same API and the only different between them is that the latter will use the scene's elapsed time (when not paused) and the regular Timer
will use the system time.
In practice, this means that if you pause the scene, the SceneTimer
will also pause and the Timer
will keep counting. Most of the times, what you're looking for will be the SceneTimer
. :)
cave.Timer
You can Initialize it in two ways:
# This way it will start counting time at zero:
timer = Timer()
# And this way it will start at 10 seconds (for example):
timer = Timer(10.0)
Methods
# Returns the elapsed time (in seconds):
get() -> float
# Sets the counter to some initial value (in seconds):
set(value: float)
# Resets the counter to 0:
reset()
cave.SceneTimer
You can Initialize it in two ways:
# This way it will start counting time at zero:
timer = SceneTimer()
# And this way it will start at 10 seconds (for example):
timer = SceneTimer(10.0)
Methods
# Returns the elapsed time (in seconds):
get() -> float
# Sets the counter to some initial value (in seconds):
set(value: float)
# Resets the counter to 0:
reset()
Others
cave.BitMask
The BitMask is used by cave as Masks to filter various things, such as Rendering related components or even Physics. A bitmask consists in 32 bits, mapped from [0 to 31]. Keep in mind that if you attempt to manipulate a bit that's outside this range, it may lead to undefined behaviour.
A BitMask class can be instantiated by you just fine if you want:
myBitMask = cave.BitMask()
myBitMask.enable(1)
myBitMask.disable(2)
Methods
If you have two BitMasks and want to check if them intersect, meaning if they have some enabled bits in common, you can use this method:
intersect(other: BitMask) -> bool
Both functions bellow serves to check if a specific bit is enabled (True) or disabled (False).
isEnabled(bit: int) -> bool
get(bit: int) -> bool
To change a bit (enabling or disabling it), you can either use the set(...)
method or the equivalent enable/disable ones:
set(bit: int, value: bool)
enable(bit: int)
disable(bit: int)
If you want, you can also enable or disable all bits at once:
enableAll()
disableAll()