예제 #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
            ms = new MouseState();

            myGrid = new Grid(new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), 20, 40);
            myBall = new Ball(this, "Ball");
            myPaddle = new paddle(1);
            myCursor = new Cursor(this, ms, "Cursor");
            myFireBar = new FireBallBar(this, "FireBallBar", new Rectangle(0, 550, 100, 50), ms);

            base.Initialize();
        }
예제 #2
0
 //this is called every frame, it checks the grid (bricks in this game)
 public void Update(Grid grid)
 {
     bool coll = false;
     ball.X += (int)ballVelocity.X;
     if (grid.hasCollided(ball) == true) // Check if collided with left or right of brick
     {
         ballVelocity.X *= -1;
         coll = true;
     }
     ball.Y += (int)ballVelocity.Y;
     if (grid.hasCollided(ball) == true && coll == false) // Check if collided with top or bottom of brick
     {
         ballVelocity.Y *= -1;
     }
 }