Beispiel #1
0
        static int Main(string[] args)
        {
            //preparing Console
            Console.Clear();
            Console.CursorVisible = false;

            _drawer = new ConsoleDrawing();

            ConsoleDrawing.ShowControls();

            Console.ReadKey(true);
            Console.Clear();

            _game = new Game(null);
            _game.Start();
            _gameTimer          = new System.Timers.Timer(800);
            _gameTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            _gameTimer.Start();


            _drawer.DrawScene(_game);

            controller = new Controller(0);
            if (controller.IsConnected)
            {
                controllerPollTimer          = new System.Timers.Timer(50);
                controllerPollTimer.Elapsed += ControllerPoll;
                controllerPollTimer.Start();
                prevControllerState = controller.GetState();
            }


            while (_game.Status != Game.GameStatus.Finished)
            {
                if (Console.KeyAvailable)
                {
                    KeyPressedHandler(Console.ReadKey(true));
                    _drawer.DrawScene(_game);
                    _gameTimer.Enabled = true;
                }
            }
            _gameTimer.Stop();
            _drawer.ShowGameOver(_game);

            Console.ResetColor();
            Console.CursorVisible = true;
            return(0);
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            //preparing Console
            Console.Clear();
            Console.CursorVisible = false;

            _drawer    = new ConsoleDrawing();
            _ramDrawer = new RamDrawing();
            ConsoleDrawing.ShowControls();

            Console.ReadKey(true);
            Console.Clear();

            _game = new Game(_ramDrawer.Ram.Count, _ramDrawer.Ram.Max(r => r.Count()));
            _game.Start();
            _gameTimer          = new System.Timers.Timer(800);
            _gameTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            _gameTimer.Start();

            _drawer.DrawScene(_game);
            _ramDrawer.DrawScene(_game);

            while (_game.Status != Game.GameStatus.Finished)
            {
                if (Console.KeyAvailable)
                {
                    KeyPressedHandler(Console.ReadKey(true));
                    _drawer.DrawScene(_game);
                    _ramDrawer.DrawScene(_game);
                    _gameTimer.Enabled = true;
                }
            }

            _gameTimer.Stop();
            _drawer.ShowGameOver(_game);

            Console.ResetColor();
            Console.CursorVisible = true;
            return(0);
        }