why is somehting so simple, so slow?

Started by
9 comments, last by kaggz 22 years, 9 months ago
I just finished making my first real directx game. its a simple tetris clone which uses directdraw and directinput. Now the game runs fine on my 1gighz machine however, when I tried it on my 300mhz laptop, it runs extremely slow. So slow in fact that its unplayable. Now Im just wondering if something so simple like tetris where all it does is display moving bmps of boxes should require such a powerful machine? Is this normal or is it just a problem with my code? btw, its running in window mode. (i dont want fullscreen)
Advertisement
Are you getting slow framerate, or the objects just seem to be moving slow?

IF the objects just seem to be moving slow possibly you need to multiply your movement by a time factor if you are not using double buffering and vsync. Time each iteration of your gameloop and multiply your movement by the amount of time each iteration takes. If you are not waiting for refresh and not using a time factor then something that is moving normal speed on your 1gig will seem a whole lot slower on a 300mhz laptop regardless of how simple it is.

Otherwise the laptop could have a really cheesy video card(can you play any other games on it?), or your game loop doing some things more than it should be doing. Possibly flawed recursion. Check your program with VTune and see if there are any odd functions that take up a large percentage of runtime.

Also make sure that you are not using something silly like DirectX 3 on your laptop and DX8 on your 1gig.

Seeya
Krippy
I''d try locking the framerate. At the beginning of your main game function, do something like

clock_time = GetTickCount();


and at the end of the function loop:

while((GetTickCount() - clock_time) < (insert desired framerate);


It would probably be easier to build these into two or three functions, but whatever.
Why lock the framerate? Why not just time the game loop and multiply the velocity of each game object by the last frame time in order to work out how far they move this frame?

Actually inserting dead time into a game run loop seems silly, considering the amount of time we spend optimising the things.
Use an IF not a WHILE to lock the framerate. That way the game loop still runs even though nothing is drawn to the screen.

Unless it''s 3D and based on time there is no choice but to lock the framerate somehow otherwise you get the above mentioned problem.

You''re code is probably very very sloppy making it run slow. Since you coded it on a 1gig you didn''t catch the problems until now.

You should learn programming on a crap computer because you get lazy otherwise even if you don''t realize it.

Ben
http://therabbithole.redback.inficad.com
I agree that there is no point to locking the framerate. If you check the time before rendering each frame and each object has a time based velocity, everything will move correctly (although perhaps choppily) on any computer.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Locking frames and locking velocity are the exact same thing in the end.

You can''t interpolate frames in a 2D game so you have to use IFs to keep it moving along or skipping frames if need be to keep up with the intended speed of the animations.

Ben
http://www.icarusindie.com




Not really, because if you have a high end computer, you may render the game at 75 fps, while a low end computer would only render it at 25 fps. If you "lock the velocity" (I call it time-based physics) the game will run smoother on faster computers, but everything will move at the same real time speed. If you lock the frame rate, your game will run at say, 30 fps, on all computers, no matter how powerful it may be. Or, if you have a computer old enough, it will run at say, 20 fps, and everything will appear to run in slow motion. Locking the frame rate is a piss poor solution that doesn''t cut it anymore.

As for your comment about not being able to interpolate in 2D, why the hell not?

Besides, if you use time-based-physics, there is no need to interpolate.

What version of directX does it need. If its 8 then does you laptop have a 3D Graphics Card?
Umfor a game like tetris, you do not want to use time based physics.

Firstly, in the original (and I assume this game), the blocks move in large jumps anyway, so the actual logistics of using it is screwed up.

Then, the fact that when you are using time based modelling, if you have a small degradation in the frame rate, it seems like a much bigger problem than if you lock the frame rate. A game which runs consistently at 40fps will look better than one which runs at 60fps but then drops to 50fps every few seconds. You should always aim for consistency.

And thirdly... overkill? Tetris just screams fixed frame rate at you
Trying is the first step towards failure.

This topic is closed to new replies.

Advertisement