Ejemplo n.º 1
0
        static void Main()
        {
            var framerate = 60;                     // How many ticks a second will occur

            var keyListener = new Listener();       // Create the listener

            KeyGetter.Run(keyListener);             // Start the listener thread
            Console.CursorVisible = false;          // Hide the cursor
            Console.Title         = "BlockBreaker"; // Set the title of the console window

            // Setup filepath to highscores
            ResourceManager.HighscoresPath  = AppDomain.CurrentDomain.BaseDirectory;
            ResourceManager.HighscoresPath += "../../highscores.xml";

            // Create score handlers
            var scorewriter = new XMLScoreWriter();

            var renderer = new Renderer(new Register());
            var display  = new Display();

            // Create Portraits
            var mainMenu     = new MenuPortrait();
            var highscores   = new HighscoresPortrait();
            var enterName    = new EnterNamePortrait();
            var mainGame     = new GamePortrait();
            var endGame      = new EndGamePortrait(scorewriter);
            var instructions = new InstructionsPortrait();

            // Assign keypress events
            keyListener.KeyGot += mainMenu.OnKeyPress;
            keyListener.KeyGot += highscores.OnKeyPress;
            keyListener.KeyGot += enterName.OnKeyPress;
            keyListener.KeyGot += mainGame.OnKeyPress;
            keyListener.KeyGot += endGame.OnKeyPress;
            keyListener.KeyGot += instructions.OnKeyPress;

            // Set up manager
            var portraitManager = new Manager(renderer, display, (int)PageHandles.MainMenu, mainMenu);

            portraitManager.AddPortrait((int)PageHandles.Highscores, highscores);
            portraitManager.AddPortrait((int)PageHandles.GiveName, enterName);
            portraitManager.AddPortrait((int)PageHandles.MainGame, mainGame);
            portraitManager.AddPortrait((int)PageHandles.EndGame, endGame);
            portraitManager.AddPortrait((int)PageHandles.Instructions, instructions);

            while (true)
            {
                portraitManager.Tick();

                Thread.Sleep(1000 / framerate);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var keyListener = new Listener(); // Create the listener

            KeyGetter.Run(keyListener);       // Start the listener thread
        }