[Sgdc] Boot Camp 3 Homework

Zack Freedman zfreedma at stevens.edu
Fri Apr 3 02:36:35 EDT 2009

This message is meant for members of SGDC Game Dev Boot Camp. If
you're not a member, become one!

Fall in, SGDC Boot Camp members!

We had a jam-packed lecture on Wednesday - we learned about creating
classes, access modifiers, method overloading, the advanced Draw
method, using the gamepad, and more. We used these skillz to craft the
foundation of an Asteroids-like arena shooter. Your homework is to
finish the job.

Here's your homework for the following lesson:
	- Add some enemies
		- Use the code we wrote in the lesson to make a GoodGuy
		- Modify it to create a BadGuy that moves around the screen
		- Implement a few BadGuys in your game
	- Add collision detection
		- Add a Rectangle that surrounds the sprite
		- Add a bool to store whether it's colliding
		- Use Rectangle.Intersects and Rectangle.Contains to set the value of the bool
		- Cause GoodGuys and BadGuys to change color when they're colliding
	- Turn it into a game
		- Use the code to create a Projectile
		- Allow the GoodGuy to release Projectiles when a button is pressed
	- Polish it Up

		- Prevent BadGuys from colliding with one another
		- Prevent the GoodGuy from colliding with his Projectiles
		- Prevent everything from leaving the screen
		- Cause everything to vanish and stop colliding when it gets hit
	- Extra Credit
		- Implement the ability to respawn
		- Draw numbers on the screen for a score counter
		- Create an enemy that follows the player
		- Create an explosion when something dies (Draw a Texture with
increasing scale and decreasing alpha)
		- Implement the ability for a second GoodGuy to be controlled by PlayerTwo

	- Remember to use the Object Browser, MSDN, and other Boot Campers for help!
	- In the error list, double-click an entry to jump to it
	- There are two control styles you could implement in your game:
		- Asteroids style: Player rotates left and right, separate button
for thrust, always shoots forward
		- Geometry Wars: Player uses left stick to change X/Y position,
right stick to aim
	- Remember to make the Rectangles public!
	- To make something "vanish", create a new Color using the overload
with four parameters. The fourth parameter is alpha, AKA transparency.
0 = transparent, 255 = opaque.
	- To get information about the size of the screen, check out
graphicsDevice.Viewport in your Game1 class.
	- To make a tighter rectangle, you can get your trig on using members
of the Math class. The Math class is static, so you don't need to
instantiate it. However, it uses double as arguments, so remember how
to cast! (float)doubleNumber
	- Some other classes that might come in handy:
		- Random: Generates different types of random numbers. Instantiate
and use Next() or NextDouble() to get a random number.
		- MathHelper: Plenty of math functions. Static (don't instantiate).
Less comprehensive than Math, but uses floats.

Common Problems:
	- Be careful with the parameters of the Draw method. It throws many
exceptions if you have even one wrong or missing parameter.
	- Make sure to use the correct access modifiers.
	- If the compiler tells you an explicit cast exists, you're either
using the wrong type of variable, or forgot to cast between double and
	- You're not really destroying the GoodGuy, BadGuy, and Projectile,
just making them invisible and non-responsive. We'll get into true
destruction next week.
	- If you're getting problems with null references, that means that a
variable was 'looked at' in code before it was instantiated.
	- Remember not to instantiate static classes and members. To check if
something is static, use the Object Browser.

More information about the SGDC mailing list