static void die() { if (score < 10) { try { int offsetShifter = 0; screen.Clear(Color.Black); int time = (DateTime.Now - diedSince).Seconds; while (time < 3) { if (time < 2) { screen.DrawImage(Resource2.GetBitmap(Resource2.BitmapResources.randallF1), 480 - offsetShifter, 0); screen.Flush(); offsetShifter += 30; } time = (DateTime.Now - diedSince).Seconds; Thread.Sleep(10); } } catch { return; } } return; }
static void initialScreen() { var displayController = DisplayController.GetDefault(); // Enter the proper display configurations 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); screen.Clear(Color.Black); screen.DrawImage(Resource2.GetBitmap(Resource2.BitmapResources.randall3hrs), 300, 0); screen.DrawString("Abdullahs crappy game", font2, new SolidBrush(Color.Red), 20, 40); screen.DrawString("To: ", font2, new SolidBrush(Color.Blue), 20, 20); screen.DrawString("Welcome", font2, new SolidBrush(Color.Yellow), 20, 0); screen.DrawString("Click UP to play", font2, new SolidBrush(Color.Green), 20, 100); screen.DrawString("Click DOWN to view highscores ", font2, new SolidBrush(Color.Green), 20, 120); screen.DrawString("Click RIGHT for about", font2, new SolidBrush(Color.Green), 20, 140); screen.DrawString("Click LEFT for instructions", font2, new SolidBrush(Color.Green), 20, 160); screen.Flush(); }
static void Main() { TimeSpan difference = DateTime.Now - DateTime.Now; ArrayList points = new ArrayList(); ArrayList avg = new ArrayList(); Random rnd = new Random(); Random r = new Random(); initialScreen(); DateTime start; string name; int offsetShifter; int num_remove; int num_rand; int counter; int moveCounter; bool dead; int offsetChange; double speedChange; int time; int levelIncrease; while (true) { difference = DateTime.Now - DateTime.Now; offsetShifter = 0; num_remove = 1; num_rand = 4; counter = 1; moveCounter = 0; dead = false; offsetChange = 2; speedChange = 0; x = 75; y = 125; if (again) { Debug.WriteLine("HERE"); showHighscores(); } while (true) { if (padUp.Read() == 0) { break; } else if (padDown.Read() == 0) { showHighscores(); } else if (padLeft.Read() == 0) { showInstructions(); } else if (padRight.Read() == 0) { showAbout(); } else { Thread.Sleep(100); } } name = askForName(); if (name == "") { name = "User"; } startGame(); start = DateTime.Now; for (int i = 0; i < num_rand; i++) { avg.Add(rnd.Next(272)); } for (int i = 0; i < 12; i++) { points.Add(100); } while (true) { screen.Clear(Color.Black); if (dead) { if ((DateTime.Now - diedSince).Seconds == 1) { break; } } for (int i = 0; i < 12; i++) { screen.FillRectangle(whiteBrush, i * 50 - offsetShifter, (int)points[i] - 25, boxWidth, boxHeight); } if (offsetShifter > 50) { for (int i = 0; i < num_remove; i++) { points.RemoveAt(0); points.Add(average(avg, num_rand)); avg.RemoveAt(0); avg.Add(rnd.Next(272)); } offsetShifter = 0; } if (dead) { screen.DrawImage(Resource2.GetBitmap(Resource2.BitmapResources.bird4), (int)x, (int)y); } else if (counter == 1) { screen.DrawImage(Resource2.GetBitmap(Resource2.BitmapResources.bird1), (int)x, (int)y); counter = 2; } else if (counter == 2) { screen.DrawImage(Resource2.GetBitmap(Resource2.BitmapResources.bird2), (int)x, (int)y); counter = 3; } else if (counter == 3) { screen.DrawImage(Resource2.GetBitmap(Resource2.BitmapResources.bird3), (int)x, (int)y); counter = 1; } drawWall(); difference = DateTime.Now - start; time = (int)difference.TotalSeconds + (int)difference.TotalMinutes; levelIncrease = time / 10; level = levelIncrease; offsetChange = 2 + level; speedChange = 1 + 0.25 * level; screen.DrawString(("Time Elapsed: " + time + 's'), font, blueBrush, 350, 15); screen.DrawString(("Player: " + name), font, blueBrush, 350, 0); screen.DrawString(("Level: " + level), font, blueBrush, 350, 30); offsetShifter += offsetChange; moveCounter++; if (dead) { y += 3; } else { if (padUp.Read() == 0) { y -= speedChange; } if (padDown.Read() == 0) { y += speedChange; } if (padRight.Read() == 0) { x += speedChange / 2; } if (padLeft.Read() == 0) { x -= speedChange / 2; } if (crash(points)) { dead = true; diedSince = DateTime.Now; } } screen.Flush(); } score = difference.Seconds + difference.Minutes * 60; players.Add(new Player(name, score)); die(); screen.Clear(Color.Black); screen.Flush(); again = true; points.Clear(); avg.Clear(); } }