Exemple #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            UpdateOffset();

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (!escDown && overlay == null)
                {
                    overlay = new GameMenu(GraphicsDevice, Content);
                }
                escDown = true;
            }
            else
            {
                escDown = false;
            }

            if (overlay != null)
            {
                overlay.Update(gameTime);
                overlay.UpdateGame(this);

                if (overlay.IsFinished())
                {
                    overlay = null;
                }
                else
                {
                    return;
                }
            }

            worldScale = Lerp(worldScale, DEFAULT_SCALE, 0.8f);

            // Here's where the input manager is told to deal with the input
            InputManager.ActKeyboard(Keyboard.GetState());
            InputManager.ActMouse(Mouse.GetState());

            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            myAnimatedHero.UpdateCurrentPlatform(elapsedTime, myPlatforms);
            foreach (Sprite s in mySprites)
            {
                s.Update(elapsedTime);
            }
            foreach (WordSprite word in myWordSprites)
            {
                word.Update(elapsedTime);
            }

            if (myAnimatedHero.IsTransitioned)
            {
                PlatformSprite currentPlatform = myAnimatedHero.currentPlatform;
                if (currentPlatform != null)
                {
                    MapData newMap = currentPlatform.data.NextMap;
                    if (newMap != null)
                    {
                        overlay = new MapTransition(GraphicsDevice, Content, newMap);
                    }
                }
            }

            base.Update(gameTime);
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            if (game == null)
            {
                game = GameData.ReadFromFile("../../../../../Game1.game");
            }

            map = game.StartMap;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Texture2D bgSprite = Content.Load<Texture2D>("space");
            background = new Background(bgSprite, (int)myScreenSize.X, (int)myScreenSize.Y);

            // TODO: use this.Content to load your game content here
            // Make the hero
            Texture2D heroImage = Content.Load<Texture2D>("hero");
            Texture2D shadow = Content.Load<Texture2D>("shadow");
            Texture2D[] heroImages = {Content.Load<Texture2D>("hero0"),
                                         Content.Load<Texture2D>("hero1"),
                                         Content.Load<Texture2D>("hero2"),
                                         Content.Load<Texture2D>("hero3")};
            Vector2 center = myScreenSize / 2;
            myAnimatedHero = new AnimatedHero(heroImages, shadow, center, myScreenSize);

            LoadMap(map);

            overlay = new SplashScreen(GraphicsDevice, Content);
        }