Game Development Reference
In-Depth Information
size. The next thing which we need to mention is that the rectangle is slightly tilted, which
is expected, as we are rotating the rectangle by 30 degrees. In this example, we are setting
the position directly to (50, 50). However there is an alternative method to move trans-
formable objects and it's by calling Transformable::move() and passing a vector,
which indicates how much we want to move the object from its current position.
Everything that we have created so far has been mostly static, so now let's add a little life
to our objects. For that, we need to use the update frame, which we haven't been able to
utilize yet. That's the part of the frame just before we start the render frame. Remember,
typically a game frame (loop cycle) goes like this:
• Handle input
• The update frame
• The render frame
It is important to update objects before we render them, otherwise their current state will
not be rendered correctly—they will be rendered with their state from the last frame.
The next example shows how we use a combination of translation and rotation to create a
simple animation:
Search WWH ::




Custom Search