Exemplo n.º 1
0
        public bool SpritesCollide(PacmanSprite sprite1, PacmanSprite sprite2)
        {
            Rectangle rec1 = new Rectangle(Convert.ToInt32(sprite1.Location.X + 8), Convert.ToInt32(sprite1.Location.Y + 8), 16, 16);
            Rectangle rec2 = new Rectangle(Convert.ToInt32(sprite2.Location.X + 8), Convert.ToInt32(sprite2.Location.Y + 8), 16, 16);


            if (rec1.Intersects(rec2))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public Game1()
        {
            GameState = GameState.Playing;
            _Graphics = new GraphicsDeviceManager(this);
            _Graphics.PreferredBackBufferHeight = 700;
            _Graphics.PreferredBackBufferWidth  = 700;
            _Content = new ContentManager(Services);
            _Player  = new PacmanSprite(9 * 32, 16 * 32, Window.ClientBounds.Width, Window.ClientBounds.Height, Keys.Left, Keys.Right, Keys.Up, Keys.Down);
            _Blinky  = new GhostBase(SpriteType.Blinkey, 9 * 32, 6 * 32, Window.ClientBounds.Width, Window.ClientBounds.Height);
            _Pinky   = new GhostBase(SpriteType.Pinkey, 9 * 32, 6 * 32, Window.ClientBounds.Width, Window.ClientBounds.Height);
            _Clyde   = new GhostBase(SpriteType.Clyde, 9 * 32, 6 * 32, Window.ClientBounds.Width, Window.ClientBounds.Height);
            _Inky    = new GhostBase(SpriteType.Inky, 9 * 32, 6 * 32, Window.ClientBounds.Width, Window.ClientBounds.Height);

            TheMaze = new Maze();

            TheMaze.OnAtePowerPellet += new EventHandler(TheMaze_OnAtePowerPellet);
            TheMaze.OnAtePellet      += new EventHandler(TheMaze_OnAtePellet);
        }