Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1.  public void Update(GameTime gameTime, Rectangle clientBounds)
  2.         {
  3.             foreach (Blob newBlob in blobList)
  4.             {
  5.                 switch (newBlob.direction)
  6.                 {
  7.                     case 1:
  8.                         position.X -= speed;
  9.                         break;
  10.                     case 2:
  11.                         position.X += speed;
  12.                         break;
  13.                     case 3:
  14.                         position.Y -= speed;
  15.                         break;
  16.                     case 4:
  17.                         position.Y += speed;
  18.                         break;
  19.                 }
  20.  
  21.                 if (newBlob.position.X <= 0)
  22.                 {
  23.                     speed *= -1;
  24.                 }
  25.                 if (position.Y <= 0)
  26.                 {
  27.                     speed *= -1;
  28.                 }
  29.                 if (position.X > clientBounds.Width)
  30.                 {
  31.                     speed *= -1;
  32.                 }
  33.                 if (position.Y > clientBounds.Height)
  34.                 {
  35.                     speed *= -1;
  36.                 }
  37.             }
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement