示例#1
0
        public GameEngine(Grid dataGrid, Random rand, int tickInterval)
        {
            this.dataGrid = dataGrid;
            this.rand = rand;

            dataGrid.Paint += new PaintEventHandler(dataGrid_Paint);
            pacman = new PacMan();
            ghost = new Ghost[4];
            ghost[0] = new Ghost("Purple");
            ghost[1] = new Ghost("Red");
            ghost[2] = new Ghost("Blue");
            ghost[3] = new Ghost("Green");
            gameOver = false;
        }
示例#2
0
        /// <summary>
        /// Handles a pacman-ghost collision.
        /// </summary>
        /// <param name="ghost"></param>
        public void CheckGhostCollision(Ghost ghost)
        {
            if (location == ghost.Location)
            {
                if (ghost.BehaviourType == GhostMode.Frightened)
                {

                    ghost.BehaviourType = GhostMode.Eaten;
                }
                else if (ghost.BehaviourType == GhostMode.Aggressive)
                {
                    location = new Point(START_LOCATION_X, START_LOCATION_Y);
                    lives--;
                }
            }
        }
示例#3
0
        public static void DrawGhost(Ghost g)
        {
            int x = g._x;
            int y = g._y * 2;

            for (int i = x - 2; i < x + 3; i++)
            {
                for (int j = y - 2; j < y + 4; j++)
                {
                    if (Ghost._ghosts[g._animation][i - x + 2][j - y + 2] == ' ')
                    {
                        continue;
                    }
                    if (g.state == GhostState.Frightened)
                    {
                        if (g._frightenedTimer > g._frightenedDuration - 60 && g._frightenedTimer % 2 == 0)
                        {
                            buf[i * 230 + j].Attributes = (short)g._color;
                        }
                        else
                        {
                            buf[i * 230 + j].Attributes = (short)Colors.LightBlue;
                        }
                    }
                    else if (g.state == GhostState.Eaten)
                    {
                        buf[i * 230 + j].Attributes = (short)Colors.Gray;
                    }
                    else
                    {
                        buf[i * 230 + j].Attributes = (short)g._color;
                    }
                    buf[i * 230 + j].Char.UnicodeChar = Ghost._ghosts[g._animation][i - x + 2][j - y + 2];
                }
            }
        }
示例#4
0
        /// <summary>
        /// Two-parameter constructor to initialize the Scared state. It requires a handle to the Ghost who is scared
        /// as well as the Maze to know which tiles are available.
        /// </summary>
        /// <param name="ghost"></param>
        /// <param name="maze"></param>
        public Scared(Ghost ghost, Maze maze)
        {
            //change direction - make a 180 degree turn
            switch (ghost.Direction)
            {
            case Direction.Up:
                ghost.Direction = Direction.Down;
                break;

            case Direction.Down:
                ghost.Direction = Direction.Up;
                break;

            case Direction.Right:
                ghost.Direction = Direction.Left;
                break;

            case Direction.Left:
                ghost.Direction = Direction.Right;
                break;
            }
            this.ghost = ghost;
            this.maze  = maze;
        }
示例#5
0
        /// <summary>
        /// Static method that returns a mapped gamestate instance by reading a specified file
        /// </summary>
        /// <param name="string">File path of the game file</param>
        /// <returns>GameState instance</returns>
        public static GameState Parse(string fileContent)
        {
            GameState g    = new GameState();
            Maze      maze = new Maze();

            g.maze = maze;
            Pen pen = new Pen();

            g.pen = pen;
            GhostPack gp = new GhostPack();

            g.ghostpack   = gp;
            g.score       = new ScoreAndLives(g);
            g.score.Lives = 3;
            Pacman pac = new Pacman(g);

            g.pacman = pac;

            g.Pacman.Position = new Vector2(11, 17);
            Ghost assistant = null;
            Ghost gh;

            string[][] parse = getElements(fileContent);

            Tile[,] array = new Tile[parse[0].Length, parse.Length];

            for (int y = 0; y < parse.Length; y++)
            {
                for (int x = 0; x < parse[0].Length; x++)
                {
                    switch (parse[y][x])
                    {
                    case "ew":
                        array[x, y] = new Wall(x, y, WallType.EmtpyWall);
                        break;

                    case "w":
                        array[x, y] = new Wall(x, y, WallType.Horizontal);
                        break;

                    case "ww":
                        array[x, y] = new Wall(x, y, WallType.Vertical);
                        break;

                    case "cur":
                        array[x, y] = new Wall(x, y, WallType.CornerUR);
                        break;

                    case "cul":
                        array[x, y] = new Wall(x, y, WallType.CornerUL);
                        break;

                    case "cdr":
                        array[x, y] = new Wall(x, y, WallType.CornerDR);
                        break;

                    case "cdl":
                        array[x, y] = new Wall(x, y, WallType.CornerDL);
                        break;

                    case "cr":
                        array[x, y] = new Wall(x, y, WallType.ClosedR);
                        break;

                    case "cl":
                        array[x, y] = new Wall(x, y, WallType.ClosedL);
                        break;

                    case "cu":
                        array[x, y] = new Wall(x, y, WallType.ClosedU);
                        break;

                    case "cd":
                        array[x, y] = new Wall(x, y, WallType.ClosedD);
                        break;

                    case "tr":
                        array[x, y] = new Wall(x, y, WallType.ConnectorR);
                        break;

                    case "tl":
                        array[x, y] = new Wall(x, y, WallType.ConnectorL);
                        break;

                    case "td":
                        array[x, y] = new Wall(x, y, WallType.ConnectorD);
                        break;

                    case "tu":
                        array[x, y] = new Wall(x, y, WallType.ConnectorU);
                        break;

                    case "p":
                        Pellet p = new Pellet(10);
                        p.Collision += g.score.IncrementScore;
                        array[x, y]  = new Path(x, y, p);
                        break;

                    case "e":
                        Energizer e = new Energizer(g.Ghostpack, 100);
                        e.Collision += g.score.IncrementScore;
                        array[x, y]  = new Path(x, y, e);
                        break;

                    case "m":
                        array[x, y] = new Path(x, y, null);
                        break;

                    case "x":
                        array[x, y] = new PenPath(x, y);
                        g.pen.AddTile(array[x, y]);
                        break;

                    case "P":
                        array[x, y]           = new Path(x, y, null);
                        g.pacman.Position     = new Vector2(x, y);
                        g.pacman.initPosition = new Vector2(x, y);
                        break;

                    case "1":

                        gh                    = new Ghost(g, x, y, GhostState.Chase, new Color(255, 0, 0), GhostName.Blinky);
                        assistant             = gh;
                        pen.Entrance          = new Vector2(x, y);
                        gh.Points             = 200;
                        Ghost.ReleasePosition = new Vector2(x, y);
                        gh.Collision         += g.score.IncrementScore;
                        gh.PacmanDied        += g.score.DeadPacman;
                        g.ghostpack.Add(gh);
                        array[x, y] = new Path(x, y, null);
                        break;

                    case "2":
                        gh             = new Ghost(g, x, y, GhostState.Chase, new Color(255, 192, 203), GhostName.Speedy);
                        gh.Points      = 200;
                        gh.Collision  += g.score.IncrementScore;
                        gh.PacmanDied += g.score.DeadPacman;
                        g.ghostpack.Add(gh);
                        array[x, y] = new Path(x, y, null);
                        g.pen.AddTile(array[x, y]);
                        g.pen.AddToPen(gh);
                        break;

                    case "3":
                        gh = new Ghost(g, x, y, GhostState.Chase, new Color(64, 224, 208), GhostName.Inky);
                        gh.GhostAssistant = assistant;
                        gh.Points         = 200;
                        gh.Collision     += g.score.IncrementScore;
                        gh.PacmanDied    += g.score.DeadPacman;
                        g.ghostpack.Add(gh);
                        array[x, y] = new Path(x, y, null);
                        g.pen.AddTile(array[x, y]);
                        g.pen.AddToPen(gh);
                        break;

                    case "4":
                        gh = new Ghost(g, x, y, GhostState.Chase, new Color(255, 165, 0), GhostName.Clyde);

                        gh.Points      = 200;
                        gh.Collision  += g.score.IncrementScore;
                        gh.PacmanDied += g.score.DeadPacman;
                        g.ghostpack.Add(gh);
                        array[x, y] = new Path(x, y, null);
                        g.pen.AddTile(array[x, y]);
                        g.pen.AddToPen(gh);
                        break;
                    }
                }
            }
            g.maze.SetTiles(array);

            //sets home positions for scatter mode
            foreach (Ghost ghost in g.ghostpack)
            {
                switch (ghost.Name)
                {
                case GhostName.Blinky:
                    ghost.HomePosition = new Vector2(g.maze.Length - 2, 1);
                    break;

                case GhostName.Speedy:
                    ghost.HomePosition = new Vector2(1, 1);
                    break;

                case GhostName.Inky:
                    ghost.HomePosition = new Vector2(g.maze.Length - 2, g.maze.Height - 2);
                    break;

                case GhostName.Clyde:
                    ghost.HomePosition = new Vector2(1, g.maze.Height - 2);
                    break;
                }
            }
            g.maze.PacmanWon += g.Score.IncrementScore;
            g.pacman.SubToGhosts();
            g.Score.Pause += g.Ghostpack.Pause;
            g.Score.Pause += g.Pen.Pause;
            return(g);
        }
