Пример #1
0
        public PlatformerGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

#if WINDOWS_PHONE
            TargetElapsedTime = TimeSpan.FromTicks(333333);
#endif
#if MONOMAC || WINDOWS || LINUX
            graphics.IsFullScreen              = false;
            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 480;
#else
            graphics.IsFullScreen = true;
#endif

            //graphics.PreferredBackBufferWidth = 800;
            //graphics.PreferredBackBufferHeight = 480;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

            Accelerometer.Initialize();
        }
Пример #2
0
        private void HandleInput(GameTime gameTime)
        {
            // get all of our input states
            keyboardState      = Keyboard.GetState();
            touchState         = TouchPanel.GetState();
            gamePadState       = virtualGamePad.GetState(touchState, GamePad.GetState(PlayerIndex.One));
            accelerometerState = Accelerometer.GetState();

            bool continuePressed =
                keyboardState.IsKeyDown(Keys.Space) ||
                gamePadState.IsButtonDown(Buttons.A) ||
                touchState.AnyTouch();

            // Perform the appropriate action to advance the game and
            // to get the player back to playing.
            if (!wasContinuePressed && continuePressed)
            {
                if (!level.Player.IsAlive)
                {
                    level.StartNewLife();
                }
                else if (level.TimeRemaining == TimeSpan.Zero)
                {
                    if (level.ReachedExit)
                    {
                        LoadNextLevel();
                    }
                    else
                    {
                        ReloadCurrentLevel();
                    }
                }
            }

            wasContinuePressed = continuePressed;

            virtualGamePad.Update(gameTime);
        }
Пример #3
0
        public PlatformerGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

#if WINDOWS_PHONE
            TargetElapsedTime = TimeSpan.FromTicks(333333);
#endif
            graphics.IsFullScreen = false;

            graphics.PreferredBackBufferWidth  = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.SupportedOrientations     = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

            Accelerometer.Initialize();

            // Create our lighting component and register it as a service so that subsystems can access it.
            penumbra = new PenumbraComponent(this)
            {
                AmbientColor = new Color(new Vector3(0.1f))
            };
            Services.AddService(penumbra);
        }