Sign in to follow this  
wicked357

Making maze game in MASM (Assembly)

Recommended Posts

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!

Share this post


Link to post
Share on other sites
I am making this entirely ASM since that is what I am working on learning I am trying to stay away from using any C/C++ implementations. I was thinking about a 20x20 character size maze with 1 path through, and I have no idea where to really start I already made a maze on paper it really isn't a great maze but that is ok I just want to try and make something semi interesting to me while I learn this stuff, I would really hate to back away from it, I have been doing C++ for awhile and thought I would in my spare time try and learn some ASM and got a book. Well I am sick of the dumb examples in the book and would like to take a different approach to it. Any ideas on how I should start this, or tutorials out there that I could learn from and get a better understanding.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks for that ill try and find a program that will translate it, I think google has a document translator not sure, anyways I got my menu made that I liked for now, I might have to change it depending on how the maze goes itself. For my maze it is going to be static so I don't want a to generate like a seed map, this is just for a learning process so I want to avoid anything to complicated that is why I choose a 20x20 map size for now. So for now I guess what I need to know and maybe ill see a good example in the document I haven't looked at yet, is how to write all the walls (Characters) to the screen in an efficient way without having 100's of lines of code to display it, maybe like using a struct or an array, but I am not sure how to go about it.

Share this post


Link to post
Share on other sites
ASM is very much like non-object oriented C code (or the opposite way). I once had to write John Conway's Game of Life in ASM. Using the console in Win32 ASM proved mind numbing and I decided to use OpenGL for display.

I used these tutorials -> they are in Russian BUT the code builds step by step and is very similiar to OpenGL in C http://www.pouet.net/topic.php?which=1609.

You could probably steal most of the code and have a conditional jump to draw rectangles in the main program loop.

Share this post


Link to post
Share on other sites
thanks for the site ill check it out, so far I have my whole program written except the game itself I created a menu system that takes name, has an option choice that allows you to choose your timer for difficulty and help screen that tells you how to play the game. What I need to do know is,

1.Draw the maze
2.Make the game accept user input from keyboard for the arrow keys
3.Figure out how to create a timer that updates every second
4.Make some sort of collision between the maze walls and user character

So far I know that I can use a macro written for gotoxy to place a solid square

if looks like this,


mGotoxy 0,0 ; puts cursor on x, y position
mov al, 0DBh ;puts a solid square in to the al register
call writechar ;writes the character from al to console



I just don't know how to make that draw across the screen and down below it. Maybe that isn't even a good way or not a possible way to do it, I am just not sure.

Share this post


Link to post
Share on other sites
Ok so I know this isn't completely right but for now I am mainly trying to work on movement so I drew a hypothetical maze using a macro I have made for writing to the console. I can't seem to get it to work right and my lack of knowledge is making it hard for me to see the problem here, any help?

Right now the loop ends for somereason even though the if statement isn't true, and because of that my character isn't moving, I know where it is at right now it should leave a trail of _char until I create a cleanup method as well. For now I just wanna get the loop working right and the _char to move around which is a square 0DBh is the hex for it.

Here is my main code and variables:

_x BYTE ? ;x location
_y BYTE ? ;y location
_char BYTE 0DBh
_move DWORD ?




;*****************GAME LOOP*********************
DRAW:
mWrite "#################X##"
mWrite "################ ##"
mWrite "################ ###"
mWrite "########### ###"
mWrite "########### ########"
mWrite "########### ### ##"
mWrite "########### ### ####"
mWrite "########### ####"
mWrite "############ #######"
mWrite "#### #######"
mWrite "############ #######"
mWrite "############ #######"
mWrite "############ #######"
mWrite "############ #######"
mWrite "####### #######"
mWrite "####### ############"
mWrite " ############"
mWrite "####### ############"
mWrite "####### ####"
mWrite "####################"

mov _x, 0
mov _y,16
JMP GAME
GAME:
call readstring
mov _move, eax
call writeint
mGotoxy _x, _y
mov al, _char
call writechar
.if _move == 119 ; UP
dec _y
.endif
.if _move == 115 ; DOWN
inc _y
.endif
.if _move == 97 ; LEFT
dec _x
.endif
.if _move == 100 ; RIGHT
inc _x
.endif

.if _x == 1 || _y == 1
JMP OVER
.endif

JMP GAME

;*****************END GAME**********************
OVER:

exit




EDIT: BTW I cannot use interrupts, so please don't suggest it. Vista doesn't allow that kind of access to the bios.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this