| XNA Game-Themed CS1 Examples ( XGC1 ) | |
|
Release 2.0 (XNA V3.1)
|
|
References:
Goals:
1. Obtain the example code
When the game starts, you'll see a screen that
looks similar to this:
This version of the 'zap' game looks and plays identically to the prior version, which was explained in the 160 tutorial .
The only difference, code-wise, between this version and the prior version is that this version uses a do...while loop, instead of a normal while loop.
2. Examining The Program:
Let's examine the C# source code that produces the behavior we see on-screen
| Version of code in 160 tutorial | Version of code in this tutorial |
|
XNACS1Circle
lastCircle = null;
Vector2 HeroBeam =
m_Hero.Center;
while
(HeroBeam.X
<= m_Enemy.CenterX)
{
HeroBeam.X += 1f;
lastCircle = CreateHeroPath(HeroBeam);
}
|
XNACS1Circle
lastCircle = null;
Vector2
HeroBeam = m_Hero.Center;
do
{
HeroBeam.X
+= 1f;
lastCircle
= CreateHeroPath(HeroBeam);
}
while
(HeroBeam.X
< m_Enemy.CenterX);
|
FURTHER EXERCISES::