Skip to main content
gamedev.net
🔒 Locked

Avoiding mouse lag

Started by Haistwolf Sep 7, 2000 at 6:48 PM 3 replies 400+ views
Original Post
Haistwolf
Haistwolf
Hi. I''m new here and new at directx programming, so please try forgive me if i''m writing bullshit. I''m developing a simple game using DelphiX, it uses mouse and the VCL, but when the game have many sprites and backgrounds (less FPS), there''s something like a "mouse lag" (mouse doesn''t works smoothtly, it "brakes" everytime). My computer is a P166 mhz 32mb. It''s strange to see this in a such simple game, but i don''t see this in complex games that use directx too, like SimCity 3000. I would like to know if i''m doing something wrong, and if there''s a way to fix this. Thanks
Sly
Sly
If the mouse pointer is drawn as a sprite, then the mouse lag is because of the lower frame rate and hence the mouse pointer not being drawn as often. It is usually drawn to the back buffer and then flipped to the primary surface along with the rest of the frame.

One method I have seen suggested (in one of the GameDev articles) was to create a separate thread for updating the mouse pointer directly onto the primary surface. Since this thread will not be held up by the slower frame rate, the mouse will seem to update quicker. Your actual frame rate will still be slower, but it will seem to be faster to the user because the mouse is moving. If you choose to use this method then you will have to remember to store the contents of the primary surface that are underneath the mouse pointer before drawing the pointer sprite and then restoring the contents before moving the mouse pointer at the next update.




Steve 'Sly' Williams
Tools Developer
Krome Studios
Gunner
Gunner
a Couple of things could be slowing you down.

1st, on a p166mhz try and stay with 256 colors(palettized) mode.
16bit color(for games) is juts going to kill your system.

Experiment with having your buffers in system memory and video memory. pick witch ever one is faster for you. usually vid memory.

I tell ya 166mhz is a tight budget framerate machine

Hope this helps

Gunner.
Lifepower
Lifepower
First and easiest solution is to use Mustdie''s cursor (for those who don''t know - M$ Windows is considered Mustdie amoung some users). just use .ANI or .CUR cursor and it won''t lagg (unless you got TNT2 Ultra 32Mb and 522 drivers from NVidia).
Second and not too optimal solution was already mentioned - flipping to primary surface.
Third solution - keep your frame rate high (yet I haven''t seen users who liked playing games that ran at 5-10 FPS rate).
Haistwolf
Haistwolf
Thanks dudes, i will try this. In fact, i want to develop the game in a slow computer because isn''t everybody that has a fast cpu (and because the game is a "board game", so 10 fps is ok to play).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.