locked
C# Maze Game Help RRS feed

  • Question

  • Hi Guys! So I am creating a Maze Game in Visual Studio, coding in C#. I am moving along nicely, but I am stuck on figuring out how to make the walls of the maze solid. Currently when you reach a wall in the maze, the place marker goes right through them and deletes the blue colored walls. I am currently trying to figure how to make the walls where you can't pass through them. I have tried various statements and also tried messing with the unicode and can't seem to get anywhere. If anyone has any tips, that would be great! Thanks.

    Here is my code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Diagnostics;
    
    namespace Project4
    {
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetWindowSize(10, 10);
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.DarkBlue;
    
            //Make maze
            Console.WriteLine("");
            Console.WriteLine(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 ");
            Console.WriteLine(" \u2588\u0020\u0020\u0020\u0020\u0020\u0020\u2588 ");
            Console.WriteLine(" \u2588\u0020\u2588\u2588\u2588\u2588\u0020\u2588 ");
            Console.WriteLine(" \u2588\u0020\u2588\u0020\u0020\u0020\u0020\u2588 ");
            Console.WriteLine(" \u2588\u0020\u2588\u0020\u2588\u2588\u2588\u2588 ");
            Console.WriteLine(" \u2588\u0020\u2588\u0020\u0020\u0020\u0020\u2588 ");
            Console.WriteLine(" \u2588\u0020\u2588\u2588\u2588\u2588\u0020\u2588 ");
            Console.WriteLine(" \u2588\u0020\u0020\u0020\u0020\u0020\u0020\u2588 ");
            Console.WriteLine(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 ");
            Console.Write("");
    
            int col = 7;
            int row = 6;
            Console.SetCursorPosition(col, row);
            Console.Write("*");
            Console.SetCursorPosition(col, row);
            while (true)
            {
                ConsoleKeyInfo info = Console.ReadKey(true);
                if (info.Key == ConsoleKey.W)
                {
                    Console.Write(" ");
                    Debug.Print("W");
                    row--;
                }
                if (info.Key == ConsoleKey.Z)
                {
                    Console.Write(" ");
                    Debug.Print("Z");
                    row++;
                }
    
                if (info.Key == ConsoleKey.A)
                {
                    Console.Write(" ");
                    Debug.Print("A");
                    col--;
                }
    
                if (info.Key == ConsoleKey.S)
                {
                    Console.Write(" ");
                    Debug.Print("S");
                    col++;
                }
    
                Console.SetCursorPosition(col, row);
                Console.Write("*");
                Console.SetCursorPosition(col, row);
    
                }
            }
        }
    }

    Wednesday, October 30, 2013 2:41 AM

Answers

  • Hi dummyy,

    Here is a good sample. Maybe you can refer to it.

    http://www.c-sharpcorner.com/UploadFile/cd7c2e/creating-maze-using-C-Sharp-under-net4-5/

    In this article you will learn how to create a maze using C# using .NET 4.5. In this article you can use Labels to create maze.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Eason_H Wednesday, November 6, 2013 2:33 AM
    Thursday, October 31, 2013 6:30 AM