private static void CreateGameScene(ISceneStack stack)
        {
            // Here we build a simple scene for a "game" where the
            // player can move a big white circle around the screen.
            var   gameInputHandler = NewInputHandler();
            Scene gameScene        = new Scene {
                InputHandler = gameInputHandler
            };

            Vector2 position = 0.5 * (Vector2)Display.CurrentWindow.Size;
            Vector2 velocity = Vector2.Zero;

            var gamepad = gameInputHandler.Gamepads.First();

            gamepad.ButtonPressed += (sender, e) =>
            {
                if (e.Button == GamepadButton.Back)
                {
                    gameScene.IsFinished = true;
                }
            };

            gamepad.LeftStickChanged += (sender, e) =>
            {
                velocity = 500 * gamepad.LeftStick;
            };

            gameScene.Update += (sender, e) =>
            {
                position += velocity * e.TotalSeconds;
            };

            var font = new Font(Font.AgateSerif)
            {
                Size  = 22,
                Style = FontStyles.Bold
            };

            gameScene.Redraw += (sender, e) =>
            {
                Display.Clear(Color.Blue);
                font.DrawText(0, 0, "Press escape to go back to title screen.");

                Display.Primitives.FillCircle(Color.White, position, 40);
            };

            stack.Add(gameScene);
        }
Ejemplo n.º 2
0
        public XleScreenCapture(
            GraphicsDevice graphics,
            IXleRenderer renderer,
            ISceneStack sceneStack,
            IXleGameControl gameControl,
            GameState gameState)
        {
            this.graphics    = graphics;
            this.renderer    = renderer;
            this.sceneStack  = sceneStack;
            this.gameControl = gameControl;
            this.gameState   = gameState;

            this.spriteBatch = new SpriteBatch(graphics);

            keyboard.KeyPress += Keyboard_KeyPress;
        }
Ejemplo n.º 3
0
        public async Task Wait(ISceneStack sceneStack)
        {
            while (timeLeft_ms > 0)
            {
                this.IsFinished = false;
                sceneStack.AddOrBringToTop(this);

                int delay = (int)(timeLeft_ms + 1);

                if (delay < 1)
                {
                    delay = 1;
                }

                //                await Task.Delay(delay);
                //await Task.Yield();
                await Task.Delay(1);
            }
        }
Ejemplo n.º 4
0
 public XleWaiter(ISceneStack sceneStack, GraphicsDevice graphics, WaitScene waitScene)
 {
     this.sceneStack = sceneStack;
     this.waitScene  = waitScene;
 }
Ejemplo n.º 5
0
 public AgateConsoleManager(ISceneStack sceneStack, AgateConsole console, AgateConsoleScene consoleScene)
 {
     this.sceneStack   = sceneStack;
     this.console      = console;
     this.consoleScene = consoleScene;
 }