![]() |
|
Lag when object follows mouse |
Ariesnl
Member #2,902
November 2002
![]() |
In windows (and also linux) when dragging an object is "glued" to the mousecursor. no matter how fast you move it stays on. How is this achieved ? when updating my object with mouse.dx and mouse.dy there is always some lag between mouse position and object position. any ideas ? Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
bamccaig
Member #7,536
July 2006
![]() |
I'm not sure, but are you redrawing every time the mouse position changes? Your mouse can probably move more granularly than 60 times a second. Just a hunch, but not sure it makes sense. I'm assuming the mouse cursor is a hardware/system mouse. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Ariesnl
Member #2,902
November 2002
![]() |
True, but the windows ( in windows and in linux) stick nicely to the mousecursor when you drag them. So there has to be another way. Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
Audric
Member #907
January 2001
|
The window manager is responsible for drawing both window frames and "system" mouse cursor, so it has no problem synchronizing the two. If the lag is distracting in your game, you may want to stop using the system mouse cursor, and draw your own during your draw step. Another approach, to try reduce lag, is to peek the event queue for the latest mouse position (or call al_get_mouse_state()), and use that to position the moving thing. It might save you half a frame worth of distance. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
First, you need to be more specific. What OS are you using? Are you using Allegro to draw a system cursor? Or are you drawing the mouse yourself? How are you monitoring the mouse position? On Windows, you can set a callback process that can process mouse moves. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Ariesnl
Member #2,902
November 2002
![]() |
I'm making a GUI system for allegro, so it's the lag between the mouse event and the actual mouse position. Allegro is drawing the system cursor, and I''m using the event system Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
I'm currently making a missile defense game and I have zero lag with the mouse. I draw my own pointer. All I do is respond to ALLEGRO_EVENT_MOUSE_AXES events. You should show code if possible. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Mark Oates
Member #1,146
March 2001
![]() |
I had a similar situation here. You may be looking for al_get_mouse_cursor_position()? In my case, my previous implementation wasn't setting the position to the actual mouse cursor at that exact moment, causing things to go crazy. Maybe it's related. -- |
Niunio
Member #1,975
March 2002
![]() |
Ariesnl said: I'm making a GUI system for allegro, so it's the lag between the mouse event and the actual mouse position. Allegro is drawing the system cursor, and I''m using the event system I did finished my own GUI system for the engine I'm creating. I wrote it in Object Pascal, I'm drawing the mouse cursor by myself and I haven't such "lag" drawing the mouse. My system is quite complex (mouse is an independent object and cursor is managed by GUI and everything is decoupled...) but in short is similar to this: PROCEDURE RenderMouseCursor VAR State: ALLEGRO_MOUSE_STATE; BEGIN al_get_mouse_state (State); al_draw_bitmap ( MousCursorBmp, MouseOffsetX + State.X, MouseOffsetY + State.Y, 0 ) END;
----------------- |
|