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?
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 #.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
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.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
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...
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 (" "); } }
Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)
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?