-
wait(); type of thing
hello, im making pacman in ascii console
and, i have to load levels; and for collision detecting, i have each "X" [a wall sector] have a spot in walls.wx[3] and walls.wy[3];
Well, when I make it draw the map, and declare all the walls [theres 52 by the 5th line, 25 lines], it completely crashes.
So, I'm asking, how can you make a loader thing, so it can declare all the variables? I mean, to make the loader, I have to have a wait(); function that pauses for like a second or two before loading the next set of variables
in easy ways to understand: how do i pause it for a time limit?
-
Not exactly sure why you need to pause...but look in to the Sleep function.
Sleep(<num milliseconds>);
example:
Sleep(1000);
will halt your program for 1 second.
-
I need it to pause, because, if i just declare them all at once it completely crashes.
And plus, this is the easiest way for me :D
edit:
this is what im taliking about
the function is
Code:
void dec_w( int nvalue, int xvalue, int yvalue )
where nvalue is the id number, xvalue is x coordinate, and yvalue is y coordinate
and then you got the problem part that crashes it
Code:
//DRAW ACTUAL LEVEL
gotoxy(11,2);
cout<<"X X X";
dec_w(0,23,2);
gotoxy(11,3);
cout<<"X XXX XXXXX X XXXXX XXX X";
dec_w(1,13,3);
dec_w(2,14,3);
dec_w(3,15,3);
dec_w(4,17,3);
dec_w(5,18,3);
dec_w(6,19,3);
dec_w(7,20,3);
dec_w(8,21,3);
dec_w(9,23,3);
dec_w(10,25,3);
dec_w(11,26,3);
dec_w(12,27,3);
dec_w(13,28,3);
dec_w(14,29,3);
dec_w(15,31,3);
dec_w(16,32,3);
dec_w(17,33,3);
gotoxy(40,12);
system("PAUSE");
gotoxy(11,4);
cout<<"X XXX XXXXX X XXXXX XXX X";
dec_w(18,13,4);
dec_w(19,14,4);
dec_w(20,15,4);
dec_w(21,17,4);
dec_w(22,18,4);
dec_w(23,19,4);
dec_w(24,20,4);
dec_w(25,21,4);
dec_w(26,23,4);
dec_w(27,25,4);
dec_w(28,26,4);
dec_w(29,27,4);
dec_w(30,28,4);
dec_w(31,29,4);
dec_w(32,31,4);
dec_w(33,32,4);
dec_w(34,33,4);
gotoxy(40,12);
system("PAUSE");
gotoxy(11,5);
cout<<"X XXX XXXXX X XXXXX XXX X";
dec_w(35,13,5);
dec_w(37,14,5);
dec_w(38,15,5);
dec_w(39,17,5);
dec_w(40,18,5);
dec_w(41,19,5);
dec_w(42,20,5);
dec_w(43,21,5);
dec_w(44,23,5);
dec_w(45,25,5);
dec_w(46,26,5);
dec_w(47,27,5);
dec_w(48,28,5);
dec_w(49,29,5);
dec_w(50,31,5);
dec_w(51,32,5);
dec_w(52,33,5);
-
Ok, sleep(); is under what header?
-
I'm pretty sure it's in windows.h
What exactly are you declaring and what does the function do? You shouldn't ever experience the problem of "declaring things too fast" that's just kinda absurd. I've honestly never experienced that sort of thing in any project I've ever made before.
-
Yeah, your instructions are executed in sequence, with the next one waiting until the current one finishes (at least without multi-threading, but that technique you probably won't get to for a little while). The crash is due to something else.
-
a) All those function calls could be stuck in loops.
b) What does dec_w() do, i.e. what's its purpose and show us the code.
-
I used dec_w(); for collision detection
Code:
//Declare where the walls are
void dec_w( int nvalue, int xvalue, int yvalue ) {
walls[nvalue].wx = xvalue;
walls[nvalue].wy = yvalue;
numwalls++;
gotoxy(50,12);
textcolor(3);
cout<<"Loading Walls: "<<numwalls<<"/250";
}
kind of like a -- uh, mySQL database.
-
Are you dynamically creating 'walls'? And are you sure that walls is an array of size 53 at least?