Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.38 KB | None | 0 0
  1. public void AddSmallestEnemy()
  2.         {
  3.             Blob newBlob = new Blob();
  4.             newBlob.texture = blob;
  5.             newBlob.position.X = (float)random.Next(0, 930);
  6.             newBlob.position.Y = (float)random.Next(0, 620);
  7.             newBlob.speed = 1;
  8.             newBlob.scale = 0.1f;
  9.             newBlob.direction = random.Next(1, 4);
  10.             blobList.Add(newBlob);  
  11.         }
  12.  
  13.         public void AddSmallerEnemy()
  14.         {
  15.             Blob newBlob = new Blob();
  16.             newBlob.texture = blob;
  17.             newBlob.position.X = (float)random.Next(0, 930);
  18.             newBlob.position.Y = (float)random.Next(0, 620);
  19.             newBlob.direction = random.Next(1, 4);
  20.             newBlob.speed = 1;
  21.             newBlob.scale = 0.2f;
  22.             blobList.Add(newBlob);
  23.         }
  24.  
  25.         public void AddMediumEnemy()
  26.         {
  27.             Blob newBlob = new Blob();
  28.             newBlob.texture = blob;
  29.             newBlob.position.X = (float)random.Next(0, 930);
  30.             newBlob.position.Y = (float)random.Next(0, 620);
  31.             newBlob.direction = random.Next(1, 4);
  32.             newBlob.speed = 1;
  33.             newBlob.scale = 0.5f;
  34.             blobList.Add(newBlob);
  35.         }
  36.  
  37.  
  38.  
  39. public void Update(GameTime gameTime, Rectangle clientBounds)
  40.         {
  41.             foreach (Blob newBlob in blobList)
  42.             {
  43.                 switch (newBlob.direction)
  44.                 {
  45.                     case 1:
  46.                         position.X -= speed;
  47.                         break;
  48.                     case 2:
  49.                         position.X += speed;
  50.                         break;
  51.                     case 3:
  52.                         position.Y -= speed;
  53.                         break;
  54.                     case 4:
  55.                         position.Y += speed;
  56.                         break;
  57.                 }
  58.  
  59.                 if (newBlob.position.X <= 0)
  60.                 {
  61.                     speed *= -1;
  62.                 }
  63.                 if (newBlob.position.Y <= 0)
  64.                 {
  65.                     speed *= -1;
  66.                 }
  67.                 if (newBlob.position.X > clientBounds.Width)
  68.                 {
  69.                     speed *= -1;
  70.                 }
  71.                 if (newBlob.position.Y > clientBounds.Height)
  72.                 {
  73.                     speed *= -1;
  74.                 }
  75.             }
  76.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement