Advertisement

Problem with my tetris game (dos,13h)

Started by November 09, 2000 11:39 AM
1 comment, last by CHollman82 24 years, 2 months ago
Half the time, the game works fine. The other half of the time, the blocks will not move down until you press a key. My code is correct, Im positive of this. I think it might be a problem with dos on my machine. It''s like the program just stops running until you hit a key, then completes a couple hundred game loops, then stops until another key is pressed. The specifics of the code would be too much to post here but Ill E-mail whatever you want(its broken into subsections like collision detection, I/O, graphics, etc.) but I really don''t think it''s my code. i use Borland 5.0 and I run the program in a dos shell in Windows ME. Thanks.
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
trust me, it''s your code, not dos. Your problem comes in the fact that you need to make your key strokes independent of the movement of the block. What i think you have is the block movements within the key capture routines. What you need to do is keep things as they are, but, add a routine outside the key capturing that drops the bricks every X seconds regardless if a key is pressed or not.
Advertisement
Thats not the problem. I have a counter that counts game loops, and every like 10,000 loops the block moves down 1 pixel. Here, this will give you an example of how I do it:
---------------------------------------------------------------
int count;
int key;

START:
while(!kbhit())
{
count++;
if(count>10000)move block down 1 pixel and reset count to 0
other stuff
}
key=getch();
if(key==whatever)do something
.
.
.
goto START;
---------------------------------------------------------------
as you can see, the user input stuff is entirely independant from the block movement. I really think it is dos because half the time the game works correctly (not just when I compile but also when running the .exe without changing the code at all). The only thing it can be is an OS problem because the game performs differently at different times without the code being changed
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();

This topic is closed to new replies.

Advertisement