示例#6
0
        public override void Update(UpdateEventArgs e)
        {
            base.Update(e);

            // Collide with pickup objects
            var pickupObject = this.Level.GetPickupObject(this.GetGridPos());

            if (pickupObject != null)
            {
                if (pickupObject.Type == Level.ORB)
                {
                    if (pickupObject.Remove())
                    {
                        this.Level.Graphics.Audio.PlayOmnomnom();
                        this.Score += this.Level.Score(pickupObject.Type);
                        if (this.Level.PickupObjects.Count <= 5)
                        {
                            this.Level.CheckWinCondition();
                        }
                    }
                }
                else if (pickupObject.Type == Level.SUPERORB)
                {
                    if (pickupObject.Remove())
                    {
                        this.Level.Graphics.Audio.PlayOmnomnom();
                        this.Score += this.Level.Score(pickupObject.Type);
                        foreach (Ghost ghost in this.Level.Ghosts)
                        {
                            if (ghost != null)
                            {
                                ghost.VulnerabilityStart();
                            }
                        }
                    }
                }
            }

            // Collide with ghosts
            Ghost killer = null;

            foreach (Ghost ghost in this.Level.Ghosts)
            {
                if (ghost != null)
                {
                    if (this.Collides(ghost))
                    {
                        if (ghost.State == Ghost.States.Vulnerable)
                        {
                            this.Score += this.Level.Score(Level.GHOSTSPAWN);
                            ghost.Die();
                        }
                        else if (ghost.State == Ghost.States.Alive)
                        {
                            killer = ghost; // Don't die twice (can't use break, as other colliding ghosts might be vulnerable).
                        }
                    }
                }
            }
            if (killer != null)
            {
                this.Die(killer);
            }
        }
示例#7
0
        public void Update(Pacboi pacman, Ghost blinky, Board board)
        {
            counter++;
            animateCounter++;
            x += velocity.X;
            y += velocity.Y;
            if (x + rect.Width < 0)
            {
                x += board.screenSize.Width;
            }
            if (x > board.screenSize.Width)
            {
                x -= board.screenSize.Width;
            }
            rect.X = (int)x;
            rect.Y = (int)y;
            //centerRect.X = (int)x;
            //centerRect.Y = (int)y;
            //if (scatter)
            //{
            //    CheckScatter();
            //}
            //else
            if (counter == 6)
            {
                counter = 0;
                if (scatter)
                {
                    UpdateDirection(board);
                }
                else
                {
                    UpdateTarget(pacman, blinky, board);
                }
            }

            sourceRect.X = 4;
            if (animateCounter < 8)
            {
                //First one
            }
            else
            {
                //second one
                sourceRect.X += 16;
            }
            if (dir == Direction.Left)
            {
                sourceRect.X += 32;
            }
            if (dir == Direction.Up)
            {
                sourceRect.X += 64;
            }
            if (dir == Direction.Down)
            {
                sourceRect.X += 96;
            }
            if (animateCounter == 16)
            {
                animateCounter = 0;
            }
        }
示例#8
0
 public bool Collides(Ghost ghost)
 {
     return((ghost.Position - this.Position).LengthSquared < SIZE * SIZE);
 }
