예제 #1
0
파일: Program.cs 프로젝트: kunmukh/EE-356
        static void showScore()
        {
            var blueBrush  = new SolidBrush(Color.Blue);
            var redBrush   = new SolidBrush(Color.Red);
            var greenBrush = new SolidBrush(Color.Green);
            var font       = Resource1.GetFont(Resource1.FontResources.Ariel32);

            screen.Clear(Color.Black);
            //
            screen.FillRectangle(blueBrush, 20, 20, 400, 230);
            screen.FillRectangle(redBrush, 30, 30, 380, 200);

            if (score >= highscore)
            {
                screen.DrawString("Score: " + score.ToString(), font, new SolidBrush(Color.Yellow), 35, 35);
                screen.DrawString("Congratulations. You have the", font, new SolidBrush(Color.Yellow), 35, 35 + 38);
                screen.DrawString("Highest Score: " + score.ToString(), font, new SolidBrush(Color.Yellow), 35, 35 + 38 + 38);
                highscore = score;
            }
            else
            {
                screen.DrawString("Your Score: " + score.ToString(), font, new SolidBrush(Color.Yellow), 35, 35);
                screen.DrawString("Highest Score: " + highscore.ToString(), font, new SolidBrush(Color.Yellow), 35, 35 + 38);
                screen.DrawString("2nd Highest Score: " + highscore2.ToString(), font, new SolidBrush(Color.Yellow), 35, 35 + 38 + 38);
                screen.DrawString("3rd Highest Score: " + highscore3.ToString(), font, new SolidBrush(Color.Yellow), 35, 35 + 38 + 38 + 38);
                screen.DrawString("4th Highest Score: " + highscore4.ToString(), font, new SolidBrush(Color.Yellow), 35, 35 + 38 + 38 + 38 + 38);

                if (score > highscore2)
                {
                    highscore4 = highscore3;
                    highscore3 = highscore2;
                    highscore2 = score;
                }
                else
                {
                    if (score > highscore3)
                    {
                        highscore4 = highscore3;
                        highscore3 = score;
                    }
                    else
                    {
                        if (score > highscore4)
                        {
                            highscore4 = score;
                        }
                    }
                }
            }

            screen.Flush();

            if (!ledValue)
            {
                led.Write(GpioPinValue.High);
                ledValue = true;
            }
            else
            {
                led.Write(GpioPinValue.Low);
                ledValue = false;
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: kunmukh/EE-356
        static void Main()
        {
            var displayController = DisplayController.GetDefault();
            var font = Resource1.GetFont(Resource1.FontResources.Ariel72);

            // Enter the proper display configurationsok
            displayController.SetConfiguration(new ParallelDisplayControllerSettings
            {
                Width                    = 480,
                Height                   = 272,
                DataFormat               = DisplayDataFormat.Rgb565,
                PixelClockRate           = 20000000,
                PixelPolarity            = false,
                DataEnablePolarity       = true,
                DataEnableIsFixed        = false,
                HorizontalFrontPorch     = 2,
                HorizontalBackPorch      = 2,
                HorizontalSyncPulseWidth = 41,
                HorizontalSyncPolarity   = false,
                VerticalFrontPorch       = 2,
                VerticalBackPorch        = 2,
                VerticalSyncPulseWidth   = 10,
                VerticalSyncPolarity     = false,
            });

            displayController.Enable();

            screen = Graphics.FromHdc(displayController.Hdc);
            var GreenPen = new Pen(Color.Green);

            // Start Drawing (to memroy)
            screen.Clear(Color.Black);

            //screen.DrawEllipse(GreenPen, 10, 10, 20, 10);
            screen.DrawString("Kunal", font, new SolidBrush(Color.Yellow), 20, 20);
            screen.DrawString("Mukherjee", font, new SolidBrush(Color.Yellow), 20, 100);
            screen.DrawString("EE 356", font, new SolidBrush(Color.Blue), 20, 180);

            // Flush the memory to the display. This is a very fast operation.
            screen.Flush();
            GpioPin padUp = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.G400D.GpioPin.PA24);
            GpioPin padDown = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.G400D.GpioPin.PA4);
            GpioPin padRight = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.G400D.GpioPin.PD9);
            GpioPin padLeft = GpioController.GetDefault().OpenPin(
                GHIElectronics.TinyCLR.Pins.G400D.GpioPin.PD7);

            int locationY = 272 / 2;

            while (padUp.Read() != 0)
            {
                Thread.Sleep(100);
            }

            while (true)
            {
                if (win == 0)
                {
                    if (padUp.Read() == 0)
                    {
                        if (locationY > (0 + 5))
                        {
                            locationY -= 2;
                        }
                    }
                    else if (padDown.Read() == 0)
                    {
                        if (locationY < (272 - 20))
                        {
                            locationY += 2;
                        }
                    }

                    Thread.Sleep(33); //33
                    UpdateScreen(locationY);
                    score++;
                }
                else
                {
                    showScore();
                    score     = 1;
                    win       = 0;
                    locationY = 272 / 2;
                    initialRandom();
                    updateCavern();

                    while (padLeft.Read() != 0)
                    {
                        Thread.Sleep(100);
                    }

                    UpdateScreen(locationY);
                }
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: kunmukh/EE-356
        static void UpdateScreen(int locationY)
        {
            var blueBrush  = new SolidBrush(Color.Blue);
            var greenBrush = new SolidBrush(Color.Green);
            var font       = Resource1.GetFont(Resource1.FontResources.Ariel32);

            var redBrush    = new SolidBrush(Color.Red);
            var purpleBrush = new SolidBrush(Color.Purple);
            var tealBrush   = new SolidBrush(Color.Teal);

            screen.Clear(Color.Black);

            //
            updateCavern();

            screen.FillRectangle(redBrush, startBlock1UpX, startBlock1UpY, blockwidth, randomHeight1);
            screen.FillRectangle(redBrush, startBlock1DownX, startBlock1DownY, blockwidth, 272 - playSpace - randomHeight1);

            screen.FillRectangle(purpleBrush, startBlock2UpX, startBlock2UpY, blockwidth, randomHeight2);
            screen.FillRectangle(purpleBrush, startBlock2DownX, startBlock2DownY, blockwidth, 272 - playSpace - randomHeight2);

            screen.FillRectangle(tealBrush, startBlock3UpX, startBlock3UpY, blockwidth, randomHeight3);
            screen.FillRectangle(tealBrush, startBlock3DownX, startBlock3DownY, blockwidth, 272 - playSpace - randomHeight3);

            screen.FillRectangle(redBrush, startBlock4UpX, startBlock4UpY, blockwidth, randomHeight4);
            screen.FillRectangle(redBrush, startBlock4DownX, startBlock4DownY, blockwidth, 272 - playSpace - randomHeight4);

            screen.FillRectangle(purpleBrush, startBlock5UpX, startBlock5UpY, blockwidth, randomHeight5);
            screen.FillRectangle(purpleBrush, startBlock5DownX, startBlock5DownY, blockwidth, 272 - playSpace - randomHeight5);

            screen.FillRectangle(tealBrush, startBlock6UpX, startBlock6UpY, blockwidth, randomHeight6);
            screen.FillRectangle(tealBrush, startBlock6DownX, startBlock6UpY + randomHeight6 + playSpace, blockwidth, 272 - playSpace - randomHeight6);

            //*


            screen.FillRectangle(redBrush, startBlock1UpX - 480, startBlock1UpY, blockwidth, randomHeight7);
            screen.FillRectangle(redBrush, startBlock1DownX - 480, startBlock1UpY + randomHeight7 + playSpace, blockwidth, 272 - playSpace - randomHeight7);

            screen.FillRectangle(purpleBrush, startBlock2UpX - 480, startBlock2UpY, blockwidth, randomHeight8);
            screen.FillRectangle(purpleBrush, startBlock2DownX - 480, startBlock2UpY + randomHeight8 + playSpace, blockwidth, 272 - playSpace - randomHeight8);

            screen.FillRectangle(tealBrush, startBlock3UpX - 480, startBlock3UpY, blockwidth, randomHeight9);
            screen.FillRectangle(tealBrush, startBlock3DownX - 480, startBlock3UpY + randomHeight9 + playSpace, blockwidth, 272 - playSpace - randomHeight9);

            screen.FillRectangle(redBrush, startBlock4UpX - 480, startBlock4UpY, blockwidth, randomHeight10);
            screen.FillRectangle(redBrush, startBlock4DownX - 480, startBlock4UpY + randomHeight10 + playSpace, blockwidth, 272 - playSpace - randomHeight10);

            screen.FillRectangle(purpleBrush, startBlock5UpX - 480, startBlock5UpY, blockwidth, randomHeight11);
            screen.FillRectangle(purpleBrush, startBlock5DownX - 480, startBlock5UpY + randomHeight11 + playSpace, blockwidth, 272 - playSpace - randomHeight11);

            screen.FillRectangle(tealBrush, startBlock6UpX - 480, startBlock6UpY, blockwidth, randomHeight12);
            screen.FillRectangle(tealBrush, startBlock6DownX - 480, startBlock6UpY + randomHeight12 + playSpace, blockwidth, 272 - playSpace - randomHeight12);

            //

            locY = locationY;
            //screen.FillRectangle(blueBrush, locationX, locationY, 15, 15);

            screen.FillRectangle(blueBrush, locationX, locationY, 25, 5);
            screen.FillRectangle(blueBrush, locationX + 5, locationY - 5, 5, 15);
            screen.FillRectangle(blueBrush, locationX + 15, locationY - 2, 5, 9);

            screen.FillRectangle(greenBrush, 200, 200, 150, 32);
            screen.DrawString("Score " + score.ToString(), font, new SolidBrush(Color.Yellow), 200, 200);
            screen.Flush();
            isWin();

            if (!ledValue)
            {
                led.Write(GpioPinValue.High);
                ledValue = true;
            }
            else
            {
                led.Write(GpioPinValue.Low);
                ledValue = false;
            }
        }