Engine
The Engine
struct is central to Rusty Engine and has already shown up in many places in this tutorial. It is highly recommended to read through all of the Engine
API documentation.
Here are a few other tidbits that are worth calling out:
should_exit
- abool
field you can set totrue
to cause Rusty Engine to cleanly exit at the end of the frame.delta
- the duration of the previous frame as aDuration
. This should be used for ticking anyTimer
s.delta_f32
- the duration of the previous frame as anf32
. This should be used to produce smooth animation. For example, if you define a movement speed inpixels per second
such asconst MOVE_SPEED: f32 = 50.0
, then you can use it to actually move a sprite at that speed by multiplying it bydelta_f32
like this:sprite.translation.x += MOVE_SPEED * engine.delta_f32
time_since_startup
- the duration since the start of the program as aDuration
time_since_startup_f64
- the duration since the start of the program as anf64
. This needs to be a 64-bit float because it would be easy for anf32
to reach a number high enough to be low precision. If you want to do math with this number, you should do the math withf64
's, and then convert it to anf32
at the very end.window_dimensions
- aVec2
describing the width and height of the window in pixels. Since(0.0, 0.0)
is the center of the screen, the edges of the screen are +/-window_dimensions / 2.0
.
...for the rest of the fields (and methods), see the Engine
API documentation