示例#9
0
        // This is where movement animation is controlled
        // Handle all collision stuff here
        public void PMmovementTimer_Tick(object sender, EventArgs e)
        {
            List <int> openDirections;
            bool       moved = false;

            Ghost     PM        = this;
            GameBoard gameBoard = mainWindow.GB;

            // Variables to hold current Row/Col square of Ghost
            // Keep in mind everything is based on top left of Ghost square.. this can be problematic in trying to determine what square he is mostly in.. would rather have the center
            // So with that in mind we'll need to make sure Ghost stays on the 'rails' based on Width/2 (the center of Ghost).. but we also don't want to make the game extremely hard,
            // so put in ranges and then reset the rails
            // Rails: - Note: looking at the center of Ghost
            // Rows:    21, 63, 105, 147, 189, 231, 273, 315, 357, 399, 441, 483, 525
            // Columns: 21, 63, 105, 147, 189, 231, 273, 315, 357, 399, 441, 483, 525, 567, 609, 651, 693, 735, 777, 819, 861, 903, 945, 987, 1029, 1071, 1113
            int pmNextRow = 0;
            int pmNextCol = 0;

            //////////////////////////////////////////
            // UP
            if (PM.Direction == 0)
            {
                // Trying to move up
                pmNextRow = (int)((Canvas.GetTop(PM) - PM.Speed) / PM.ActualHeight);
                pmNextCol = (int)((Canvas.GetLeft(PM) + PM.ActualWidth / 2) / PM.ActualWidth);      // Use Ghost midpoint to see what column they are trying to use

                if ((gamePath[pmNextRow, pmNextCol] == 1 || gamePath[pmNextRow, pmNextCol] == 2) && // Make sure the next square is movable
                    Canvas.GetLeft(PM) > ((pmNextCol * PM.ActualWidth) - PMMovementWindow) &&       // Make sure we're pretty close to the path, will adjust during move
                    Canvas.GetLeft(PM) < ((pmNextCol * PM.ActualWidth) + PMMovementWindow))
                {
                    Canvas.SetTop(PM, Canvas.GetTop(PM) - PM.Speed);
                    Canvas.SetLeft(PM, pmNextCol * PM.ActualHeight);
                    moved = true;
                }
            }
            //////////////////////////////////////////
            // Down
            else if (PM.Direction == 1)
            {
                pmNextRow = (int)((Canvas.GetTop(PM) + PM.Speed + PM.ActualHeight) / PM.ActualHeight);
                pmNextCol = (int)((Canvas.GetLeft(PM) + PM.ActualWidth / 2) / PM.ActualWidth);

                if ((gamePath[pmNextRow, pmNextCol] == 1 || gamePath[pmNextRow, pmNextCol] == 2) && // Make sure the next square is movable
                    Canvas.GetLeft(PM) > ((pmNextCol * PM.ActualWidth) - PMMovementWindow) &&      // Make sure we're pretty close to the path, will adjust during move
                    Canvas.GetLeft(PM) < ((pmNextCol * PM.ActualWidth) + PMMovementWindow))
                {
                    Canvas.SetTop(PM, Canvas.GetTop(PM) + PM.Speed);
                    moved = true;
                }
            }
            //////////////////////////////////////////
            // Left
            else if (PM.Direction == 2)
            {
                pmNextRow = (int)((Canvas.GetTop(PM) + PM.ActualWidth / 2) / PM.ActualHeight);  // Use midpoint to see what row we are trying to be in
                pmNextCol = (int)((Canvas.GetLeft(PM) - PM.Speed) / PM.ActualHeight);

                // Check to see if pmNextCol is -1.. if it is teleport Ghost to the right side of the board!
                if (pmNextCol == -1)
                {
                    Canvas.SetLeft(PM, gameBoard.ActualWidth - PM.ActualWidth - 1);
                    moved = true;
                }
                else
                if ((gamePath[pmNextRow, pmNextCol] == 1 || gamePath[pmNextRow, pmNextCol] == 2) && // Make sure the next square is movable
                    Canvas.GetTop(PM) > ((pmNextRow * PM.ActualHeight) - PMMovementWindow) &&     // Make sure we're pretty close to the path, will adjust during move
                    Canvas.GetTop(PM) < ((pmNextRow * PM.ActualHeight) + PMMovementWindow))
                {
                    Canvas.SetLeft(PM, Canvas.GetLeft(PM) - PM.Speed);
                    moved = true;
                }
            }
            //////////////////////////////////////////
            // Right
            else if (PM.Direction == 3)
            {
                pmNextRow = (int)((Canvas.GetTop(PM) + PM.ActualWidth / 2) / PM.ActualHeight);  // Use midpoint to see what row we are trying to be in
                pmNextCol = (int)((Canvas.GetLeft(PM) + PM.Speed + PM.ActualWidth) / PM.ActualHeight);

                // Check to see if NextCol is 27.. if it is teleport Ghost to the left side of the board!
                if (pmNextCol == 27)
                {
                    Canvas.SetLeft(PM, 0);
                    moved = true;
                }
                else
                if ((gamePath[pmNextRow, pmNextCol] == 1 || gamePath[pmNextRow, pmNextCol] == 2) && // Make sure the next square is movable
                    Canvas.GetTop(PM) > ((pmNextRow * PM.ActualHeight) - PMMovementWindow) &&      // Make sure we're pretty close to the path, will adjust during move
                    Canvas.GetTop(PM) < ((pmNextRow * PM.ActualHeight) + PMMovementWindow))
                {
                    Canvas.SetLeft(PM, Canvas.GetLeft(PM) + PM.Speed);
                    moved = true;
                }
            }

            int currentRow = (int)((Canvas.GetTop(PM) + PM.ActualHeight / 2) / PM.ActualHeight);
            int currentCol = (int)((Canvas.GetLeft(PM) + PM.ActualWidth / 2) / PM.ActualWidth);

            positionTracker.putGhostPosition(GetHashCode(), new int[] { currentRow, currentCol });

            openDirections = GetOpenDirections(currentRow, currentCol);

            GoToOpenDirection(openDirections, moved);
        }
示例#10
0
 protected virtual void UpdateTarget(Pacboi pacman, Ghost blinky, Board board)
 {
 }
