OpenGL Game Projects
In 2008/9 I designed and built two simple OpenGL games in C++ for my graphics modules at UEA. I learnt these techniques from scratch, with no prior knowledge of graphics work save for Flash, which is so far removed from low level drawing it's hard to make any comparisons.
These projects have been submitted and marked, so I can release them here for people to play with. I won't be releasing the source code as some parts were supplied by my university for the modules, and I don't have permission to redistribute them.
This was my first game, and my first ever attempt at C++ or OpenGL development. The task was to design a simple game from scratch, meeting the following requirements:
- Top-down viewpoint
- Player controlled main character
- Computer controlled characters that follow the main character
- Computer controlled characters allowed to join or leave the group
- Obstacles or enemies to avoid
- A goal at the end of the level to lead characters to
My design for this was a swarm of bees controlled by the player, who had to avoid bears to reach the hive at the other end of the level. The graphic design for the game was fairly simple, with a grass texture for the background, then cartoon bees and bears for the characters. I designed all the objects myself in Fireworks, and the grass texture was taken from the excellent Mayang Texture Library.
One of the largest considerations was the swarm motion of the bees. After some research, Craig Reynolds' "Boids" algorithm looked to be a simple solution that could give elegant results. The algorithm is explained with pseudocode here. When implemented, this turned out to be not so simple. The motion was very jerky when the swarm flew close together, so I expanded the method with a few more rules to keep the bees moving.
What I really wanted was motion like Attack of the Killer Swarm, Kyle Gabler's excellent production for the Experimental Gameplay Project. You can download it from their site, it's well worth checking out.
You can download my game here:
This was my 3rd year graphics module project, and designed to be more of a graphics demo than a game. This time the environment had to be 3d, still using OpenGL and C++. These were the requirements:
- Vehicle driving through a 3d environment
- Multiple camera angles.
- Computer controlled vehicles moving through the environment
- Collision detection and response with buildings and vehicles
- Good lighting and textures
As the module was focused on the development of the program, and not 3D modelling, we were permitted to download and use models free from the internet. Turbosquid and Artist3D proved invaluable for this, with large collections of free models that could be refined to produce the demo with. Some basic knowledge of 3dsMax was still needed - models come in a huge variety of formats and scales, so they all need to be normalised and optimised.
One particular problem came to light when AI cars were added. The player car was a fairly high detail model which looked good up close and far away, and held up well with only vertex lighting. When 5 or more of the cars were needed, performance took a nose dive. The amount of polygons became prohibitive as every extra car demanded a huge number of vertexes to be pushed across the graphics bus. There were two ways to solve this problem:
- Vertex Buffer Objects:
- The vertex positions only need to be placed on the card once, then they can be translated and re-used every frame.
- Reduced detail models:
- The AI models are greatly reduced in quality, so the impact of copying them every frame is negligible.
As VBOs only came in to existence with nVidia's 8 series cards I could not guarantee their availability on every machine the demo might have to run on. The only solution that would work on every system was to reduce the detail in the AI cars. They were optimised in 3dsMax; their interiors removed, and extraneous detail taken away with the 'ProOptimise' modifier. The result brought the performance back up to a good level, but the lighting on the cars suffered as a result.
Download not available yet