Game Development Reference
In-Depth Information
A couple of lessons can be taken from this example. The first one is how and where to set
the framerate limit—just after the initialization of the window. This will limit our game
logic somewhere close to 60 frames a seconds. Keep in mind that this controls the upper
limit of the framerate. If the frames start taking more than 1/60 seconds to complete
(handle events, update objects, and render), then the framerate will drop below 60.
However, with our simple code, that is extremely unlikely.
You've probably noticed a new function called RectangleShape::setOrigin() .
The origin of an object determines how it should be rendered on the screen. It serves as a
center point for the translation, rotation, and scale for the object. In the preceding ex-
ample, we have a square with size 50 x 50. The center of that square is (25, 25), so we
need to set that as the origin of the object. Otherwise, the object will start rotating around
Search WWH ::

Custom Search