示例#11
0
        private void GameLogic(Graphics g)
        {
            if (totalGhosts < maxGhosts)
            {
                //respawn
                Ghost ghost = new Ghost(backLayer.TileObject[spawningPlace.X, spawningPlace.Y].Sprite.Location.X, backLayer.TileObject[spawningPlace.X, spawningPlace.Y].Sprite.Location.Y);
                ghost.TileLocation = new Point(spawningPlace.X, spawningPlace.Y);
                ghost.Speed        = ghostSpeed;

                //add ghosts to game objects
                GameObjects.Add(ghost);
                totalGhosts++;
            }

            for (int i = 0; i < GameObjects.Count; i++)
            {
                //collision
                if (pacMan.IsCollidingWith(GameObjects[i]))
                {
                    //with ball
                    if (GameObjects[i].GetType() == typeof(Ball))
                    {
                        //remove ball
                        Ball ball = (Ball)GameObjects[i];
                        ball.UnDraw(g);
                        GameObjects.Remove(ball);
                        foodLayer.Remove(ball.TileLocation.X, ball.TileLocation.Y);

                        if (ball.Type == Ball.BallType.Power)
                        {
                            pacMan.HasPower = true;
                        }
                        totalBalls--;

                        i--;

                        //increment score
                        totalScore += scoreIncrementRegular;

                        continue;
                    }//if

                    //with ghost
                    if (GameObjects[i].GetType() == typeof(Ghost))
                    {
                        if (pacMan.HasPower == true)
                        {
                            //remove ghost
                            Ghost ghost = (Ghost)GameObjects[i];
                            ghost.UnDraw(g);
                            GameObjects.Remove(ghost);
                            totalGhosts--;
                            i--;

                            //increment score
                            totalScore += scoreIncrementGhost;

                            continue;
                        }
                        else
                        {
                            //game over
                            this.isRunning  = false;
                            this.isGameOver = true;
                            this.isGameWon  = false;
                        } //if
                    }     //if
                }         //if
            }             //for

            if (totalBalls == 0)
            {
                this.isRunning  = false;
                this.isGameOver = true;
                this.isGameWon  = true;
            }
        }
示例#12
0
        public void SetLevel(Level level)
        {
            currentLevel     = level;
            hud.CurrentLevel = level;


            int oldScore = 0;

            if (pacman != null)
            {
                oldScore = pacman.Score;
            }

            SpriteSheet pacmanSheet = new SpriteSheet(characterSheet.Texture, Vector2.Zero, new Vector2(80, 16), new Vector2(16, 16));

            pacman       = new Pacman(pacmanSheet, level, 5);
            pacman.Score = oldScore;

            Tile pacmanSpawnTile = level.GetTile(1, 1);

            if (level.PacmanSpawn != null)
            {
                pacmanSpawnTile = level.PacmanSpawn;
            }

            pacman.Position = pacmanSpawnTile.Position + new Vector2(level.TileSize / 2);

            hud.Pacman         = pacman;
            this.levelPosition = new Vector2((window.ClientBounds.Width / 2) - (level.PixelWidth / 2), (window.ClientBounds.Height / 2) - (level.PixelHeight / 2));



            ghosts.Clear();
            int ghostBehaviourIndex = 0;

            foreach (Tile spawn in level.GhostSpawns)
            {
                SpriteSheet redGhostSheet    = new SpriteSheet(characterSheet.Texture, new Vector2(0, 16), new Vector2(128, 16), new Vector2(16, 16));
                SpriteSheet pinkGhostSheet   = new SpriteSheet(characterSheet.Texture, new Vector2(0, 32), new Vector2(128, 16), new Vector2(16, 16));
                SpriteSheet blueGhostSheet   = new SpriteSheet(characterSheet.Texture, new Vector2(0, 48), new Vector2(128, 16), new Vector2(16, 16));
                SpriteSheet orangeGhostSheet = new SpriteSheet(characterSheet.Texture, new Vector2(0, 64), new Vector2(128, 16), new Vector2(16, 16));
                SpriteSheet runGhostSheet    = new SpriteSheet(characterSheet.Texture, new Vector2(0, 80), new Vector2(64, 16), new Vector2(16, 16));

                GhostBehaviour behaviour        = null;
                SpriteSheet    ghostSpritesheet = null;
                switch (ghostBehaviourIndex)
                {
                case 0:
                    behaviour        = new GhostPatrolling(pacman, level);
                    ghostSpritesheet = blueGhostSheet;
                    break;

                case 1:
                    behaviour        = new GhostPathfinding(pacman, level);
                    ghostSpritesheet = orangeGhostSheet;
                    break;

                default:
                    behaviour        = new GhostFullyRandom(pacman, level);
                    ghostSpritesheet = redGhostSheet;
                    break;
                }

                Ghost ghost = new Ghost(ghostSpritesheet, runGhostSheet, level, pacman, behaviour);
                ghost.Position = spawn.Position + new Vector2(level.TileSize / 2);
                ghosts.Add(ghost);
                ghostBehaviourIndex++;
                ghostBehaviourIndex %= 3;
            }
        }
示例#13
0
        /// <summary>
        /// Effectively moves the Pac Man according to member variable Direction.
        /// </summary>
        void DoMove()
        {
            // Everytime the updateCount == updatesPerPixel, move one pixel in
            // the desired direction and reset the updateCount.
            mUpdateCount++;
            mUpdateCount %= mUpdatesPerPixel;
            if (mUpdateCount == 0)
            {
                // Now is a nice time to update our speed, like we do for the ghosts.
                if (Ghost.NextTile(Direction, Position).HasCrump)
                {
                    mUpdatesPerPixel = Constants.PacManSpeed() + 2;
                }
                else
                {
                    mUpdatesPerPixel = Constants.PacManSpeed();
                }

                // Move one pixel in the desired direction
                if (Direction == EDirection.Up)
                {
                    Position.DeltaPixel.Y--;
                }
                else if (Direction == EDirection.Down)
                {
                    Position.DeltaPixel.Y++;
                }
                else if (Direction == EDirection.Left)
                {
                    Position.DeltaPixel.X--;
                }
                else if (Direction == EDirection.Right)
                {
                    Position.DeltaPixel.X++;
                }

                // By moving one pixel we might have moved to another tile completely
                if (Position.DeltaPixel.X == 16)
                {
                    // Special case : the tunnel
                    if (Position.Tile.X == 27)
                    {
                        Position.Tile.X = 0;
                    }
                    else
                    {
                        Position.Tile.X++;
                    }
                    Position.DeltaPixel.X = 0;
                }
                else if (Position.DeltaPixel.X == -16)
                {
                    // Special case : the tunnel
                    if (Position.Tile.X == 0)
                    {
                        Position.Tile.X = 27;
                    }
                    else
                    {
                        Position.Tile.X--;
                    }
                    Position.DeltaPixel.X = 0;
                }
                else if (Position.DeltaPixel.Y == 16)
                {
                    Position.Tile.Y++;
                    Position.DeltaPixel.Y = 0;
                }
                else if (Position.DeltaPixel.Y == -16)
                {
                    Position.Tile.Y--;
                    Position.DeltaPixel.Y = 0;
                }
            }
        }
