void LoadScreen()
        {
            Console.WriteLine("LoadScreen...");

            graphics.Clear();

            int radius  = 225;
            int originX = graphics.Width / 2;
            int originY = graphics.Height / 2 + 130;

            graphics.Stroke = 3;
            for (int i = 1; i < 5; i++)
            {
                graphics.DrawCircle
                (
                    centerX: originX,
                    centerY: originY,
                    radius: radius,
                    color: colors[i - 1],
                    filled: true
                );

                graphics.Show();
                radius -= 20;
            }

            graphics.DrawLine(0, 220, 240, 220, Color.White);
            graphics.DrawLine(0, 230, 240, 230, Color.White);

            graphics.CurrentFont = new Font12x20();
            graphics.DrawText(54, 130, "TEMPERATURE", Color.White);

            graphics.Show();
        }
        void DrawTitleMenu()
        {
            Console.WriteLine("Draw title");

            graphics.Clear();
            graphics.Show();
            Thread.Sleep(400);//pause for video recording

            graphics.DrawLine(0, 0, 127, 0, true);
            graphics.Show();
            for (int i = 1; i < 63; i++)
            {
                graphics.DrawPixel(0, i);
                graphics.DrawPixel(127, i);
                graphics.Show();
            }

            graphics.DrawLine(0, 63, 127, 63, true);
            graphics.Show();
            Thread.Sleep(400);

            graphics.DrawText(22, 20, "Frogger");
            graphics.Show();
            Thread.Sleep(400);

            for (int i = 0; i < 5; i++)
            {
                DrawFrog(20 * (i + 1), 50, 1);

                graphics.Show();
                Thread.Sleep(400);
            }
        }
Beispiel #3
0
        void Draw()
        {
            int angle = 160;
            int increment = 4;
            int x, y = 0;

            while (true)
            {
                graphics.Clear();

                DrawRadar();

                graphics.DrawLine(120, 170, 105, (float)(angle * Math.PI / 180), Color.Yellow);

                if (angle >= 180)
                {
                    increment = -4;
                }
                if (angle <= 0)
                {
                    increment = 4;
                }

                angle += increment;
                servo.RotateTo(new Angle(angle, AU.Degrees));

                graphics.DrawText(0, 0, $"{180 - angle}°", Color.Yellow);

                if (sensor.Distance != null && sensor.Distance >= new Length(0, LU.Millimeters))
                {
                    graphics.DrawText(170, 0, $"{sensor.Distance?.Millimeters}mm", Color.Yellow);
                    radarData[angle] = (float)(sensor.Distance?.Millimeters / 2);
                }
                else
                {
                    radarData[angle] = 0;
                }

                for (int i = 0; i < 180; i++)
                {
                    x = 120 + (int)(radarData[i] * MathF.Cos(i * MathF.PI / 180f));
                    y = 170 - (int)(radarData[i] * MathF.Sin(i * MathF.PI / 180f));
                    graphics.DrawCircle(x, y, 2, Color.Yellow, true);
                }

                graphics.Show();
                Thread.Sleep(100);
            }
        }
        void DrawShapes()
        {
            Random rand = new Random();

            graphics.Clear(true);

            int radius  = 10;
            int originX = displayWidth / 2;
            int originY = displayHeight / 2;

            for (int i = 1; i < 5; i++)
            {
                graphics.DrawCircle
                (
                    centerX: originX,
                    centerY: originY,
                    radius: radius,
                    color: Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))
                );
                graphics.Show();
                radius += 30;
            }

            int sideLength = 30;

            for (int i = 1; i < 5; i++)
            {
                graphics.DrawRectangle
                (
                    x: (displayWidth - sideLength) / 2,
                    y: (displayHeight - sideLength) / 2,
                    width: sideLength,
                    height: sideLength,
                    color: Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))
                );
                graphics.Show();
                sideLength += 60;
            }

            graphics.DrawLine(0, displayHeight / 2, displayWidth, displayHeight / 2,
                              Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)));
            graphics.DrawLine(displayWidth / 2, 0, displayWidth / 2, displayHeight,
                              Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)));
            graphics.DrawLine(0, 0, displayWidth, displayHeight,
                              Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)));
            graphics.DrawLine(0, displayHeight, displayWidth, 0,
                              Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)));
            graphics.Show();

            //Thread.Sleep(5000);
        }
        void DrawGame()
        {
            //draw gameboard
            graphics.DrawRectangle(xStart, yStart, CellSize * connectGame.Width + 1, CellSize * connectGame.Height + 1, Color.DarkBlue, true);
            graphics.DrawRectangle(xStart, yStart, CellSize * connectGame.Width + 1, CellSize * connectGame.Height + 1, Color.Blue, false);

            for (int i = 1; i < 7; i++)
            {
                graphics.DrawLine(xStart + CellSize * i,
                                  yStart,
                                  xStart + CellSize * i,
                                  yStart + CellSize * 6 + 1,
                                  Color.Blue);
            }

            for (int j = 1; j < 6; j++)
            {
                graphics.DrawLine(xStart,
                                  yStart + j * CellSize,
                                  CellSize * connectGame.Width + xStart,
                                  yStart + j * CellSize,
                                  Color.Blue);
            }

            for (int x = 0; x < connectGame.Width; x++)
            {
                for (int y = 0; y < connectGame.Height; y++)
                {
                    if (connectGame.GameField[x, y] == 0)
                    {
                        continue;
                    }
                    DrawChipOnBoard(x, y, connectGame.GameField[x, y] == 1);
                    //DrawChipOnBoard(x, y, x % 2 == 0);
                }
            }

            //Game state
            switch (connectGame.GameState)
            {
            case Span4Game.GameStateType.Draw:
                graphics.DrawText(2, 0, "Draw", Color.White);
                break;

            case Span4Game.GameStateType.Player1Wins:
                graphics.DrawText(2, 0, "Player 1 Wins!", Color.White);
                break;

            case Span4Game.GameStateType.Player2Wins:
                graphics.DrawText(2, 0, "Player 2 Wins!", Color.White);
                break;

            case Span4Game.GameStateType.Player1Turn:
                DrawPreviewChip(currentColumn, true);
                break;

            case Span4Game.GameStateType.Player2Turn:
                DrawPreviewChip(currentColumn, false);
                break;
            }

            //Draw side display

            /*   int xText = 150;
             * graphics.DrawText(xText, 0, "Span4!");
             *
             * graphics.DrawText(xText, 18, "Player 1");
             * DrawChip(xText + 40, 21, 3, true);
             *
             * graphics.DrawText(xText, 27, "Player 2");
             * DrawChip(xText + 40, 30, 3, false);
             *
             * graphics.DrawText(xText, 45, "Score:");
             * graphics.DrawText(xText, 54, $"{connectGame.Player1Wins} to {connectGame.Player2Wins}");  */
        }
