I know how to use gotoxy, but how might I use that to create a wall. Heres the scenario: I've created a program where you move an asterisk around the screen. Well I want to turn that in to a maze program. How might I go about making walls?
Printable View
I know how to use gotoxy, but how might I use that to create a wall. Heres the scenario: I've created a program where you move an asterisk around the screen. Well I want to turn that in to a maze program. How might I go about making walls?
you could use #.
I don't mean it like that... How would I make the wall actually stop the asterisk?
if ( asterix_current_square +1 == '#') // do whatever to stop asterix moving to square.
im bored
I tried that statement but I don't know what kind of equation can keep it from going... like an equation that can block it all together...
Nevermind I got it...
I don't mean it like that... How would I make the wall actually stop the asterisk?
Instead of #, use char 219. It's a solid block.
If your game 'arena' is an array of [80] [24] then the following will work:
Code:.
.
.
char inkey;
while (1)
{
if (kbhit ())
inkey = getch ();
if ((inkey == '6') && (arena [x + 1] [y] != 219))
{
x++;
gotoxy (x - 1, y);
printf (" ");
}
if ((inkey == '4') && (arena [x - 1] [y] != 219))
{
x--;
gotoxy (x + 1, y);
printf (" ");
}
if ((inkey == '2') && (arena [x] [y + 1] != 219))
{
y++;
gotoxy (x, y - 1);
printf (" ");
}
if ((inkey == '8') && (arena [x] [y - 1] != 219))
{
y--;
gotoxy (x, y + 1);
printf (" ");
}
}
Could you be a little specific to what some of the things do, I'm kind'a a newbie... could you use // to comment on what does what?