Пример #1
0
        public Form1()
        {
            InitializeComponent();

            var soundSet = new SoundSet();

            _game = Game.Game.Create()
                    .Subscribe(GameNotification.Beginning, soundSet.Beginning)
                    .Subscribe(GameNotification.EatCoin, soundSet.Chomp)
                    .Subscribe(GameNotification.Respawning, soundSet.Death)
                    .Subscribe(GameNotification.EatFruit, soundSet.EatFruit)
                    .Subscribe(GameNotification.EatGhost, soundSet.EatGhost)
                    .Subscribe(GameNotification.ExtraPac, soundSet.ExtraPac)
                    .Subscribe(GameNotification.Intermission, soundSet.Intermission)
                    .StartGame();

            _graphicsBuffers = new GraphicsBuffers(this)
            {
                ShowFps = true
            };

            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text          = "PacMan";
            this.WindowState   = FormWindowState.Maximized;
            this.KeyDown      += Form1_KeyDown;

            _renderLoop.Interval = 16; //40fps
            _renderLoop.Enabled  = true;
            _renderLoop.Tick    += _renderLoop_Tick;
        }
Пример #2
0
        internal static Game.Game AddSounds(this Game.Game game)
        {
            var soundSet = new SoundSet();

            game.Subscribe(GameNotification.Beginning, soundSet.Beginning)
            .Subscribe(GameNotification.EatCoin, soundSet.Chomp)
            .Subscribe(GameNotification.Respawning, soundSet.Death)
            .Subscribe(GameNotification.EatFruit, soundSet.EatFruit)
            .Subscribe(GameNotification.EatGhost, soundSet.EatGhost)
            .Subscribe(GameNotification.ExtraPac, soundSet.ExtraPac)
            .Subscribe(GameNotification.Intermission, soundSet.Intermission);

            return(game);
        }