示例#14
0
 /// <summary>
 /// In case this ghost is Inky, he will need a reference to blinky in order
 /// to find his way around the maze. Otherwise, setting this has no effect.
 /// </summary>
 /// <param name="blinky">A reference to Blinky.</param>
 public void SetBlinky(Ghost blinky)
 {
     blinky_ = blinky;
 }
示例#15
0
        private Vector2 target; //used to chase that target
        //private Pacman pacman; Not used.

        /// <summary>
        /// Constructor instantiates the ghost, maze, target and pacman.
        /// </summary>
        public Zombie(Ghost ghost, Maze maze, Vector2 target)
        {
            this.ghost  = ghost;
            this.maze   = maze;
            this.target = target;
        }
示例#16
0
        public LobbyScreen(ScreenManager sM, BackgroundLevel bgLevel = null, MultiPlayerInfo mpInfo = null)
            : base(sM)
        {
            // Some settings
            if (bgLevel == null)
            {
                this.bgLevel = new BackgroundLevel(this.screenManager);
            }
            else
            {
                this.bgLevel = bgLevel;
            }
            this.errorMessages   = "";
            this.multiplayerInfo = mpInfo;
            this.MenuSize        = this.screenManager.ScreenResolution - 150 * Vector2.UnitX;
            this.NrOfColumns     = 2;
            this.PositionMenuScreen(MenuItem.HorizontalAlign.Center, MenuItem.VerticalAlign.Top);
            this.FavMenuItem.TextAlign          = MenuItem.HorizontalAlign.Left;
            this.HorizontalAndVerticalArrowKeys = true;

            // Start and back buttons
            MenuItem miStart = new MenuItem("Start", sM.Graphics);

            if (!this.MultiPlayer || this.multiplayerInfo.IsHost())
            {
                miStart.OnClick += (o, e) => { this.Start(); }
            }
            ;
            this.AddMenuItem(miStart);
            this.miBack          = new MenuItem("Back", sM.Graphics);
            this.miBack.OnClick += (o, e) => { this.Remove(); };
            this.AddMenuItem(this.miBack, 1);

            // The player dropdowns
            List <string> options = new List <string>()
            {
                Settings.Get.Name, "Stupid", "Normal", "Euclidian", NONE
            };

            this.miPacMan   = new MenuItemList("PacMan", new List <string>(options), sM.Graphics);
            this.miMsPacMan = new MenuItemList("Ms PacMan", new List <string>(options), sM.Graphics);
            this.miGhosts   = new MenuItemList[4];
            for (int i = 0; i < this.miGhosts.Length; i++)
            {
                this.miGhosts[i] = new MenuItemList(Ghost.GetName(i), new List <string>(options), sM.Graphics);
            }
            if (this.MultiPlayer)
            {
                this.managePlayersMP();
            }
            this.finishCreatingMenus();

            // The maps
            MenuItem[] miMaps = new MenuItem[6];
            for (int i = 0; i < miMaps.Length; i++)
            {
                miMaps[i]          = new MenuItem("Map " + i.ToString(), sM.Graphics);
                miMaps[i].OnClick += generateSetMap(i);
                this.AddMenuItem(miMaps[i], 1);
            }

            // Colour the menus (and position them)
            this.FastLayout(this.FavMenuItem);
            miBack.TextAlign = MenuItem.HorizontalAlign.Right;

            // Set the PacMan and ghost colours
            this.miPacMan.SelectedColour    = Color.Yellow;
            this.miMsPacMan.SelectedColour  = Color.Yellow;
            this.miGhosts[0].SelectedColour = Color.Red;
            this.miGhosts[1].SelectedColour = Color.DeepPink;
            this.miGhosts[2].SelectedColour = Color.Cyan;
            this.miGhosts[3].SelectedColour = Color.Orange;

            // Position the menus (override previous positioning)
            this.positionMenuItems(miStart, miMaps);

            // Load the values
            this.Load();

            // Subscribe to the multiplayer info events
            if (this.MultiPlayer)
            {
                this.multiplayerInfo.OnRefresh += (o, e) => { this.managePlayersMP(); }
            }
            ;
        }
示例#17
0
文件: Play.cs 项目: SiTox/07-SK-K-PM
 public bool EnemyPlayerCollision(Ghost enemy)
 {
     if ((enemy.X == Player.X) && (enemy.Y == Player.Y))
         return true;
     else
     {
         //Horizontal - enemy on left
         if ((enemy.X + 1 == Player.X) &&
             (enemy.Y == Player.Y) &&
             (enemy.D == Direction.Left) &&
             (Player.D == Direction.Right)) return true;
         //Horizontal - enemy on right
         else if ((enemy.X - 1 == Player.X) &&
             (enemy.Y == Player.Y) &&
             (enemy.D == Direction.Right) &&
             (Player.D == Direction.Left)) return true;
         //Vertical - enemy up
         else if ((enemy.Y + 1 == Player.Y) &&
             (enemy.X == Player.X) &&
             (enemy.D == Direction.Up) &&
             (Player.D == Direction.Down)) return true;
         //Vertical - enemy down
         else if ((enemy.Y - 1 == Player.Y) &&
             (enemy.X == Player.X) &&
             (enemy.D == Direction.Down) &&
             (Player.D == Direction.Up)) return true;
         else return false;
     }
 }
示例#18
0
 /// <summary>
 /// Constructor instantiates the ghost, maze, target and pacman.
 /// </summary>
 public Scatter(Ghost ghost, Maze maze, Vector2 target)
 {
     this.ghost  = ghost;
     this.maze   = maze;
     this.target = target;
 }
示例#19
0
文件: Play.cs 项目: SiTox/07-SK-K-PM
        public void LoadObjects()
        {
            Player = new PacMan(Map.StartPoint);
            Player.D = Map.StartDirection;

            Enemies.Clear();
            for (int n = 0; n < Map.Enemies.Count; n++)
            {
                Ghost en = new Ghost(Map.Enemies[n], false);
                en.Color = ConsoleColor.White;
                if (n % 2 != 0) en.White = true;
                Enemies.Add(en);
            }
        }
