示例#1
0
 public void Update(Pacman pacman)
 {
     if(this.GetNbBonus()==0)
     {
         Pacman.LEVEL++;
         Pacman.NB_LIVES++;
         this.FillMap();
         Game.IN_GAME = false;
         Game.ReplaceElements();
         pacman.Replace();
     }
 }
 private void UpdatePacman(Pacman pacman, Map map)
 {
     this.keyboard = Keyboard.GetState();
     if (pacman.Direction == DIRECTION.UP || pacman.Direction == DIRECTION.DOWN || pacman.Direction == DIRECTION.NONE)
     {
         if (keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.Down))
         {
             pacman.Direction = (keyboard.IsKeyDown(Keys.Up) ? DIRECTION.UP : DIRECTION.DOWN);
             if (!Game.IN_GAME)
                 Game.IN_GAME = true;
         }
         else if (keyboard.IsKeyDown(Keys.Right) || keyboard.IsKeyDown(Keys.Left))
         {
             if (pacman.GetCaseYSup(map.Tile_size) != -1 || pacman.GetCaseYInf(map.Tile_size) != -1)
             {
                 pacman.Direction = (keyboard.IsKeyDown(Keys.Right) ? DIRECTION.RIGHT : DIRECTION.LEFT);
                 if (!Game.IN_GAME)
                     Game.IN_GAME = true;
             }
         }
     }
     if (pacman.Direction == DIRECTION.RIGHT || pacman.Direction == DIRECTION.LEFT || pacman.Direction == DIRECTION.NONE)
     {
         if (keyboard.IsKeyDown(Keys.Right) || keyboard.IsKeyDown(Keys.Left))
         {
             pacman.Direction = (keyboard.IsKeyDown(Keys.Right) ? DIRECTION.RIGHT : DIRECTION.LEFT);
             if (!Game.IN_GAME)
                 Game.IN_GAME = true;
         }
         else if (keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.Down))
         {
             if (pacman.GetCaseXSup(map.Tile_size) != -1 || pacman.GetCaseXInf(map.Tile_size) != -1)
             {
                 pacman.Direction = (keyboard.IsKeyDown(Keys.Up) ? DIRECTION.UP : DIRECTION.DOWN);
                 if (!Game.IN_GAME)
                     Game.IN_GAME = true;
             }
         }
     }
 }
示例#3
0
 private bool CheckCollisionPacmanGhosts(Pacman pacman)
 {
     foreach(Ghost g in Game.GHOSTS)
     {
         if(g.GetAcutalCaseX(map.Tile_size) == pacman.GetAcutalCaseX(map.Tile_size) && g.GetAcutalCaseY(map.Tile_size) == pacman.GetAcutalCaseY(map.Tile_size))
         {
             if(g.Enable)
             {
                 Pacman.NB_LIVES--;
                 Game.IN_GAME = false;
                 Game.ReplaceElements();
                 pacman.Replace();
             }
             else
             {
                 g.GoToBase();
                 pacman.Score += 200;
             }               
         }
     }
     return false;
 }
示例#4
0
 public void Update(Pacman pacman)
 {
     if(!Game.IN_GAME)
     {
         pacman.Replace();
     }
     this.UpdatePacman(pacman);
     this.CheckCollisionPacmanGhosts(pacman);
 }
示例#5
0
 public Collision(Pacman pacman, Map map)
 {
     this.map = map;
 }
示例#6
0
 private void UpdatePacman(Pacman pacman)
 {
     switch (this.map.Grid[pacman.GetAcutalCaseY(map.Tile_size)][pacman.GetAcutalCaseX(map.Tile_size)].Content)
     {
         case CELL_CONTENT.BEAN:
             pacman.Score += 10;
             map.Grid[pacman.GetAcutalCaseY(map.Tile_size)][pacman.GetAcutalCaseX(map.Tile_size)].Content = CELL_CONTENT.EMPTY;
             break;
         case CELL_CONTENT.BIGBEAN:
             pacman.Score += 20;
             map.Grid[pacman.GetAcutalCaseY(map.Tile_size)][pacman.GetAcutalCaseX(map.Tile_size)].Content = CELL_CONTENT.EMPTY;
             break;
         case CELL_CONTENT.PACGUM:
             pacman.Score += 50;
             foreach(Ghost g in Game.GHOSTS)
             {
                 g.Enable = false;
             }
             map.Grid[pacman.GetAcutalCaseY(map.Tile_size)][pacman.GetAcutalCaseX(map.Tile_size)].Content = CELL_CONTENT.EMPTY;
             break;
     }
 }
示例#7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("Arial");

            wall = Content.Load<Texture2D>(@"Sprites\\Background\\wall");
            bean = Content.Load<Texture2D>(@"Sprites\\Background\\bean");
            bigbean = Content.Load<Texture2D>(@"Sprites\\Background\\big_bean");
            pacgum = Content.Load<Texture2D>(@"Sprites\\Background\\pacgum");

            pacman = new Pacman("Pacman", Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_RIGHT"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_DOWN"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_LEFT"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_UP"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_RIGHT_F"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_DOWN_F"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_LEFT_F"));
            pacman.AddTexture(Content.Load<Texture2D>(@"Sprites\\Pacman\\pacman_UP_F"));
            pacman.SetPosition(15*20, 17*20);

            Texture2D g_eat = Content.Load<Texture2D>(@"Sprites\\Ghosts\\ghost_eatable");

            GHOSTS.Add(new Ghost("Ghost 1", Content.Load<Texture2D>(@"Sprites\\Ghosts\\ghost_sky"), 14 * 20, 14 * 20));
            GHOSTS.Add(new Ghost("Ghost 2", Content.Load<Texture2D>(@"Sprites\\Ghosts\\ghost_red"), 14 * 20, 13 * 20));
            GHOSTS.Add(new Ghost("Ghost 3", Content.Load<Texture2D>(@"Sprites\\Ghosts\\ghost_pink"), 13 * 20, 13 * 20));
            GHOSTS.Add(new Ghost("Ghost 4", Content.Load<Texture2D>(@"Sprites\\Ghosts\\ghost_orange"), 13 * 20, 14 * 20));

            foreach(Ghost g in GHOSTS)
            {
                g.AddTexture(g_eat);
            }
        }
 public void Update(Pacman pacman, Map map)
 {
     this.UpdatePacman(pacman, map);
     this.UpdateGhosts();
 }