Пример #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            mBackground = new Sprite();
            mBall = new Ball();
            mWallTop = new Wall();
            mWallBottom = new Wall();

            player1 = new GameSpace(GameSpace.Player.One);
            player2 = new GameSpace(GameSpace.Player.Two);
            powerUp = new PowerUp("powerUpTest");
            base.Initialize();
        }
Пример #2
0
 public Sprite CheckCollisions(List<Sprite> colliders, GameSpace p1, GameSpace p2)
 {
     foreach (Sprite collider in colliders)
     {
         if (!this.BoundingBox.Intersects(collider.BoundingBox))
         {
             continue;
         }
         Paddle paddle = collider as Paddle;
         //collision with a paddle
         if (paddle != null)
         {
             paddle.CollideWithBall(this);
             return paddle;
         }
         Wall wall = collider as Wall;
         //wall collision
         if (wall != null)
         {
             if (wall.Equals(Game1.mWallTop))
             {
                 Position = new Vector2(Position.X, Game1.mWallTop.BoundingBox.Bottom + 1);
             }
             else
             {
                 Position = new Vector2(Position.X, Game1.mWallBottom.BoundingBox.Top - 1 - this.BoundingBox.Height);
             }
             this.m_direction.Y *= -1;
             return wall;
         }
         FadeBlock block = collider as FadeBlock;
         //fadeBlock collision
         if (block != null)
         {
             colliders.Remove(block);
             if (!p1.RemoveBlock(block))
                 p2.RemoveBlock(block);
             this.m_direction.X *= -1;
             return block;
         }
         PowerUp powerUp = collider as PowerUp;
         //powerUp collision
         if (powerUp != null)
         {
             return powerUp;
         }
     }
     return null;
 }
Пример #3
0
 public void Update(GameTime theGameTime, GameWindow window, GameSpace p1, GameSpace p2, List<Sprite> colliders, out Sprite gotHit)
 {
     m_prevPosition = Position;
     if (BoundingBox.Right > window.ClientBounds.Width)
     {
         Position = new Vector2(0, Position.Y);
     }
     if (BoundingBox.Left < 0)
     {
         Position = new Vector2(window.ClientBounds.Width - Source.Width, Position.Y);
     }
     gotHit = CheckCollisions(colliders, p1, p2);
     if (this.Speed.Y >= 300)
     {
         m_speed.Y = 300;
     }
     if (this.Speed.Y <= -300)
     {
         m_speed.Y = 300;
     }
     base.Update(theGameTime, m_speed, Direction);
 }
Пример #4
0
        public void LoadContent(ContentManager content, GameSpace.Player player1, GameWindow window)
        {
            base.LoadContent(content, ASSET_NAME);

            soundEffect = content.Load<SoundEffect>("blip");
        }