示例#20
0
文件: AI.cs 项目: Mattias1/pacman
 public bool CanGhostSeePacMan(Ghost ghost, float factor = 1f)
 {
     return((ghost.Position - this.PacMan.Position).LengthSquared < Ghost.SEEINGRANGE * factor * Ghost.SEEINGRANGE * factor);
 }
示例#21
0
        public void CreateGameField()
        {
            //game engine variables
            isRunning  = true;
            isGameOver = false;
            isPaused   = false;
            isGameWon  = false;

            //score tracking
            totalBalls = 0;
            totalScore = 0;

            backLayer = new TiledLayer(gameFieldWidth, gameFieldHeight, tileSize);

            //create background
            backLayer.Add(new Wall(Wall.WallType.TopLeft), true, 0, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 1, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 2, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 3, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 4, 1);
            backLayer.Add(new Wall(Wall.WallType.TopJunction), true, 5, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 6, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 7, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 8, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 9, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 10, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 11, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 12, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 13, 1);
            backLayer.Add(new Wall(Wall.WallType.TopJunction), true, 14, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 15, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 16, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 17, 1);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 18, 1);
            backLayer.Add(new Wall(Wall.WallType.TopRight), true, 19, 1);

            backLayer.Add(new Wall(Wall.WallType.Left), true, 0, 2);
            backLayer.Add(new Path(), false, 1, 2);
            backLayer.Add(new Path(), false, 2, 2);
            backLayer.Add(new Path(), false, 3, 2);
            backLayer.Add(new Path(), false, 4, 2);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 5, 2);
            backLayer.Add(new Path(), false, 6, 2);
            backLayer.Add(new Path(), false, 7, 2);
            backLayer.Add(new Path(), false, 8, 2);
            backLayer.Add(new Path(), false, 9, 2);
            backLayer.Add(new Path(), false, 10, 2);
            backLayer.Add(new Path(), false, 11, 2);
            backLayer.Add(new Path(), false, 12, 2);
            backLayer.Add(new Path(), false, 13, 2);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 14, 2);
            backLayer.Add(new Path(), false, 15, 2);
            backLayer.Add(new Path(), false, 16, 2);
            backLayer.Add(new Path(), false, 17, 2);
            backLayer.Add(new Path(), false, 18, 2);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 2);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 3);
            backLayer.Add(new Path(), false, 1, 3);
            backLayer.Add(new Wall(Wall.WallType.TopLeft), true, 2, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 3, 3);
            backLayer.Add(new Path(), false, 4, 3);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 5, 3);
            backLayer.Add(new Path(), false, 6, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 7, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 8, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 9, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 10, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 11, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 12, 3);
            backLayer.Add(new Path(), false, 13, 3);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 14, 3);
            backLayer.Add(new Path(), false, 15, 3);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 16, 3);
            backLayer.Add(new Wall(Wall.WallType.TopRight), true, 17, 3);
            backLayer.Add(new Path(), false, 18, 3);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 3);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 4);
            backLayer.Add(new Path(), false, 1, 4);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 2, 4);
            backLayer.Add(new Path(), false, 3, 4);
            backLayer.Add(new Path(), false, 4, 4);
            backLayer.Add(new Path(), false, 5, 4);
            backLayer.Add(new Path(), false, 6, 4);
            backLayer.Add(new Path(), false, 7, 4);
            backLayer.Add(new Path(), false, 8, 4);
            backLayer.Add(new Path(), false, 9, 4);
            backLayer.Add(new Path(), false, 10, 4);
            backLayer.Add(new Path(), false, 11, 4);
            backLayer.Add(new Path(), false, 12, 4);
            backLayer.Add(new Path(), false, 13, 4);
            backLayer.Add(new Path(), false, 14, 4);
            backLayer.Add(new Path(), false, 15, 4);
            backLayer.Add(new Path(), false, 16, 4);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 17, 4);
            backLayer.Add(new Path(), false, 18, 4);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 4);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 5);
            backLayer.Add(new Path(), false, 1, 5);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 2, 5);
            backLayer.Add(new Path(), false, 3, 5);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 4, 5);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 5, 5);
            backLayer.Add(new Path(), false, 6, 5);
            backLayer.Add(new Wall(Wall.WallType.TopLeft), true, 7, 5);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 8, 5);
            backLayer.Add(new Path(), false, 9, 5);
            backLayer.Add(new Path(), false, 10, 5);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 11, 5);
            backLayer.Add(new Wall(Wall.WallType.TopRight), true, 12, 5);
            backLayer.Add(new Path(), false, 13, 5);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 14, 5);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 15, 5);
            backLayer.Add(new Path(), false, 16, 5);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 17, 5);
            backLayer.Add(new Path(), false, 18, 5);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 5);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 6);
            backLayer.Add(new Path(), false, 1, 6);
            backLayer.Add(new Path(), false, 2, 6);
            backLayer.Add(new Path(), false, 3, 6);
            backLayer.Add(new Path(), false, 4, 6);
            backLayer.Add(new Path(), false, 5, 6);
            backLayer.Add(new Path(), false, 6, 6);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 7, 6);
            backLayer.Add(new Path(), false, 8, 6);
            backLayer.Add(new Path(), false, 9, 6);
            backLayer.Add(new Path(), false, 10, 6);
            backLayer.Add(new Path(), false, 11, 6);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 12, 6);
            backLayer.Add(new Path(), false, 13, 6);
            backLayer.Add(new Path(), false, 14, 6);
            backLayer.Add(new Path(), false, 15, 6);
            backLayer.Add(new Path(), false, 16, 6);
            backLayer.Add(new Path(), false, 17, 6);
            backLayer.Add(new Path(), false, 18, 6);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 6);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 7);
            backLayer.Add(new Path(), false, 1, 7);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 2, 7);
            backLayer.Add(new Path(), false, 3, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 4, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 5, 7);
            backLayer.Add(new Path(), false, 6, 7);
            backLayer.Add(new Wall(Wall.WallType.BottomLeft), true, 7, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 8, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 9, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 10, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 11, 7);
            backLayer.Add(new Wall(Wall.WallType.BottomRight), true, 12, 7);
            backLayer.Add(new Path(), false, 13, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 14, 7);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 15, 7);
            backLayer.Add(new Path(), false, 16, 7);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 17, 7);
            backLayer.Add(new Path(), false, 18, 7);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 7);


            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 8);
            backLayer.Add(new Path(), false, 1, 8);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 2, 8);
            backLayer.Add(new Path(), false, 3, 8);
            backLayer.Add(new Path(), false, 4, 8);
            backLayer.Add(new Path(), false, 5, 8);
            backLayer.Add(new Path(), false, 6, 8);
            backLayer.Add(new Path(), false, 7, 8);
            backLayer.Add(new Path(), false, 8, 8);
            backLayer.Add(new Path(), false, 9, 8);
            backLayer.Add(new Path(), false, 10, 8);
            backLayer.Add(new Path(), false, 11, 8);
            backLayer.Add(new Path(), false, 12, 8);
            backLayer.Add(new Path(), false, 13, 8);
            backLayer.Add(new Path(), false, 14, 8);
            backLayer.Add(new Path(), false, 15, 8);
            backLayer.Add(new Path(), false, 16, 8);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 17, 8);
            backLayer.Add(new Path(), false, 18, 8);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 8);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 9);
            backLayer.Add(new Path(), false, 1, 9);
            backLayer.Add(new Wall(Wall.WallType.BottomLeft), true, 2, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 3, 9);
            backLayer.Add(new Path(), false, 4, 9);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 5, 9);
            backLayer.Add(new Path(), false, 6, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 7, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 8, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 9, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 10, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 11, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 12, 9);
            backLayer.Add(new Path(), false, 13, 9);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 14, 9);
            backLayer.Add(new Path(), false, 15, 9);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 16, 9);
            backLayer.Add(new Wall(Wall.WallType.BottomRight), true, 17, 9);
            backLayer.Add(new Path(), false, 18, 9);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 9);

            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 0, 10);
            backLayer.Add(new Path(), false, 1, 10);
            backLayer.Add(new Path(), false, 2, 10);
            backLayer.Add(new Path(), false, 3, 10);
            backLayer.Add(new Path(), false, 4, 10);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 5, 10);
            backLayer.Add(new Path(), false, 6, 10);
            backLayer.Add(new Path(), false, 7, 10);
            backLayer.Add(new Path(), false, 8, 10);
            backLayer.Add(new Path(), false, 9, 10);
            backLayer.Add(new Path(), false, 10, 10);
            backLayer.Add(new Path(), false, 11, 10);
            backLayer.Add(new Path(), false, 12, 10);
            backLayer.Add(new Path(), false, 13, 10);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 14, 10);
            backLayer.Add(new Path(), false, 15, 10);
            backLayer.Add(new Path(), false, 16, 10);
            backLayer.Add(new Path(), false, 17, 10);
            backLayer.Add(new Path(), false, 18, 10);
            backLayer.Add(new Wall(Wall.WallType.Vertical), true, 19, 10);

            backLayer.Add(new Wall(Wall.WallType.BottomLeft), true, 0, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 1, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 2, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 3, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 4, 11);
            backLayer.Add(new Wall(Wall.WallType.BottomJunction), true, 5, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 6, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 7, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 8, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 9, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 10, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 11, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 12, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 13, 11);
            backLayer.Add(new Wall(Wall.WallType.BottomJunction), true, 14, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 15, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 16, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 17, 11);
            backLayer.Add(new Wall(Wall.WallType.Horizontal), true, 18, 11);
            backLayer.Add(new Wall(Wall.WallType.BottomRight), true, 19, 11);


            //food layer
            foodLayer = new TiledLayer(gameFieldWidth, gameFieldHeight, tileSize);
            foodLayer.Add(new Ball(), false, 1, 2);
            foodLayer.Add(new Ball(), false, 2, 2);
            foodLayer.Add(new Ball(), false, 3, 2);
            foodLayer.Add(new Ball(), false, 4, 2);
            foodLayer.Add(new Ball(), false, 6, 2);
            foodLayer.Add(new Ball(), false, 7, 2);
            foodLayer.Add(new Ball(), false, 8, 2);
            foodLayer.Add(new Ball(), false, 9, 2);
            foodLayer.Add(new Ball(), false, 10, 2);
            foodLayer.Add(new Ball(), false, 11, 2);
            foodLayer.Add(new Ball(), false, 12, 2);
            foodLayer.Add(new Ball(), false, 13, 2);
            foodLayer.Add(new Ball(), false, 15, 2);
            foodLayer.Add(new Ball(), false, 16, 2);
            foodLayer.Add(new Ball(), false, 17, 2);
            foodLayer.Add(new Ball(Ball.BallType.Power), false, 18, 2);

            foodLayer.Add(new Ball(), false, 1, 3);
            foodLayer.Add(new Ball(), false, 4, 3);
            foodLayer.Add(new Ball(), false, 6, 3);
            foodLayer.Add(new Ball(), false, 13, 3);
            foodLayer.Add(new Ball(), false, 15, 3);
            foodLayer.Add(new Ball(), false, 18, 3);

            foodLayer.Add(new Ball(), false, 1, 4);
            foodLayer.Add(new Ball(), false, 3, 4);
            foodLayer.Add(new Ball(), false, 4, 4);
            foodLayer.Add(new Ball(), false, 5, 4);
            foodLayer.Add(new Ball(), false, 6, 4);
            foodLayer.Add(new Ball(), false, 7, 4);
            foodLayer.Add(new Ball(), false, 8, 4);
            foodLayer.Add(new Ball(), false, 9, 4);
            foodLayer.Add(new Ball(), false, 10, 4);
            foodLayer.Add(new Ball(), false, 11, 4);
            foodLayer.Add(new Ball(), false, 12, 4);
            foodLayer.Add(new Ball(), false, 13, 4);
            foodLayer.Add(new Ball(), false, 14, 4);
            foodLayer.Add(new Ball(), false, 15, 4);
            foodLayer.Add(new Ball(), false, 16, 4);
            foodLayer.Add(new Ball(), false, 18, 4);

            foodLayer.Add(new Ball(), false, 1, 5);
            foodLayer.Add(new Ball(), false, 3, 5);
            foodLayer.Add(new Ball(), false, 6, 5);
            foodLayer.Add(new Ball(), false, 13, 5);
            foodLayer.Add(new Ball(), false, 16, 5);
            foodLayer.Add(new Ball(), false, 18, 5);

            foodLayer.Add(new Ball(), false, 1, 6);
            foodLayer.Add(new Ball(), false, 2, 6);
            foodLayer.Add(new Ball(), false, 3, 6);
            foodLayer.Add(new Ball(), false, 4, 6);
            foodLayer.Add(new Ball(), false, 5, 6);
            foodLayer.Add(new Ball(), false, 6, 6);
            foodLayer.Add(new Ball(), false, 13, 6);
            foodLayer.Add(new Ball(), false, 14, 6);
            foodLayer.Add(new Ball(), false, 15, 6);
            foodLayer.Add(new Ball(), false, 16, 6);
            foodLayer.Add(new Ball(), false, 17, 6);
            foodLayer.Add(new Ball(), false, 18, 6);

            foodLayer.Add(new Ball(), false, 1, 7);
            foodLayer.Add(new Ball(), false, 3, 7);
            foodLayer.Add(new Ball(), false, 6, 7);
            foodLayer.Add(new Ball(), false, 13, 7);
            foodLayer.Add(new Ball(), false, 16, 7);
            foodLayer.Add(new Ball(), false, 18, 7);

            foodLayer.Add(new Ball(), false, 1, 8);
            foodLayer.Add(new Ball(), false, 3, 8);
            foodLayer.Add(new Ball(), false, 4, 8);
            foodLayer.Add(new Ball(), false, 5, 8);
            foodLayer.Add(new Ball(), false, 6, 8);
            foodLayer.Add(new Ball(), false, 7, 8);
            foodLayer.Add(new Ball(), false, 8, 8);
            foodLayer.Add(new Ball(), false, 9, 8);
            foodLayer.Add(new Ball(), false, 10, 8);
            foodLayer.Add(new Ball(), false, 11, 8);
            foodLayer.Add(new Ball(), false, 12, 8);
            foodLayer.Add(new Ball(), false, 13, 8);
            foodLayer.Add(new Ball(), false, 14, 8);
            foodLayer.Add(new Ball(), false, 15, 8);
            foodLayer.Add(new Ball(), false, 16, 8);
            foodLayer.Add(new Ball(), false, 18, 8);

            foodLayer.Add(new Ball(), false, 1, 9);
            foodLayer.Add(new Ball(), false, 4, 9);
            foodLayer.Add(new Ball(), false, 6, 9);
            foodLayer.Add(new Ball(), false, 13, 9);
            foodLayer.Add(new Ball(), false, 15, 9);
            foodLayer.Add(new Ball(), false, 18, 9);

            foodLayer.Add(new Ball(Ball.BallType.Power), false, 1, 10);
            foodLayer.Add(new Ball(), false, 2, 10);
            foodLayer.Add(new Ball(), false, 3, 10);
            foodLayer.Add(new Ball(), false, 4, 10);
            foodLayer.Add(new Ball(), false, 6, 10);
            foodLayer.Add(new Ball(), false, 7, 10);
            foodLayer.Add(new Ball(), false, 8, 10);
            foodLayer.Add(new Ball(), false, 9, 10);
            foodLayer.Add(new Ball(), false, 10, 10);
            foodLayer.Add(new Ball(), false, 11, 10);
            foodLayer.Add(new Ball(), false, 12, 10);
            foodLayer.Add(new Ball(), false, 13, 10);
            foodLayer.Add(new Ball(), false, 15, 10);
            foodLayer.Add(new Ball(), false, 16, 10);
            foodLayer.Add(new Ball(), false, 17, 10);
            foodLayer.Add(new Ball(Ball.BallType.Power), false, 18, 10);


            //safeplaces
            safePlace = new List <Point>();
            safePlace.Add(new Point(1, 2));
            safePlace.Add(new Point(18, 2));
            safePlace.Add(new Point(1, 10));
            safePlace.Add(new Point(18, 10));

            //spawning place
            spawningPlace = new Point(8, 6);


            //GAME OBJECTS
            GameObjects = new List <Sprite>();

            //add food object to game objects
            for (int c = 0; c < foodLayer.Columns; c++)
            {
                for (int r = 0; r < foodLayer.Rows; r++)
                {
                    if (foodLayer.TileObject[c, r] != null)
                    {
                        //with ball
                        if (foodLayer.TileObject[c, r].Sprite.GetType() == typeof(Ball))
                        {
                            Ball ball = (Ball)foodLayer.TileObject[c, r].Sprite;
                            ball.TileLocation = new Point(c, r);
                            GameObjects.Add(ball);
                            totalBalls++;
                        }
                    }
                }
            }


            //create pacman
            pacMan = new PacMan(backLayer.TileObject[1, 2].Sprite.Location.X,
                                backLayer.TileObject[1, 2].Sprite.Location.Y);
            pacMan.TileLocation = new Point(1, 2);
            pacMan.Speed        = pacManSpeed;


            //create ghosts
            ghost1 = new Ghost(backLayer.TileObject[8, 6].Sprite.Location.X, backLayer.TileObject[8, 6].Sprite.Location.Y);
            ghost1.TileLocation = new Point(8, 6);
            ghost1.Speed        = ghostSpeed;

            ghost2 = new Ghost(backLayer.TileObject[18, 2].Sprite.Location.X, backLayer.TileObject[18, 2].Sprite.Location.Y);
            ghost2.TileLocation = new Point(18, 2);
            ghost2.Speed        = ghostSpeed;

            ghost3 = new Ghost(backLayer.TileObject[18, 10].Sprite.Location.X, backLayer.TileObject[18, 10].Sprite.Location.Y);
            ghost3.TileLocation = new Point(18, 10);
            ghost3.Speed        = ghostSpeed;

            ghost4 = new Ghost(backLayer.TileObject[13, 10].Sprite.Location.X, backLayer.TileObject[13, 10].Sprite.Location.Y);
            ghost4.TileLocation = new Point(13, 10);
            ghost4.Speed        = ghostSpeed;

            ghost5 = new Ghost(backLayer.TileObject[13, 2].Sprite.Location.X, backLayer.TileObject[13, 2].Sprite.Location.Y);
            ghost5.TileLocation = new Point(13, 2);
            ghost5.Speed        = ghostSpeed;

            //add ghosts to game objects
            GameObjects.Add(ghost1);
            GameObjects.Add(ghost2);
            GameObjects.Add(ghost3);
            GameObjects.Add(ghost4);
            GameObjects.Add(ghost5);

            maxGhosts = totalGhosts = 5;
        }