Example #1
0
 public bool Collision(Pellet p)
 {
     if (rect.IntersectsWith(p.rect))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #2
0
        public void initLevel()
        {
            tmpXSpeed = player.getXSpeed();
            tmpYSpeed = player.getYSpeed();

            for (int i = 1; i < 36; i++)
            {
                Pellet p = new Pellet(32 + (i * 20), 50, 10, 10, Color.Yellow);
                pellets.Add(p);
            }

            for (int i = 1; i < 25; i++)
            {
                Pellet p = new Pellet(52, 50 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }

            Ghost g = new Ghost(100, 250, 32, GHOST_SPEED, 0, "ambush", Color.Red);

            ghosts.Add(g);

            Wall w  = new Wall(25, 25, 12, 240, Color.Blue);
            Wall w2 = new Wall(25, 25, 740, 12, Color.Blue);
            Wall w3 = new Wall(765, 25, 12, 240, Color.Blue);
            Wall w4 = new Wall(25, 305, 12, 240, Color.Blue);
            Wall w5 = new Wall(765, 305, 12, 240, Color.Blue);
            Wall w6 = new Wall(25, 545, 752, 12, Color.Blue);
            Wall w7 = new Wall(15, 305, 12, 15, Color.Yellow);

            // TODO: Figure out a way to have pac-man teleport when he exits

            walls.Add(w);
            walls.Add(w2);
            walls.Add(w3);
            walls.Add(w4);
            walls.Add(w5);
            walls.Add(w6);
        }
Example #3
0
        public void createPellets()
        {
            // create pellets
            #region Pellets
            for (int i = 1; i < 6; i++)
            {
                Pellet p = new Pellet(12 + (i * 20), 46, 10, 10, Color.Yellow);
                pellets.Add(p);
            }

            PowerPellet pp = new PowerPellet(128, 40, 20, 50, Color.Wheat);
            powerPellets.Add(pp);
            PowerPellet pp2 = new PowerPellet(50, 500, 20, 50, Color.Wheat);
            powerPellets.Add(pp2);
            PowerPellet pp3 = new PowerPellet(760, 42, 20, 50, Color.Wheat);
            powerPellets.Add(pp3);
            PowerPellet pp4 = new PowerPellet(758, 372, 20, 50, Color.Wheat);
            powerPellets.Add(pp4);

            for (int i = 1; i < 10; i++)
            {
                Pellet p = new Pellet(32, 46 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 6; i++)
            {
                Pellet p = new Pellet(32 + (i * 20), 226, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 9; i++)
            {
                Pellet p = new Pellet(132, 46 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 15; i++)
            {
                Pellet p = new Pellet(132, 206 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 6; i++)
            {
                Pellet p = new Pellet(10 + (i * 20), 330, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 5; i++)
            {
                Pellet p = new Pellet(30, 330 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 6; i++)
            {
                Pellet p = new Pellet(55, 385 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 1; i < 35; i++)
            {
                Pellet p = new Pellet(55 + (i * 20), 505, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 18; i++)
            {
                Pellet p = new Pellet(295, 480 - (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 28; i++)
            {
                Pellet p = new Pellet(150 + (i * 20), 105, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(199, 85 - (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 20; i++)
            {
                Pellet p = new Pellet(215 + (i * 20), 45, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 2; i++)
            {
                Pellet p = new Pellet(592, 68 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 2; i++)
            {
                Pellet p = new Pellet(396, 68 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(155 + (i * 20), 178, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 18; i++)
            {
                Pellet p = new Pellet(497, 132 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 13; i++)
            {
                Pellet p = new Pellet(200, 202 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 2; i++)
            {
                Pellet p = new Pellet(152 + (i * 20), 274, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 2; i++)
            {
                Pellet p = new Pellet(152 + (i * 20), 400, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(222 + (i * 20), 278, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(222 + (i * 20), 441, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 8; i++)
            {
                Pellet p = new Pellet(320 + (i * 20), 212, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 8; i++)
            {
                Pellet p = new Pellet(320 + (i * 20), 345, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 8; i++)
            {
                Pellet p = new Pellet(320 + (i * 20), 439, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 9; i++)
            {
                Pellet p = new Pellet(520 + (i * 20), 272, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(398, 373 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 5; i++)
            {
                Pellet p = new Pellet(592, 179 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 8; i++)
            {
                Pellet p = new Pellet(595, 298 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(520 + (i * 20), 441, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 4; i++)
            {
                Pellet p = new Pellet(694 + (i * 20), 43, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 8; i++)
            {
                Pellet p = new Pellet(762, 68 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 10; i++)
            {
                Pellet p = new Pellet(663, 298 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 7; i++)
            {
                Pellet p = new Pellet(663, 132 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(665, 46 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 2; i++)
            {
                Pellet p = new Pellet(618 + (i * 20), 399, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 2; i++)
            {
                Pellet p = new Pellet(621 + (i * 20), 178, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 4; i++)
            {
                Pellet p = new Pellet(697 + (i * 20), 330, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 4; i++)
            {
                Pellet p = new Pellet(762, 354 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 5; i++)
            {
                Pellet p = new Pellet(735, 410 + (i * 20), 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            for (int i = 0; i < 3; i++)
            {
                Pellet p = new Pellet(695 + (i * 20), 220, 10, 10, Color.Yellow);
                pellets.Add(p);
            }
            #endregion
        }
Example #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            boi = new Pacboi(Content.Load <Texture2D>("spritesheet"), new Rectangle(312, 615, 45, 45),
                             new Rectangle(3, 0, 15, 15), new Vector2(0, 0), new Rectangle(327, 630, 14, 14));

            lifesource = new Rectangle(132, 17, 15, 15);
            //pacboi's starting location based off of map tiles
            //25.625 y
            //13 x
            pacMoved    = false;
            pacJustDied = false;
            nextInQueue = Direction.Up;

            int screenWidth  = graphics.GraphicsDevice.Viewport.Width;
            int screenHeight = graphics.GraphicsDevice.Viewport.Height;

            score = 0;

            mapsquare = GetTiles();
            map       = new Board(Content.Load <Texture2D>("pacmenu"), new Rectangle(0, 72, 672, 744), mapsquare);

            text = "Test Text hererererere.....";
            //Isaiahs Stuff \______________________
            pellets = new Pellet[244];

            pelletPositionsX = new int[] { 50, 100, 150 };
            pelletPositionsY = new int[] { 50, 100, 150 };
            //setPellets();

            topText      = "1UP     HIGH SCORE";
            posOfTopText = new Vector2(100, 0);

            //dem
            //224
            //288
            //672
            //864

            //if its a normal or power pellet
            Boolean isPowerPelletTrue = false;

            for (int i = 0; i < pelletPositionsX.Length; i++)
            {
                //if (pelletPositionsX[i] == 24 || pelletPositionsX[i] == 816 || pelletPositionsY[i] == 144 || pelletPositionsY[i] == 624)
                //{
                //    isPowerPelletTrue = true;
                //}
                //else
                //{
                //    isPowerPelletTrue = false;
                //}
                //makes the pellet objects
                pellets[i] = new Pellet(pelletPositionsX[i], pelletPositionsY[i], i, isPowerPelletTrue);
            }
            for (int r = 0; r < 28; r++)
            {
                for (int c = 0; c < 36; c++)
                {
                    if (map.space[r, c].pellet == true)
                    {
                        tester[r, c] = new Pellet(r, c, false);
                    }
                    else if (map.space[r, c].powerPellet == true)
                    {
                        tester[r, c] = new Pellet(r, c, true);
                    }
                    else
                    {
                        tester[r, c] = new Pellet(10000, 100000, false);
                    }
                }
            }
            //______________________________________

            ghosts = new Ghost[]
            {
                new Inky(24 * 12, 24 * 17),
                new Blinky(24 * 14, 24 * 14),
                new Pinky(24 * 14, 24 * 17),
                new Clyde(24 * 16, 24 * 17)
            };
            //foreach (Ghost g in ghosts) g.Run();

            Oldkb = Keyboard.GetState();

            base.Initialize();
        }