Advertisement
chibizombie

Projectile

Sep 12th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. class CGruntProjectile : CEntity
  2.     {
  3.         private bool myAlive;
  4.  
  5.         public CGruntProjectile(CGame game, Texture2D texture)
  6.             : base(game, texture)
  7.         {
  8.             myAlive = false;
  9.         }
  10.         public bool Alive
  11.         {
  12.             get
  13.             {
  14.                 return myAlive;
  15.             }
  16.             set
  17.             {
  18.                 myAlive = value;
  19.             }
  20.         }
  21.  
  22.         public void Fire(float x, float y)
  23.         {
  24.             myPosition.X = (x + (myGame.player.Width / 2));
  25.             myPosition.Y = (y + (myGame.player.Height));
  26.             myAlive = true;
  27.         }
  28.  
  29.         public void Tick()
  30.         {
  31.             if (Alive == false)
  32.             {
  33.                 return;
  34.             }
  35.  
  36.             myPosition.Y += 5f;
  37.  
  38.             if (myPosition.Y > myGame.Width)
  39.             {
  40.                 myAlive = false;
  41.                 return;
  42.             }
  43.  
  44.             if (this.CollisionBox.Intersects(myGame.player.CollisionBox))
  45.             {
  46.                 myAlive = false;
  47.                 myGame.player.Death();
  48.             }
  49.         }
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement