Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7.  
  8. namespace PacmanGame
  9. {
  10.     class Ghost : Entity
  11.     {
  12.         Random rnd;
  13.         Vector2 dir;
  14.        
  15.  
  16.         public Ghost(Texture2D tex, Vector2 pos, int dirType) : base (tex,pos,new Rectangle(128, 0, 32, 32))
  17.         {
  18.             this.dir = new Vector2(1,0);
  19.             this.prevPos = pos;
  20.  
  21.             if (dirType == 1)
  22.             {
  23.                 this.dir = new Vector2(0, 1);
  24.             }
  25.         }
  26.  
  27.         public virtual void Content()
  28.         {
  29.             fx = SpriteEffects.None;
  30.             scale = 1;
  31.             rnd = new Random();
  32.             //dir = GetDir();
  33.             speed = 0.1f;
  34.             //rec = new Rectangle(128, 0, 32, 32);
  35.            
  36.         }
  37.  
  38.         //public Vector2 GetDir()
  39.         //{
  40.         //    int temp = 0;
  41.         //    while(temp == 0)
  42.         //        temp = rnd.Next(0, 3) - 1;
  43.         //    if (rnd.Next(2) == 0)
  44.         //        return new Vector2(temp, 0);
  45.         //    return new Vector2(0, temp);
  46.  
  47.         //}
  48.  
  49.         public override void Update(GameTime gameTime)
  50.         {
  51.  
  52.             if (Game1.currentGameState == PacmanGame.Game1.GameState.PPGameRun)
  53.                 rec = new Rectangle(128 + 96, 0, 32, 32);
  54.             else
  55.                 rec = new Rectangle(128, 0, 32, 32);
  56.  
  57.             hitbox.X = (int)pos.X-16;
  58.             hitbox.Y = (int)pos.Y-16;
  59.  
  60.             pos += dir * speed;
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement