Time for action – positioning tanks
To position tanks within our game, perform the following steps:
1. Add the following fields to the declarations area of the
TankBattlesGa
me
class:ContentManager p2Content; Random rand = new Random();
2. In the
Initialze()
method of theTankBattlesGame
class, add the following lines right before the call tobase.Init
ialize()
:p2Content = new ContentManager(this.Services); p2Content.RootDirectory = "Content";
3. Add the
StartNewRound()
method to theTankBattlesGame
class as follows:public void StartNewRound() { tanks.Clear(); Vector3 p1Position = new Vector3(rand.Next(8, 56), 0, rand.Next(8, 56)); Vector3 p2Position = new Vector3(rand.Next(8, 56), 0, rand.Next(8, 56)); int p1Quadrant = rand.Next(0, 4); switch (p1Quadrant) { case 0: p2Position += new Vector3(64, 0, 64); break; case 1: p1Position += new Vector3(64, 0, 0); p2Position += new Vector3...