Game Development Reference
In-Depth Information
With that done we can move to our game loop. The first thing we want to do is handle
events:
We can see the close window implementation on a Closed event. We want to do
something on the click of a mouse button though—play the sound. This is done easily
enough by calling Sound::play() .
Now, let's look at the update frame:
The first two lines are there to account for a situation in which the Listener changes
position in each frame. However, in this particular example, the listener is stationary and,
as such, we can opt to omit them. The next four lines move the sound to the position of
the mouse (relative to the current window). Note that we have updated the sprite as well.
The final task in the example is rendering the scene. We only have two shapes so that
should be an easy enough job:
Search WWH ::




Custom Search