public override void gameIni() { //set screen size this.setScreenSize(400, 400); //set screen colour this.setScreenColour(Microsoft.Xna.Framework.Graphics.Color.Black); //there should be no gravity this.setGravity(0); //create ball sprite ball = new sprite(this, "pong", 10, 10, 240, 120); leftPaddle = new sprite(this, "pong", 10, 80, 10, 160); rightPaddle = new sprite(this, "pong", 10, 80, 380, 160); //disable physics collisions //otherwise physics engine takes control of paddles response to being hit leftPaddle.enableCollision(false); rightPaddle.enableCollision(false); ball.enableCollision(false); //text objects to be used in the game title = new text(this, "pongText", "PONG"); playerScore = new text(this, "pongText", "0"); computerScore = new text(this, "pongText", "0"); //sets ball initial velocity ball.setVelocity(150, 150); }
public override void gameIni() { gameOver = false; finalStatus = new text(this, "Arial", ""); //create random variable objects rX = new Random(); rY = new Random(); this.setScreenSize(300, 400); //there should be no gravity this.setGravity(0); road = new sprite(this, "road", 300f, 400f, 150f, 200f); road.enableCollision(false); flag = new sprite(this, "flag", 40, 40, 200, -1000); flag.enableCollision(false); line1 = new sprite(this, "line", 10, 80, 145, 40); line1.enableCollision(false); line2 = new sprite(this, "line", 10, 80, 145, 140); line2.enableCollision(false); line3 = new sprite(this, "line", 10, 80, 145, 240); line3.enableCollision(false); line4 = new sprite(this, "line", 10, 80, 145, 340); line4.enableCollision(false); car = new sprite(this, "car", 30f, 60f, 135f, 200f, FarseerGames.FarseerPhysics.CollisionCategory.Cat3, FarseerGames.FarseerPhysics.CollisionCategory.Cat1); //car.enableCollision(false); //kids kid1 = new sprite(this, "kid2", 30, 30, rX.Next(100, 200), rY.Next(20, 100), FarseerGames.FarseerPhysics.CollisionCategory.Cat1, FarseerGames.FarseerPhysics.CollisionCategory.Cat3); kid2 = new sprite(this, "kid3", 30, 30, rX.Next(100, 200), rY.Next(20, 100), FarseerGames.FarseerPhysics.CollisionCategory.Cat2, FarseerGames.FarseerPhysics.CollisionCategory.Cat4); //create text object for timer timer = new text(this, "Arial", "0 seconds"); }
public override void gameIni() { gameOver = false; finalStatus = new text(this, "Arial", ""); //create random variable objects rX = new Random(); rY = new Random(); this.setScreenSize(300, 400); //there should be no gravity this.setGravity(0); road = new sprite(this, "road", 300f, 400f, 150f, 200f); road.enableCollision(false); flag = new sprite(this, "flag", 40, 40, 200, -1000); flag.enableCollision(false); line1 = new sprite(this, "line", 10, 80, 145, 40); line1.enableCollision(false); line2 = new sprite(this, "line", 10, 80, 145, 140); line2.enableCollision(false); line3 = new sprite(this, "line", 10, 80, 145, 240); line3.enableCollision(false); line4 = new sprite(this, "line", 10, 80, 145, 340); line4.enableCollision(false); car = new sprite(this, "car", 30f, 60f, 135f, 200f, FarseerGames.FarseerPhysics.CollisionCategory.Cat3, FarseerGames.FarseerPhysics.CollisionCategory.Cat1); //car.enableCollision(false); //kids kid1 = new sprite(this, "kid2", 30, 30, rX.Next (100,200), rY.Next(20,100),FarseerGames.FarseerPhysics.CollisionCategory.Cat1 ,FarseerGames.FarseerPhysics.CollisionCategory.Cat3 ); kid2 = new sprite(this, "kid3", 30, 30, rX.Next(100, 200), rY.Next(20, 100),FarseerGames.FarseerPhysics.CollisionCategory.Cat2 ,FarseerGames.FarseerPhysics.CollisionCategory.Cat4 ); //create text object for timer timer = new text(this, "Arial", "0 seconds"); }