Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace PacmanGame
- {
- class Ghost : Entity
- {
- Random rnd;
- Vector2 dir;
- public Ghost(Texture2D tex, Vector2 pos, int dirType) : base (tex,pos,new Rectangle(128, 0, 32, 32))
- {
- this.dir = new Vector2(1,0);
- this.prevPos = pos;
- if (dirType == 1)
- {
- this.dir = new Vector2(0, 1);
- }
- }
- public virtual void Content()
- {
- fx = SpriteEffects.None;
- scale = 1;
- rnd = new Random();
- //dir = GetDir();
- speed = 0.1f;
- //rec = new Rectangle(128, 0, 32, 32);
- }
- //public Vector2 GetDir()
- //{
- // int temp = 0;
- // while(temp == 0)
- // temp = rnd.Next(0, 3) - 1;
- // if (rnd.Next(2) == 0)
- // return new Vector2(temp, 0);
- // return new Vector2(0, temp);
- //}
- public override void Update(GameTime gameTime)
- {
- if (Game1.currentGameState == PacmanGame.Game1.GameState.PPGameRun)
- rec = new Rectangle(128 + 96, 0, 32, 32);
- else
- rec = new Rectangle(128, 0, 32, 32);
- hitbox.X = (int)pos.X-16;
- hitbox.Y = (int)pos.Y-16;
- pos += dir * speed;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement