XNA Game-Themed CS1 Examples ( XGC1 )

Release 2.0 (XNA V3.1)
2/8/2010

Topic: Topic.5.RepetitionStructures
Example: Ex_1.ZapGameTemplate

Zap Game: Begin template


References:

Goals:



1. Obtain the example code

Download and unzip the zip file and you will see an ExampleProgram folder. Open the ExampleProgram folder, the EXE folder contains the compiled program and you can double click on the .sln file to work with the source code.

When the game starts, you'll see a screen that looks similar to this:


As you look at the screen (and play the game), you can see that there's already a lot going on.   There are a number of blocks scattered randomly across the screen.  The "Enemy" soccer ball on the right is moving up and down the screen.  At the bottom of the screen, you can see the "Enemy not zap"  message.  Every so often, you'll hear a sound as the enemy tries to zap you; the message at the bottom of the screen will briefly change to "Enemy try to send zap path!".  You'll notice that the 'beam' the enemy shoots isn't nearly long enough to reach to your side of the screen.

You control the "Hero" basketball on the left side of the screen, and can move that up and down the screen. Whenever you push the 'A' button, you should hear a sound, and see two circles appear, then disappear, next to your basketball.  If you push the 'B' button, everything on the screen (your basketball, the enemy soccer ball, all the blocks) are randomly placed at new heights on the screen.

The goal of the game is for you to 'zap' the enemy with a laser beam more times than the enemy zaps you with it's laser beam.  You'll notice that right now neither you, nor the enemy, can actually shoot a laser beam.  This is something that you'll fix, as you work your way through the chapter.

Source code to produce all of the above effects are provided for you in this tutorial - you are NOT expected to write all of the above from scratch yourself.  You ARE expected to be able to understand almost everything that's provided to you, since the provided code is very similar to material that you've looked at in prior tutorials.  There is a small amount of genuinely new stuff, which is what we'll look at in this tutorial.

Having said that, it is important to emphasize what you will be expected to do with this project, so that you understand what you'll need to do to extend this game in future tutorials: despite being given a lot of code, in future tutorials your job will be to add (or modify) small amounts of new code.  In other words, once you get an understanding of how the provided .  This is important because while the volume of code may seem overwhelming at first, the reality is that you'll be making very small, manageable changes to this game throughout this chapter.  In order to make it easy to find the very small amount of code that you will need to change, those lines of code have been highlighted in yellow , below.

Also, you may wish to see the 'finished' version of the game that we will build up to in this chapter.  You can find it in 490 tutorial, in this chapter.


2. Overview Of The Program:

Let's start by taking a quick look at the program as a whole.  For right now, we'll focus on the familiar stuff that you already know, and leave anything that's new till later in this tutorial