Archived

This topic is now archived and is closed to further replies.

2DamnFunky

My game and windowed mode

Recommended Posts

2DamnFunky    122
ok ive been following the tutorial on the gamedev site entitled "Moving from Exclusive Mode to Windowed Mode in DirectX PART ONE" So far my game is now viewed in a window on my desktop and the program does NOT use any MULTI THREADING techniques as described in part two. Now ive been developing really simple graphic routines using the old directdraw7 interfaces. Now when i use functions that are quite intensive i.e collision detection and multiple sprite rendering the game runs just fine. Smooth. So no problems there. However when i replace these functions with much simpler ones that are less intensive the game seems to seize up. The sprite will Jerkily move accross the screen. Ive measured the time differences between frames for both types of functions and the less intensive ones are averaging about 0-2ms a call and the more intensive are around 20ms-30ms. So why is this the case, surely it should be the other way round. Heres a simple function in all its glory: void FreeFallObject(Object *object, float floorX, float floorY) { static float velY = object->initVelX; static float velX = object->initVelY; float timeBetweenFrames = 0.0f; //the time between successive frames in SECONDS timeBetweenFrames = (float)(Game.diffTickCount/1000.0f); velY += (float)(object->accelY * timeBetweenFrames); velX += (float)(object->accelX * timeBetweenFrames); object->currX += (float)(velX * timeBetweenFrames); object->currY += (float)(velY * timeBetweenFrames); //check if we have hit the floor yet if (object->currY >= floorY) { object->currY = floorY; //make sure it doesnt go past / through the floor //adjust the velocity to take into the coeff of restitution velY = -(object->coeffRestitutionY) * velY; } } To measure the speed i simply use a simple GDI call to print the global variable holding the frame difference in ms to the screen. Whats interesting is that actually using this call will add a slight overhead (presumably) to the processing but will stop the game from seizing up.However, removing it causes it to act jerkily. It seems counter intuitive for the game to seize up when its running as fast as it possibly can. Apart from this function call there is only the message handler and all thats pertinent to operating a windows application. Is this something to do with operating under the windows environment and having to ''share'' resources. Again no multi threading is being used..would that help? And i noticed the use of the call sleep(0) in one tutorial regarding threading...im not using that...is that it? Any help would be appreciated. Regards 2DamnFunky

Share this post


Link to post
Share on other sites