예제 #1
0
파일: Game1.cs 프로젝트: jewinemiller/Leap
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            lightmask = Content.Load<Texture2D>("lightmask");
            lightEffect = Content.Load<Effect>("lighting");
            //background = Content.Load<Texture2D>("background");
            //bg2 = Content.Load<Texture2D>("bg2");
            flameTexture = Content.Load<Texture2D>("Torches/torch1");
            cursor = Content.Load<Texture2D>("cursor");

            bgHolder = Content.Load<Texture2D>("wally");
            backgrounds.Add(bgHolder);
            bgHolder = Content.Load<Texture2D>("wally2");
            backgrounds.Add(bgHolder);
            bgHolder = Content.Load<Texture2D>("wally");
            backgrounds.Add(bgHolder);
            bgHolder = Content.Load<Texture2D>("wally2");
            backgrounds.Add(bgHolder);

            bgHolder = Content.Load<Texture2D>("rocky1");
            rocks.Add(bgHolder);
            bgHolder = Content.Load<Texture2D>("rocky2");
            rocks.Add(bgHolder);
            bgHolder = Content.Load<Texture2D>("rocky1");
            rocks.Add(bgHolder);
            bgHolder = Content.Load<Texture2D>("rocky2");
            rocks.Add(bgHolder);

            font = Content.Load<SpriteFont>("Font");
            fontLocation = new Vector2(0.0f, graphics.GraphicsDevice.Viewport.Height-25);
            fontTime = 0;

            bgmusic = Content.Load<Song>("Audio/MP3s/song2");

            platformTextures = new Texture2D[17];
            platformTextures[0] = Content.Load<Texture2D>("Platforms/endcap_left");
            platformTextures[1] = Content.Load<Texture2D>("Platforms/endcap_right");

            for (int i = 0; i < platformTextures.Length - 3; i++)
            {
                platformTextures[i + 2] = Content.Load<Texture2D>("Platforms/segment" + Convert.ToString(i+1));
            }

            pHolder = Content.Load<Texture2D>("running/lofwalking10001");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10002");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10003");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10004");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10005");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10006");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10007");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10008");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10009");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10010");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10011");
            playerAnimation.Add(pHolder);
            pHolder = Content.Load<Texture2D>("running/lofwalking10012");
            playerAnimation.Add(pHolder);

            playerAnim = new Animation(1, playerAnimation);

            world.addPlatform(new Rectangle(100, 200, 150, 25), Content.Load<Texture2D>("Platform"), platformTextures, randomNumber);
            world.addPlatform(new Rectangle(300, 200, 150, 25), Content.Load<Texture2D>("Platform"), platformTextures, randomNumber);
            world.addPlatform(new Rectangle(550, 150, 150, 25), Content.Load<Texture2D>("Platform"), platformTextures, randomNumber);
            world.addPlatform(new Rectangle(800, 175, 150, 25), Content.Load<Texture2D>("Platform"), platformTextures, randomNumber);

            playerTexture = Content.Load<Texture2D>("dude");
            player = new Player(playerTexture, graphics, world, flameTexture);
            player.animCycle = playerAnim;
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            var param = graphics.GraphicsDevice.PresentationParameters;
            scene = new RenderTarget2D(graphics.GraphicsDevice, param.BackBufferWidth, param.BackBufferHeight);
            mask = new RenderTarget2D(graphics.GraphicsDevice, param.BackBufferWidth, param.BackBufferHeight);

            menu = new MainMenu(Content, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));

            MediaPlayer.Play(bgmusic);
            MediaPlayer.IsRepeating = true;

            //Powerups
            torchTexture = Content.Load<Texture2D>("Torches/torch1");
            torchPowerupPos = new Vector2(0,0);
            torchPowerup = new Powerup(torchTexture, torchPowerupPos, 3);

            //bg2 = Content.Load<Texture2D>("bg2");
            //bg3 = Content.Load<Texture2D>("bg3");

            /*bgs[0] = background;
            bgs[1] = background;
            bgs[2] = background;

            rects[0] = new Rectangle(0, 0, background.Width, background.Height);
            rects[1] = new Rectangle(background.Width, 0, background.Width, background.Height);
            rects[2] = new Rectangle(background.Width, 0, background.Width, background.Height);
            */
            rects = new Rectangle[backgrounds.Count];
            rockrects = new Rectangle[rocks.Count];
            rects[0] = new Rectangle(0, 0, backgrounds[0].Width, backgrounds[0].Height);
            rockrects[0] = new Rectangle(0, 0, rocks[0].Width, rocks[0].Height);

            for (int i = 1; i < rects.Length; i++)
            {
                rects[i] = new Rectangle((rects[i - 1].X + rects[i - 1].Width), 0, backgrounds[i].Width, backgrounds[i].Height);
            }

            for (int i = 1; i < rockrects.Length; i++)
            {
                rockrects[i] = new Rectangle((rockrects[i - 1].X + rockrects[i - 1].Width), 0, rocks[i].Width, rocks[i].Height);
            }

            backObj = new Background(rects);
            world.bg = backObj;
            rockObj = new Background(rockrects);
            world.rocks = rockObj;
        }
예제 #2
0
파일: Game1.cs 프로젝트: jewinemiller/Leap
        protected override void Update(GameTime gameTime)
        {
            if (!menu.isActive)
            {
                world.shrinkLight();

                fontTime++;

                currState = Keyboard.GetState();
                // Allows the game to exit
                if (currState.IsKeyDown(Keys.Escape) && !prevState.IsKeyDown(Keys.Escape))
                {
                    menu = new PauseMenu(Content, new Rectangle(graphics.PreferredBackBufferWidth, 0, 500, graphics.PreferredBackBufferHeight), world, torchPowerup);
                }

                player.move(currState, prevState, torchPowerup);
                player.checkState();

                if (player.Location.Y >= graphics.PreferredBackBufferHeight - player.Body.Height)
                {
                    menu = new GameOver(Content, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), world, torchPowerup);
                }
                world.checkForTorches(player, torchPowerup);

                //Save our kbstate
                prevState = currState;
                sizeFactor = world.sizeFactor;
                rects = world.bg.rects;
                rockrects = world.rocks.rects;
                world.checkFallingPlatforms(3);

                /*if (currState.IsKeyDown(Keys.Right) || currState.IsKeyDown(Keys.D))
                {
                    world.movePlatforms(5);
                }*/
            }
            else
            {
                currMouse = Mouse.GetState();
                mouseLoc = new Vector2(currMouse.X, currMouse.Y);
                menu.Update(gameTime);
                prevMouse = currMouse;
            }
            base.Update(gameTime);
        }
예제 #3
0
파일: Button.cs 프로젝트: jewinemiller/Leap
 public void act(Menu.actFunction func)
 {
     func();
 }