Thread: commandline on delay or something:P

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

    commandline on delay or something:P

    Code:
    do{
    	randomize();
    	result = rand() % 15;
    
    	sleep(1);
    
       if (result == 1||result == 6||result == 7)
       {
       sleep(1);
       textattr(4 << 0); cprintf("The enemy strikes you with his pow\r\n\n");
       health-=4;
       cout << "fitte2 : " << health << " : fitte : " << enemyhp << "\n\n";
       if (health<=0) {dead();}
       continue;
       }
    
       else if (result == 2||result == 3||result == 4||result == 5||result == 8||result == 9)
       {
       sleep(1);
       textattr(2 << 0); cprintf("You hit the enemy hard in its chest\r\n\n");
       enemyhp-= 4;
       cout << "fitte2 : " << health << " : fitte : " << enemyhp << "\n\n";
       continue;
       }
    
       else {textattr(3 << 0); cprintf("you dodge enemies blow!\r\n\n");
       cout << "fitte2 : " << health << " : fitte : " << enemyhp << "\n\n";
    
       }
    while (enemyhp > 0);
    }
    ok.. what I need to know is how I can make a comand line each time the health and enemy health display's, but not so that you need to freeze the program, like the delay and stuff goes on. is this possible?
    Last edited by boozy; 11-03-2004 at 09:30 AM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Try the FAQ

    *Edit: if this wasnt what you meant im sorry, I might be a little stupid today.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    On an aside, you shouldn't be calling randomize inside your loop. You only need to call that one time in your entire program.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    25
    Well, if I call randomize outside the loop, you will dodge, hit or get hit all the time. the fight would have no effect:P if this is what you ment. ok.. what I ment was can I like have a comandline open for writing like 1-> sec? like this (makeing up my own commands to make an example)

    Code:
    {
    cout << "you have 3 seconds to answer!\n;
    time(3) {cin.get >> question1;}
                  if (queston1 == yes) {point++; continue;}
                  else {cout << "Wrong!"; fault++;}
    }
    if you understand what Im after more now:P thanks.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    No you won't. You call randomize only one time. You then call rand whenever you need a new random number.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Regarding delay in the connection
    By byatin in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-19-2008, 02:59 PM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  3. Networking (queuing delay, avg packet loss)
    By spoon_ in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-05-2005, 11:23 AM
  4. my own commandline parser function
    By scrappy in forum C Programming
    Replies: 7
    Last Post: 08-22-2003, 02:57 AM
  5. Delay
    By CanadianOutlaw in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 06:28 AM