コード例 #1
0
        public Game()
        {
            GalagaBus.GetBus().InitializeEventBus(new List <GameEventType>()
            {
                GameEventType.InputEvent,    // key press / key release
                GameEventType.WindowEvent,   // messages to the window
                GameEventType.GameStateEvent // changes to the game state
            });
            win = new Window("Galaga", 500, 500);

            win.RegisterEventBus(GalagaBus.GetBus());
            GalagaBus.GetBus().Subscribe(GameEventType.WindowEvent, this);
            GalagaBus.GetBus().Subscribe(GameEventType.GameStateEvent, this);

            gameTimer = new GameTimer(60, 60);

            stateMachine = new StateMachine();
        }
コード例 #2
0
        private void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_ESCAPE":
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
                break;

            case "KEY_RIGHT":
                Direction(new Vec2F(0.01f, 0.0f));
                break;

            case "KEY_LEFT":
                Direction(new Vec2F(-0.01f, 0.0f));
                break;

            case "KEY_SPACE":
                AddShots(Game);
                break;
            }
        }