Richard G Baldwin (512) 223-4758, NRG Room 4238, Baldwin@DickBaldwin.com, http://www.austincc.edu/baldwin

GAME 2342 Game Development Using C++

This material applies to classroom sections and Open Campus (PCM) sections taught by Professor Baldwin.

Lab Projects

Spring 2009

Revised 01/15/09

The official web page for this course is http://www.austincc.edu/baldwin/Spring09/Game2342WebPage/GAME2342.htm

Laboratory Software

BloodshedSoftware's Dev-C++ as well as Microsoft Visual Studio will be provided in the Game Programming lab at NRG.

The Allegro game engine will also be provided in the lab.

Lab Project #1

Using the C++ IDE of your choice and the game engine of your choice, write a program that will display your first or last name in a Windows graphics window.

Make it possible to move the name in any of eight directions (north, northeast, east, southeast, south, southwest, west, and northwest) by holding down various combinations of arrow keys.

The program terminates when the user presses the Esc key.

Demonstrate your program to Prof. Baldwin by the required date in order to receive credit for the project.

Lab Project #2

Using the C++ IDE of your choice and the game engine of your choice, write a program that behaves as described below:

Three alien ships fly slowly through the cross hairs of a weapon.  The viewfinder of the weapon is a square, 400 pixels on each side.

As the ships fly by, they discharge colored flares to discourage heat seeking missiles. Each ship discharges different color flares.

In addition, the ships don't fly in a straight path.  Instead, they take evasive maneuvers in an attempt to evade missiles.

The first ship discharges red flares. The path of the ship is a sine curve, centered on the cross hairs with a peak-to-peak amplitude of 400 and one full cycle on each side of the vertical cross hair.

The second ship to fly by discharges blue flares. The path of the ship is a cosine curve, centered on the cross hairs with a peak-to-peak amplitude of 400 and one full cycle on
each side of the vertical cross hair.

The third ship to fly by discharges green flares.  The path of the ship is a cosine-squared curve, with the cosine function that is multiplied by itself to produce the square centered on the cross hairs with a peak-to-peak amplitude of the square root of 400 pixels and one full cycle on each side of the vertical cross hair. In other words, the cosine function that is squared to produce the green flares is identical to the cosine curve traced out by the blue flares except that the amplitude is the square root of the amplitude of cosine function used to produce the blue flares.

The view of the flares through the weapon's viewpoint remains on the screen until the user presses a key on the keyboard.

A screen shot of the weapon's viewfinder after all three ships have flown by is shown in Figure 2.  Note, however, that, depending on your browser, this html rendering of the screen shot may not be the same size as the original.

Figure 2. Screen shot for Proj02.

Click here to download an executable version of the program encapsulated in a zip file.

Lab Project #3

By controlling the color of every individual pixel, create and display the graphics window shown in Figure 3. The blue graphics area of the window is 256 pixels wide and 256 pixels high.

Figure 3. Screen output from Proj03.

The text in the title bar is not important.

The background is pure blue.

The top edge of the large I is pure red (red intensity = 254 or 255, green and blue = 0 or 1).

The bottom edge of the large I is pure green (green intensity = 254 or 255, red and blue = 0 or 1).

The colors transition smoothly from pure red to pure green going from the top to the bottom of the large I.

Be sure to display your window side-by-side with my window to confirm that the dimensions of the large I are the same to within eyeball tolerances.  The closer your dimensions are to mine, the easier the program will be to write.

The fully-populated window must appear on the screen within a few milliseconds after the program starts running. (No long drawn-out screen painting period is allowed.)

Your populated window must remain on the screen until the user presses any key.

Lab Project #4

Click here to download an image file named tree.pcx encapsulated in a zip file named tree.zip. Extract the image file from the zip file.

Display two copies of the image file, one above the other, in a graphics window with dimensions of 340x680 as shown in Figure 4 below.  (The text in the title bar is unimportant.)

