Thread: wait(); type of thing

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    12

    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?

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    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.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    12
    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

    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);
    Last edited by s3abass; 10-09-2004 at 02:00 PM.

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    12
    Ok, sleep(); is under what header?

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    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.

  6. #6
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    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.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    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.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    Registered User
    Join Date
    Oct 2004
    Posts
    12
    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.

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Are you dynamically creating 'walls'? And are you sure that walls is an array of size 53 at least?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "error: incomplete type is not allowed"
    By Fahrenheit in forum C++ Programming
    Replies: 9
    Last Post: 05-10-2005, 09:52 PM
  2. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  3. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. A 'wait' type function...
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 02-10-2002, 10:48 PM