Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach (GameObject ball in shipList)
- {
- int MaxX = graphics.GraphicsDevice.Viewport.Width - ball.BoundingBox.Width;
- int MinX = 0;
- int MaxY = graphics.GraphicsDevice.Viewport.Height - ball.BoundingBox.Height;
- int MinY = 0;
- if (ball.Position.X > MaxX)
- {
- ball.Position.X = MaxX;
- ball.Velocity.X *= -1;
- }
- else if (ball.Position.X < MinX)
- {
- ball.Position.X = MinX;
- ball.Velocity.X *= -1;
- }
- if (ball.Position.Y > MaxY)
- {
- ball.Position.Y = MaxY;
- ball.Velocity.Y *= -1;
- }
- else if (ball.Position.Y < MinY)
- {
- ball.Position.Y = MinY;
- ball.Velocity.Y *= -1;
- }
- foreach (GameObject ball2 in shipList)
- {
- if (ball != ball2)
- {
- if (ball.BoundingBox.Intersects(ball2.BoundingBox))
- {
- ball.Velocity.X *= -1;
- ball.Velocity.Y *= -1;
- ball2.Velocity.X *= -1;
- ball2.Velocity.Y *= -1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement