Ejemplo n.º 1
0
        public MeadowApp()
        {
            InitializeHardware();

            Console.WriteLine("Create game object");
            game = new RPSLSGame();
            view = new RPSLSView(display);

            Console.WriteLine("Play game");

            PlayGame();

            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 2
0
        public void UpdateDisplay(RPSLSGame game)
        {
            DrawBitmap(12, 80, GetImageDataForHand(game.Player1));

            DrawBitmap(132, 80, GetImageDataForHand(game.Player2));

            //clear buffer showing hands with black
            display.DrawRectangle(0, 185, 240, 16, Color.Black, true);

            var hand = game.Player1.ToString();

            display.DrawText(60 - hand.Length * 6, 185, hand, Blue);

            hand = game.Player2.ToString();
            display.DrawText(180 - hand.Length * 6, 185, hand, Orange);

            //clear buffer showing results with black
            display.DrawRectangle(0, 220, 240, 16, Color.Black, true);

            if (game.GetResult() == RPSLSGame.Result.Player1Wins)
            {
                int start = 120 - (game.Player1.ToString().Length + 6) * 6;
                display.DrawText(start, 220,
                                 game.Player1.ToString(), Blue);
                display.DrawText(start + game.Player1.ToString().Length * 12, 220,
                                 " wins!", White);
            }
            else if (game.GetResult() == RPSLSGame.Result.Player2Wins)
            {
                int start = 120 - (game.Player2.ToString().Length + 6) * 6;
                display.DrawText(start, 220,
                                 game.Player2.ToString(), Orange);
                display.DrawText(start + game.Player2.ToString().Length * 12, 220,
                                 " wins!", White);
            }
            else
            {
                display.DrawText(72, 220, "Tie game", White);
            }

            Console.WriteLine("Update display");

            display.Show();

            Console.WriteLine("Update complete");
        }