Game Development Reference
In-Depth Information
Advanced Programming
Techniques
In this chapter, we will take a look at Box2D—a physics engine to simulate realistic-
looking physics of the objects in 2D space. After we cover the basics of how to use
Box2D, we will move on and create a little physics simulation that is going to be
triggered at the end of the level. For this to work, we will also need to add a new
level object that represents the level's end.
Next, we will look at the topic of shader programs. Shaders, in general, are simple
programs that are executed on the Graphics Processing Unit ( GPU ). We will create
our own shader program consisting of a vertex and a fragment shader to achieve a
simple monochrome filter effect.
Physics engines, such as Box2D and programming shaders, are very complex topics.
Each deserves at least one topic on their own to get hold of their gist. Nonetheless,
this chapter is meant to give you the first push in the right direction on how to
approach these broad topics.
Today's smartphones have an integrated accelerometer. This can be used to detect
the spatial position of the device, which is delivered by the accelerometer as one
value for each of the three axes. We will query the accelerometer hardware and use
the read values to translate them into the player movement in Canyon Bunny.
In this chapter, we will cover the following topics:
• 2D physics using Box2D
• Shader programs
• Use accelerometer as an alternate input method to move the bunny head
Search WWH ::




Custom Search