Original Post
I'm making a game called collapse where a line of blocks fills up before it is placed underneath a stick of blocks. You must click on three blocks or more in a row to remove them. Anyways the problem I'm having is that I want to have levels and the levels will dictate how fast a random colour block will be added to the next line of blocks to be placed under the stack of blocks in the game surface. Here is the class I'm currently testing
The problem is not that it doesn't keep track of the milliseconds properly its just that as soon as all 10 are done then it puts all 10 of the numbers on the screen at once. Is this because putting text on the screen takes along time and so it doesn't get done until everything is done? Am I going to run into problems with this method when I'm placing frames on the screen? Thanks in advance.
EDIT: Fixed source
[edited by - Space_Panda on January 9, 2003 6:32:05 PM]
class Next_Line
{
public:
Line_of_Blocks beginLine;
DWORD difference;
DWORD keepTrack;
int block_count;
Next_Line(void);
~Next_Line(void);
void Place_Block(int i, int colour);
int Next_Block_Time(int level);
Line_of_Blocks Get_New_Line();
void Destroy_Passed_Line();
};
// END OF CLASS DEFINITION
//THE FOLLOWING IS A THE NEXT_BLOCK_TIME FUNCTION
int Next_Line::Next_Block_Time(int level)
{
static DWORD lastTickCount = timeGetTime();
DWORD thisTickCount;
thisTickCount = timeGetTime();
Next_Line::difference = thisTickCount - lastTickCount;
lastTickCount = thisTickCount;
Next_Line::keepTrack += Next_Line::difference;
if(Next_Line::keepTrack >= 100/level)
{
Next_Line::keepTrack = 0;
return(1);
}
else
return(0);
}
// END OF METHOD
// AND NOW THE CALL IN MAIN TO TEST THE CLASS METHODS
int _tmain(int argc, _TCHAR* argv[])
{
Next_Line new_line;
int count = 0;
while(count < 10)
{
if(new_line.Next_Block_Time(1))
{
count ++;
cout << count;
}
}
return 0;
}