Help with making a maze game with MASM

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2007
Posts: 26
Reputation: wicked357 is an unknown quantity at this point 
Solved Threads: 0
wicked357 wicked357 is offline Offline
Light Poster

Help with making a maze game with MASM

 
0
  #1
Jul 20th, 2009
I have been working with assembly for some weeks now and I want to actually take on a challenge that actually might interest me in the means to learning it better, so I thought I would try and make a maze game something simple, not sure on size yet I will have to see what my console size is and go from there, I would like some suggestions or maybe a tutorial or example I could get a good idea from and work with. Anything really would help on this, thank you!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Help with making a maze game with MASM

 
0
  #2
Jul 20th, 2009
Make a high resolution random maze. I built one of these a very long time ago and pretty cool!

Set all pixels on. Set the outer edge a different color. When you are done you'll have interlaced pixels of walls and paths. Assuming you only want one path through the maze, look at an adjacent pixel. Is there a wall? Yes? Is there a wall next to it yes, set that pixel and the pixel between the two as path? Then recursively call the maze builder passing that new adjacent pixel. So techically recursion occurs on odd row/col pixels. Even's are walls or wall opernings thus paths. If you get a no, look at the other walls, looking for adjacent pixels. This is lots of recursion up and down, but you will get one unique maze through the entire object. If pixel is a border wall, move to another pixel direction.

Once done, Cut a hole in the wall at two locations, then set a pixel mouse! Have it traverse the maze! Fun to watch!

But build it in C first! Then rewrite to assembly. Your turn around time will be faster!
Last edited by wildgoose; Jul 20th, 2009 at 3:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Help with making a maze game with MASM

 
0
  #3
Jul 21st, 2009
Found it. Built it back in 1992 for a College For Kids class I taught at Columbia College. Haven't found the source but the EXE is in the zip. Press escape key to quit.
Attached Files
File Type: zip SPELUNK.zip (7.1 KB, 8 views)
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 26
Reputation: wicked357 is an unknown quantity at this point 
Solved Threads: 0
wicked357 wicked357 is offline Offline
Light Poster

Re: Help with making a maze game with MASM

 
0
  #4
Jul 22nd, 2009
That is pretty cool, I'm really looking do something more simple to start out with. Something like maybe 20x20 characters using a color scheme and making one path to the end, a time limit and maybe a menu to start the game. Do you have any help on something this simple, or along the lines on where to start for the maze rendering part of the characters.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 26
Reputation: wicked357 is an unknown quantity at this point 
Solved Threads: 0
wicked357 wicked357 is offline Offline
Light Poster

Re: Help with making a maze game with MASM

 
0
  #5
Jul 22nd, 2009
Ok I would say this how can I display multiple characters on the screen without making a gotoxy macro then telling what character to write to the screen for every single character space. something that is easy I guess or the best way to do it.I think that is where I should probably start I would then think I would create boundaries after that and create the "character" character say a # is the character, then probably take in input from the user like using the arrows keys. But that is all in the future I just want to be able to display all the walls without typing 1000's of lines of code or even 100's because I dont know the efficient way to do it.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Help with making a maze game with MASM

 
0
  #6
Jul 22nd, 2009
What I told you is pretty simple. Remember the colored border bit!

The colored border keeps the maze builder confined.

So, make a 20x20 array, instead of full screen.
char ary[20][20];
Fill it with 'X's.
On the perimeter fill it with '@'s. Randomly start at (1...19) | 1;
x = (rand() % (20 -2)) + 1;
y = (rand() % (20 -2)) + 1;
If you encounter a '@', act like its a path so don't go there!
As you mark a path insert a ' ' (space).

You can do something like system("cls"); Then print the array to watch the maze building logic! It would be even better if you could somehow home the cursor to the top of page without erasing it!


Like I said, very simple! All you are doing is randomly probing two cells away and if you find a wall (in a prospective room/hall slot) then recursively call your function passing the new X,Y coordinate of that spot, paint your floor (' ') then probe for missing floors on all four sides of you. If none found then return from your function call. The previous recursion will then probe, and so forth. Once you hit home plate, the very first place you started and probe all its walls and find nothing to do, you're done!

The interesting thing is for more advance steps, paint the border in shapes in your array (or pixel screen). The border should be painted on odd cells, but it will keep the recursion wall builder (actually floor builder) within its confines so it will build a wall to fill the shape!

Then randomize an entry point and exit point on the border.

Then build your mouse!

Look forward to seeing your posted code! I'l help out if you hit a programming snag. Draw a five by five cell on graph paper. Walk through the logic on paper with colored pens. Understand the logic then write the code!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Help with making a maze game with MASM

 
0
  #7
Jul 22nd, 2009
This is WAY more then I should start you with but you should get the basic idea from this!

  1. char ary[ MAZE_X ][ MAZE_Y ];
  2.  
  3.  
  4. void BuildMaze( int gx, int gy )
  5. {
  6. int x, y, flg;
  7.  
  8. flg = 0x0f; // set our random wall tracker
  9. ary[ gx ][ gy ] = ' '; // Mark our floor!
  10.  
  11. while (flg) // randomizer
  12. {
  13. int r = rnd() & 3; // Randomly pick a wall
  14. int bit = 1 << r; // Bit indicating that wall
  15.  
  16. if (!(flg & bit)) // If wall already checked...
  17. continue;
  18.  
  19. flg ^= bit; // clear flag indicating that wall checked!
  20.  
  21. switch ( r ) // Now check it!
  22. {
  23. case 0: // Left
  24. if ( 0 < gx - 2 ) // Within array confines?
  25. {
  26. if (ary[ gx-2 ][ gy ] == 'X') // Room still a wall?
  27. {
  28. ary[ gx-1 ][ gy ] = ' '; // mark floor between rooms
  29. BuildMaze( gx-2, gy ); // recursion
  30. }
  31. }
  32. break;
  33.  
  34. case 1: // Up
  35. case 2: // Right
  36. case 3: // Down
  37. break;
  38. }
  39. }
Last edited by wildgoose; Jul 22nd, 2009 at 12:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 26
Reputation: wicked357 is an unknown quantity at this point 
Solved Threads: 0
wicked357 wicked357 is offline Offline
Light Poster

Re: Help with making a maze game with MASM

 
0
  #8
Jul 23rd, 2009
I was thinking more like a visible maze map with a time limit to get to the end or the game will end, so the map would be static not randomly generating it.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Help with making a maze game with MASM

 
0
  #9
Jul 23rd, 2009
It's your project. Your ultimate goal is to write this in assembly code. C code was merely the inital step to get it working and proof of algorithms.

If you examine the function I partially did, finishing it should be pretty easy!
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 26
Reputation: wicked357 is an unknown quantity at this point 
Solved Threads: 0
wicked357 wicked357 is offline Offline
Light Poster

Re: Help with making a maze game with MASM

 
0
  #10
Jul 24th, 2009
Originally Posted by wildgoose View Post
It's your project. Your ultimate goal is to write this in assembly code. C code was merely the inital step to get it working and proof of algorithms.

If you examine the function I partially did, finishing it should be pretty easy!
I think you are over estimating me... lol, I am having problems figuring out a timer system I wanna use in this game let alone drawing the maze and determining user input for moving around and collision with walls. I might have bit off more then I can chew here, but I hate to just give up... I honestly think I might quit any form of ASM learning after not being able to complete this task, and that just isn't me I think I will continue trying until the end of the week if not, I give I guess as sad as it is. Who knows maybe I won't quit, but I am getting close I can't seem to find any useful information on the web that had helped me and my book is awful for examples and understanding them.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC