Example #1
0
        static void Main(string[] args)
        {
            Random   random  = new Random();
            IDisplay display = new ArduinoDisplay();

            IPixel[,] pixels = new IPixel[20, 10];
            while (true)
            {
                Thread.Sleep(1);
                display.DisplayInt(100);
                for (sbyte i = 0; i < 20; i++)
                {
                    for (sbyte j = 0; j < 10; j++)
                    {
                        //pixels[i, j] = new Pixel((byte)random.Next(1, 256), (byte)random.Next(1, 256), (byte)random.Next(1, 256));
                        pixels[i, j] = new Pixel(0, 0, 0);
                    }
                }

                display.Draw(pixels);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            ReadBMP("title.txt", ref title);
            ReadBMP("gameOver.txt", ref gameOver);

            for (int i = 0; i < background.GetLength(0); i++)
            {
                for (int j = 0; j < background.GetLength(1); j++)
                {
                    if (i < background.GetLength(0) - 2)
                    {
                        background[i, j] = dullerRainbow[j];
                        board[i, j]      = dullerRainbow[j];
                    }
                    else
                    {
                        background[i, j] = new Pixel(0, 0, 0);
                        board[i, j]      = new Pixel(0, 0, 0);
                    }
                }
            }

            IDisplay display = new ArduinoDisplay();

            state = State.Title;

            while (true)
            {
                if (state == State.Playing)
                {
                    UpdateCats();
                    UpdateLasers();
                    UpdateFallingStuff();
                    UpdateBat();

                    Thread.Sleep(50);

                    int catsAlive = 0;

                    foreach (int c in cats)
                    {
                        if (c == 1)
                        {
                            catsAlive++;
                        }
                    }

                    display.DisplayInts(catsAlive, score);

                    bool allCatsDead = true;

                    foreach (int i in cats)
                    {
                        if (i == 1)
                        {
                            allCatsDead = false;
                            break;
                        }
                    }

                    if (allCatsDead)
                    {
                        state = State.GameOver;
                    }
                }
                else if (state == State.Title)
                {
                    UpdateTitle();
                }
                else if (state == State.GameOver)
                {
                    UpdateGameOver();
                }
                display.Draw(board);
            }
        }