| 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 almost identically to the prior version, which was explained in the 305 tutorial . The only visible change is that instead of having a single, continuous beam that the player uses to try and zap the enemy, there is now a line of distinct dots, as pictured above.
Let's examine the C# source code that produces the behavior we see on-screen
| Version of code in 305 tutorial | Version of code in this tutorial |
|
XNACS1Circle
lastCircle = null
;
Vector2
HeroBeam = m_Hero.Center;
for
(float
x = m_Hero.CenterX+1; x <
m_Enemy.CenterX
;
x++
)
{
HeroBeam.X
= x;
lastCircle = CreateHeroPath(HeroBeam);
}
|
XNACS1Circle
lastCircle = null
;
Vector2
HeroBeam = m_Hero.Center;
for
(float x = m_Hero.CenterX+1; x < m_Enemy.CenterX;
x+=(3*HERO_PATH_SIZE
)
)
{
HeroBeam.X = x;
lastCircle = CreateHeroPath(HeroBeam);
}
|
FURTHER EXERCISES::