Beispiel #1
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;
     }
 }