Beispiel #6
0
        void DrawGame()
        {
            //draw gameboard
            graphics.DrawRectangle(0, 9, 64, 55, true, false);

            for (int i = 1; i < 7; i++)
            {
                graphics.DrawLine(CellSize * i,
                                  yStart,
                                  CellSize * i,
                                  yStart + CellSize * 6 + 1,
                                  true);
            }

            for (int j = 1; j < 6; j++)
            {
                graphics.DrawLine(xStart,
                                  yStart + j * CellSize,
                                  63 + xStart,
                                  yStart + j * CellSize,
                                  true);
            }

            for (int x = 0; x < connectGame.Width; x++)
            {
                for (int y = 0; y < connectGame.Height; y++)
                {
                    if (connectGame.GameField[x, y] == 0)
                    {
                        continue;
                    }
                    DrawChipOnBoard(x, y, connectGame.GameField[x, y] == 1);
                }
            }

            //Game state
            switch (connectGame.GameState)
            {
            case Span4Game.GameStateType.Draw:
                graphics.DrawText(2, 0, "Draw");
                break;

            case Span4Game.GameStateType.Player1Wins:
                graphics.DrawText(2, 0, "Player 1 Wins!");
                break;

            case Span4Game.GameStateType.Player2Wins:
                graphics.DrawText(2, 0, "Player 2 Wins!");
                break;

            case Span4Game.GameStateType.Player1Turn:
                DrawPreviewChip(currentColumn, true);
                break;

            case Span4Game.GameStateType.Player2Turn:
                DrawPreviewChip(currentColumn, false);
                break;
            }

            //Draw side display
            int xText = 75;

            graphics.DrawText(xText, 0, "Span4!");

            graphics.DrawText(xText, 18, "Player 1");
            DrawChip(115, 21, true);

            graphics.DrawText(xText, 27, "Player 2");
            DrawChip(115, 30, false);

            graphics.DrawText(xText, 45, "Score:");
            graphics.DrawText(xText, 54, $"{connectGame.Player1Wins} to {connectGame.Player2Wins}");
        }