protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); //sprite1 = new Sprite(Content.Load<Texture2D>("sprite1"), new Vector2(0,0), new Vector2(47, 49), graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, sprite1Sphere, Sprite1BoundingArray, Sprite1BoundingBox); ball = new Ball(new Sprite(Content.Load<Texture2D>("Ball"), new Vector2(100, 100), new Vector2(7, 7), graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); localPlayer = new Player(new Sprite(Content.Load<Texture2D>("VerticalPlayer"), new Vector2(5, 240 - 16), new Vector2(6, 60), graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), true); remotePlayer = new Player(new Sprite(Content.Load<Texture2D>("VerticalPlayer"), new Vector2(800-5-6, 240-16), new Vector2(6, 60), graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), false); }
public void Move(Player p1, Player p2) { if (outOfBounds()){ velocity.Y = -velocity.Y; } if (playerCollision(p1, p2)){ velocity.X = -velocity.X; } position.X += velocity.X; position.Y += velocity.Y; }
public void Update(Player p1, Player p2) { Move(p1, p2); boundingBox.Min = new Vector3(position.X, position.Y, 0); boundingBox.Max = new Vector3(position.X + 6, position.Y + 60, 0); sprite.Update(position); }
public bool playerCollision(Player p1, Player p2) { if (boundingBox.Intersects(p1.boundingBox) || boundingBox.Intersects(p2.boundingBox)) { return true; } else { return false; } }