Getting my game loop to pause

I'm working on making a Simon game in Allegro. I'm trying to get the pattern to show on the screen in a constant rhythm (I want the color of the button to change for 3 seconds, then change back, then after three seconds change again and so on). To do this I'm trying to implement a sleep function inside the loop that shows the pattern (for test purposes my pattern only consists of 5 elements right now). This pattern showing loop is nested inside my game loop. Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

#include "base_game_entity.h"
#include <allegro>

int main(){

    initialize(); //this contains all the graphics setup and keyboard install
    int i = 0; //this will be the while loop counter

    while(!key[KEY_ESC]){
        
        i = 5

        while(i > 0){

            //I'm only using the console to test the sleep function for now

            cout << i << endl;

            Sleep(3000);

            i--;

        }
        

    }

}
END_OF_MAIN()

//Here is my sleep function
//I included time.h in base_game_entity.h already which is why it isn't here
void sleep(clock_t wait)
 {
 clock_t goal;
 goal = wait + clock();
 while( goal > clock());
 }
 


This code compiles but the console just writes out the 5 numbers instantly instead of waiting. Any suggestions?
This code does not compile. Check line 12 carefully.
Last edited on
Ok I argee with, L B. There is a compiling error.
Last edited on
Okay that was a mistake I made because I had to type everything in from my memory. I don't have the code on hand (I'm in class and I forgot my laptop at home). I just arrived home from a trip and this was the first chance I had to ask the question, so I figured I'd just ask already that way when I get home I can try to fix the issue.
Topic archived. No new replies allowed.