private void DrawGameMenu() { bool proceed = false; int cursorStart = 250; int cursorOffset = 100; int cursorPosition = cursorStart; while (!proceed) { canvas = new Rectangle(0, 0, consoleGraphics.ClientWidth, consoleGraphics.ClientHeight, (uint)Colors.GreyAlpha); canvas.Render(consoleGraphics); consoleGraphics.DrawString("GAME SETTINGS", "Consolas", (uint)Colors.Yellow, 150, 70, 50); consoleGraphics.DrawString($"LEVEL: {Settings.LevelSelector}", "Consolas", (uint)Colors.Yellow, 240, cursorStart, 30); consoleGraphics.DrawString($"SPEED: {Settings.SpeedSelector}", "Consolas", (uint)Colors.Yellow, 240, cursorStart + cursorOffset, 30); consoleGraphics.DrawString($"SHAPES: {Settings.ShapeSetName}", "Consolas", (uint)Colors.Yellow, 240, cursorStart + cursorOffset * 2, 30); PlaceCursor(); consoleGraphics.DrawString("PRESS UP OR DOWN TO NAVIGATE", "Consolas", (uint)Colors.Yellow, 150, 620, 20); consoleGraphics.DrawString("PRESS ENTER TO CHANGE SETTINGS", "Consolas", (uint)Colors.Yellow, 150, 650, 20); consoleGraphics.DrawString("PRESS SPACE TO START GAME", "Consolas", (uint)Colors.Yellow, 150, 680, 20); consoleGraphics.DrawString("PRESS ESC TO EXIT GAME", "Consolas", (uint)Colors.Yellow, 150, 710, 20); consoleGraphics.FlipPages(); if (Input.IsKeyDown(Keys.SPACE)) { proceed = true; } if (Input.IsKeyDown(Keys.DOWN)) { MoveCursorDown(); } if (Input.IsKeyDown(Keys.UP)) { MoveCursorUp(); } if (Input.IsKeyDown(Keys.RETURN)) { ChangeSettings(); } if (Input.IsKeyDown(Keys.ESCAPE)) { Environment.Exit(0); } } void PlaceCursor() { consoleGraphics.DrawString(">>", "Consolas", (uint)Colors.Yellow, 150, cursorPosition, 30); } void MoveCursorDown() { cursorPosition = cursorPosition >= cursorStart + (cursorOffset * 2) ? cursorPosition = cursorStart : cursorPosition + cursorOffset; Utility.SleepLong(); } void MoveCursorUp() { cursorPosition = cursorPosition <= cursorStart ? cursorPosition = cursorStart + (cursorOffset * 2) : cursorPosition - cursorOffset; Utility.SleepLong(); } void ChangeSettings() { if (cursorPosition == cursorStart + (cursorOffset * 0)) { if (Settings.LevelSelector >= 12) { Settings.LevelSelector = 0; } else { Settings.LevelSelector++; } } else if (cursorPosition == cursorStart + (cursorOffset * 1)) { if (Settings.SpeedSelector >= 9) { Settings.SpeedSelector = 0; } else { Settings.SpeedSelector++; } } else if (cursorPosition == cursorStart + (cursorOffset * 2)) { if (Settings.ShapeSet == ShapeSets.Nightmare) { Settings.ShapeSet = ShapeSets.TooYoungToDie; } else if (Settings.ShapeSet == ShapeSets.TooYoungToDie) { Settings.ShapeSet = ShapeSets.NotTooRough; } else if (Settings.ShapeSet == ShapeSets.NotTooRough) { Settings.ShapeSet = ShapeSets.HurtMePlenty; } else if (Settings.ShapeSet == ShapeSets.HurtMePlenty) { Settings.ShapeSet = ShapeSets.UltraViolence; } else if (Settings.ShapeSet == ShapeSets.UltraViolence) { Settings.ShapeSet = ShapeSets.Nightmare; } } Utility.SleepMiddle(); } DrawBlackCanvas(); }
public override bool Update(Field Field, GameEngine engine) { if (Field.Rectangles[y / size + 1, x / size].CelsValue != 1 && Field.Rectangles[y / size + 1, x / size + 1].CelsValue != 1) { if (y != graphics.ClientHeight - size * 2 && Field.Rectangles[y / size + 2, x / size].CelsValue != 1 && Field.Rectangles[y / size + 2, x / size + 1].CelsValue != 1) { if (Input.IsKeyDown(Keys.LEFT)) { if (x > 0 && Field.Rectangles[y / size, x / size - 1].CelsValue == 0 && Field.Rectangles[y / size + 1, x / size - 1].CelsValue == 0) { x -= size; } } else if (Input.IsKeyDown(Keys.RIGHT)) { if (x < graphics.ClientWidth - size * 2 - 5 && Field.Rectangles[y / size, x / size + 2].CelsValue == 0 && Field.Rectangles[y / size + 1, x / size + 2].CelsValue == 0) { x += size; } } if (Input.IsKeyDown(Keys.DOWN) || iter % 10 == 0) { if (y <= graphics.ClientHeight - size * 3) { if (Field.Rectangles[y / size + 2, x / size].CelsValue == 0 && Field.Rectangles[y / size + 2, x / size + 1].CelsValue == 0) { y += size; } } else { if (y < graphics.ClientHeight - size) { y += size; } } } iter++; } else { int fieldX = x; int fieldY = y; for (int i = 0; i < bigRectangl.GetLength(0); i++) { for (int j = 0; j < bigRectangl.GetLength(1); j++) { Field.Rectangles[fieldY / size, fieldX / size].Color = color; Field.Rectangles[fieldY / size, fieldX / size].CelsValue = bigRectangl[i, j]; fieldX += size; } fieldY += size; fieldX = x; } x = startX; y = startY; } return(endGame = true); } else { return(endGame = false); } }