Skip to main content
gamedev.net
🔒 Locked

Finished

Started by popcorn Aug 9, 2007 at 9:06 PM 4 replies 2.3k views
Original Post
popcorn
popcorn
Not sure if this warrents a thread on its own but yep I've finished the project, trying to draw the maze out proved to be more difficult than I thought and I feel like I was just hacking code out in a desperate attempt to get something working. I was literally writing code, running the program, getting an index out of bounds exception then back to writing code and repeating the whole cycle again. It was such a relief when I finally ran the code and it produced a maze that looked right. Anyway I was going to post my full code on the other thread but I feel I need to refactor the code a bit before posting and at the moment I don't really feel like touching the code in case I break something. This is how my code for drawing the maze ended up:

//draw the maze
                
                int r = 0;//room we're in
                int row = 0;
                
                string top = new string('_', columns + (columns - 1));
                top = " " + top;

                Console.WriteLine(top);

                while (r < numRooms - 1)
                {
                    Console.Write("|");
                    for (int i = 0; i < columns; i++)
                    {
                        if (i == columns - 1 && r < numRooms -1)
                        {
                            int sWall = r + (columns - 1) * (row + 1);
                            if (wallArray[sWall].isWallUp)
                                Console.Write("_");
                            else
                                Console.Write(" ");

                            Console.Write("|");
                            r++;
                            row++;
                        }
                        else if (r == numRooms - 1)
                        {
                            Console.Write("_|");
                        }
                        else if (row == rows - 1 && r < numRooms - 1)
                        {
                            Console.Write("_");
                            int eWall = r + (columns - 1) * row;
                            if (wallArray[eWall].isWallUp)
                                Console.Write("|");
                            else
                                Console.Write("_");

                            r++;
                        }
                        else
                        {
                            int sWall = r + (columns - 1) * (row + 1);
                            int eWall = r + (columns - 1) * row;

                            if (wallArray[sWall].isWallUp)
                                Console.Write("_");
                            else
                                Console.Write(" ");

                            if (wallArray[eWall].isWallUp)
                                Console.Write("|");
                            else
                                Console.Write(" ");

                            r++;
                        }
                    }
                    Console.WriteLine();
                }

How do you post pictures on threads?
How about them apples?
Gyna
Gyna
Only the original poster and moderators can edit posts :)

Edit: ah.. right you are!

[Edited by - Gyna on August 10, 2007 12:53:22 PM]
JWalsh
JWalsh
Quote:
Original post by Gyna
Only the original poster and moderators can edit posts :)


Not true. Anyone can edit. Only the original poster and the moderators can save the edit, however.

Cheers!
SiCrane
SiCrane
You have to be logged in, though. If you aren't logged in, you'll get a permission denied message.
popcorn
popcorn
Image is here

Actually I noticed there was something not right about the maze when I looked in that picture, I'm printing a space instead of an _ character when the | wall is not up. Should be simple enough to fix.

[Edited by - popcorn on August 10, 2007 8:20:00 PM]
How about them apples?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.