From baa8b687ef51e4a961692cc5ebe5acc1aa6d2e83 Mon Sep 17 00:00:00 2001 From: PowerfulShuffle <florisvandezande85@gmail.com> Date: Wed, 8 Jan 2025 14:57:49 +0100 Subject: [PATCH] update - improved minesweeper/sudoku text alignment - changed minesweeper/maze description --- PuzzlePlayer/Maze.cs | 4 +-- PuzzlePlayer/Minesweeper.cs | 25 ++++++++++---- PuzzlePlayer/Properties/Settings.Designer.cs | 2 +- PuzzlePlayer/PuzzlePlayer.cs | 2 +- PuzzlePlayer/Sudoku.cs | 36 +++++++------------- 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/PuzzlePlayer/Maze.cs b/PuzzlePlayer/Maze.cs index e533f65..16961d8 100644 --- a/PuzzlePlayer/Maze.cs +++ b/PuzzlePlayer/Maze.cs @@ -40,14 +40,14 @@ namespace PuzzlePlayer_Namespace Point playerPos; List<Point> shortestPath; - public Maze(int sizeX = 6, int sizeY = 4) + public Maze(int sizeX = 16, int sizeY = 12) { drawFactor = 1; // init all 2D array's Reset(sizeX, sizeY); lastGeneratedBoard = GetClearBoard(sizeX, sizeY); - description = "Maze is played on a grid containing walls. You need to navigate through the maze until you reach the end. Use the arrow keys or WASD to move the blue square to the end goal"; + description = "Maze is played on a grid containing walls. You have to navigate through the maze until you reach the end. Use the arrow keys or WASD to move the blue square to the end!"; } private void Reset(int sizeX, int sizeY) diff --git a/PuzzlePlayer/Minesweeper.cs b/PuzzlePlayer/Minesweeper.cs index 2e56064..d417ce5 100644 --- a/PuzzlePlayer/Minesweeper.cs +++ b/PuzzlePlayer/Minesweeper.cs @@ -16,7 +16,7 @@ namespace PuzzlePlayer_Namespace private static Random random = new Random(); private bool[,] mineState; private bool isFirstClick; - public Minesweeper(int width = 6, int height = 6) + public Minesweeper(int width = 16, int height = 12) { if (width <= 1 || height <= 1) throw new ArgumentOutOfRangeException(); // breedte 1 mag niet door optimisatie bij Reveal() boardState = GetClearBoard(width, height); @@ -24,7 +24,7 @@ namespace PuzzlePlayer_Namespace mineState = new bool[width, height]; isFirstClick = false; - description = "zoek het uit"; + description = "In Minesweeper, the number of a tile indicates the amount of adjacent mines.\r\n◠You can place flags on suspected mines with right-click\r\n◠Unlike the classic version of minesweeper, there is not a set number of mines and you will survive after clicking on a mine, at the cost of gaining less points \r\n◠The first click is always safe!"; drawFactor = 1; } @@ -71,7 +71,7 @@ namespace PuzzlePlayer_Namespace case -2: gr.DrawString("⚑", new Font("Verdana", stringsize), - Brushes.Black, + Brushes.DarkRed, (int)(r.X + ((double)i + 0.5) * tilesize.Width), (int)(r.Y + ((double)j + 0.5) * tilesize.Height), stringFormat); @@ -81,13 +81,26 @@ namespace PuzzlePlayer_Namespace gr.DrawString("✸", new Font("Verdana", stringsize), Brushes.Black, - (int)(r.X + ((double)i + 0.5) * tilesize.Width), - (int)(r.Y + ((double)j + 0.5) * tilesize.Height), + (int)(r.X + ((double)i + 0.52) * tilesize.Width), + (int)(r.Y + ((double)j + 0.54) * tilesize.Height), stringFormat); break; } } + /*gr.DrawLine(Pens.Red, + (int)(r.X + ((double)i + 0.5) * tilesize.Width), + (int)(r.Y + ((double)j + 0.0) * tilesize.Height), + (int)(r.X + ((double)i + 0.5) * tilesize.Width), + (int)(r.Y + ((double)j + 1.0) * tilesize.Height) + ); + gr.DrawLine(Pens.Red, + (int)(r.X + ((double)i + 0.0) * tilesize.Width), + (int)(r.Y + ((double)j + 0.5) * tilesize.Height), + (int)(r.X + ((double)i + 1.0) * tilesize.Width), + (int)(r.Y + ((double)j + 0.5) * tilesize.Height) + );*/ + gr.DrawRectangle(Pens.DarkGray, r.X + i * tilesize.Width, r.Y + j * tilesize.Height, @@ -128,7 +141,7 @@ namespace PuzzlePlayer_Namespace } return false; - bool Reveal(Point p, bool ForceOpen) + bool Reveal(Point p, bool ForceOpen) //just set ForceOpen to false when using { if (ForceOpen && boardState[p.X, p.Y] == -2) { boardState[p.X, p.Y] = emptySpace; Reveal(p, false); } if (boardState[p.X, p.Y] != emptySpace) return false; diff --git a/PuzzlePlayer/Properties/Settings.Designer.cs b/PuzzlePlayer/Properties/Settings.Designer.cs index c36b667..ae100a0 100644 --- a/PuzzlePlayer/Properties/Settings.Designer.cs +++ b/PuzzlePlayer/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace PuzzlePlayer_Namespace.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/PuzzlePlayer/PuzzlePlayer.cs b/PuzzlePlayer/PuzzlePlayer.cs index add7f23..fb28440 100644 --- a/PuzzlePlayer/PuzzlePlayer.cs +++ b/PuzzlePlayer/PuzzlePlayer.cs @@ -10,7 +10,7 @@ namespace PuzzlePlayer_Namespace { internal static void Main(string[] args) { - Application.Run(new PuzzleForm(new Minesweeper())); + Application.Run(new PuzzleForm(new Sudoku())); } } diff --git a/PuzzlePlayer/Sudoku.cs b/PuzzlePlayer/Sudoku.cs index ebfb05b..076fa3f 100644 --- a/PuzzlePlayer/Sudoku.cs +++ b/PuzzlePlayer/Sudoku.cs @@ -15,7 +15,7 @@ namespace PuzzlePlayer_Namespace private static int boardLength; private static int rootBoardLength; private static Random random = new Random(); - public Sudoku(int boardSize = 4) + public Sudoku(int boardSize = 16) { boardState = GetClearBoard(boardSize, boardSize); lastGeneratedBoard = GetClearBoard(boardSize, boardSize); @@ -35,44 +35,32 @@ namespace PuzzlePlayer_Namespace }; Size tilesize = new Size(r.Width / boardState.GetLength(0), r.Height / boardState.GetLength(1)); Pen border = new Pen(Color.Black, 2); + Brush textcolor; gr.FillRectangle(Brushes.Beige, r.X, r.Y, tilesize.Width * boardState.GetLength(0), tilesize.Height * boardState.GetLength(1)); for (int i = 0; i < boardState.GetLength(0); i++) { for (int j = 0; j < boardState.GetLength(1); j++) { - gr.DrawRectangle(Pens.LightGray, r.X + i * tilesize.Width, r.Y + j * tilesize.Height, tilesize.Width, tilesize.Height); - if (boardState[i,j] != -1) + if (boardState[i,j] != emptySpace) { - if (lastGeneratedBoard[i, j] != Board.emptySpace) - { - gr.DrawString( - (boardState[i, j]).ToString(), - new Font("Arial", tilesize.Width / 2), - Brushes.Black, - (int)(r.X + (i + 0.27) * tilesize.Width + tilesize.Width / 4), - (int)(r.Y + (j + 0.33) * tilesize.Height + tilesize.Height / 4), - format); - } - else - { - gr.DrawString( - (boardState[i, j]).ToString(), - new Font("Arial", tilesize.Width / 2), - Brushes.DarkBlue, - (int)(r.X + (i + 0.27) * tilesize.Width + tilesize.Width / 4), - (int)(r.Y + (j + 0.33) * tilesize.Height + tilesize.Height / 4), - format); - } + if (lastGeneratedBoard[i, j] == Board.emptySpace) textcolor = Brushes.DarkBlue; else textcolor = Brushes.Black; + gr.DrawString( + (boardState[i, j]).ToString(), + new Font("Arial", tilesize.Width / 2), + textcolor, + (int)(r.X + (i + 0.52) * tilesize.Width), + (int)(r.Y + (j + 0.54) * tilesize.Height), + format); } } } - for (int i = 1; i < Math.Sqrt(boardState.GetLength(0)); i++) + for (int i = 1; i < Math.Sqrt(boardState.GetLength(0)); i++) //draws box lines { gr.DrawLine(Pens.Black, r.X + i * (int)Math.Sqrt((double)boardState.GetLength(0)) * tilesize.Width, -- GitLab