DO NOT hard code the size of the image anywhere in your program.  In other words, your program must discover the size of the image in order to place the two copies of the image, properly aligned in the graphics window.

Figure 4. Screen output from Proj04.

Before displaying the bottom image, modify the pixels in a square 150-pixels on each side in the center of that image.  Modify the pixels in such a way that the color of each pixel in the square is the negative of the color of the original pixel.

The fully-populated window must appear on the screen within a few milliseconds after the program starts running. (No long drawn-out screen painting period is allowed.)

The window must remain on the screen until the user presses any key.

Lab Project #5

Draw a black 220x220 graphics window on the screen as shown in Figure 5. 

Figure 5. Screen output from Proj05.

When you press the left mouse button, the mouse pointer disappears and a small red square, ten pixels on each side is drawn at the location of the mouse pointer as shown by the red squares in the upper portion of Figure 5.

When you press the right mouse button, a small green diamond (rotated square), 14 pixels from each vertex to the opposite vertex, is drawn in the location of the mouse pointer as shown by the green diamonds in the upper portion of Figure 5..

When you drag slowly with the left mouse button, the red squares form a wide solid line tracing out the path of the mouse pointer as shown in the middle left of Figure 5.

When you drag slowly with the right mouse button, the green diamonds form a wide solid line tracing out the path of the mouse pointer as shown in the middle right of Figure 5.

If you drag rapidly with a mouse button pressed, you may see a non-uniform sequence of red squares or green diamonds tracing out the path of the mouse pointer as shown in the lower portion of Figure 5.

When you release a mouse button, the mouse pointer reappears.

The program terminates when the user presses the Esc key.

IMPORTANT: You may not use any global variables in this project.

Lab Project #6

Create a sprite animation program of your own design.  One or more sprites must move in front of a multi-colored background image.  (The background must not be a solid color.) 

The user must be able to control the behavior of the sprite using either the mouse or the arrow keys (or both if you prefer)

During the course of the animation, the sprite must take on at least four different poses in a way that is consistent with the theme of the animation.  (See http://www.dickbaldwin.com/homeschool/Hs10000.htm#Figure_7 for an example of different sprite poses.)

Click the link below the image at http://www.dickbaldwin.com/homeschool/Hs10000.htm#Figure_4 to see an example of an animated sprite moving in front of a background image under control of the mouse.  (The boy walks toward the mouse pointer.)

You may create your own sprites or use sprites that you acquire from other sources, such as downloading them from the web.  Go to Google and search for sprites and you will find numerous sources for sprites on the web.

It is relatively easy to create your own sprites using the Alice software at http://www.alice.org/.  Alice is installed on the lab computers at NRG or you can download it for free and install it on your computer.  See http://www.dickbaldwin.com/tocalice.htm for information on running the Alice software.

You may also be able to extract sprites from the Scratch software at http://scratch.mit.edu// (which is also available for free) but I have never tried to do that.  Another possible source of sprites is the Greenfoot website at http://www.greenfoot.org/.

Lab Project #7

Write a computer game of your choice.  It can be as simple as hangman, Tic-Tac-Toe, and Rock-Scissors-Paper, or as complicated as Doom.  The choice is yours.  It doesn't have to be a new game.  It can simply be your implementation of a game that has been around for years. However, you need to be creative and make the player interface interesting.  It can be a two-person game, or it can be a one-person game where the person plays against the computer.  Once again, that's your choice.  Note, however, that the player interface must be primarily implemented using Allegro graphics and C++.

You will find links to many computer games that have been written by others using Allegro at http://www.allegro.cc/  While it will be okay for you to get ideas and and to use chunks of code from those games, please don't simply copy one of the existing games.  If you use one of those games as the basis for your game, make significant changes to the game, to the player interface, and to the code.

Lab Project #8

Same as Lab Project # 7 except that you must write a completely different game.

-end-

File: GAME2342LabProjects.htm