A very odd thing about Mouse Movement

For questions about using Classic.

Post » Wed Mar 13, 2013 10:29 am

Well basicly i almost finished programming the gameplay and now i started working with some UI. So i wanted to replace the original mouse cursor with some nice custom one. So yeah, ive hidden the cursor and made a sprite object and an event
+Always = Set SpirteX to MouseX and SpriteY to MouseY

Now heres what happends.
If the mouse is being moved rapidly and fast the Sprite is falling behind! And not only that! whenever the mouse is being moved in such a rapid manner - the CPU usage grows preety noticeable.

At first i though its because i have about 1200 events running, so it creates the delay. But no.
So ive gone and made a new, perfect clean project.
Added 16^2 sprite
Same event. Always>set PosX/Y to MouseX/Y
If the mouse is still, then the CPU wainting on circles around 95% (+/- 0.30%.
But when ill start moving the mouse like a crazy monkey then blam: down to 88%(!!!!). Thats a Whoping 7% CPU usage just for mouse movement O_O The heck?

And obviously, even at such empty, newborn project - the sprite falls behind the mouse cursor.

And its not a Debugger error - ive checked the CPU usage also via windows Task Manager. It shows the same. At worst the usage is 41% without the mouse movement. With the mouse going crazy - up to 51%. And thats with Dual AMD Phenom CPU.

1. Why position updating leave the sprite behind?
2. What the heck is wrong with the CPU usage?
3. How to fix the CUP usage and/or Sprite Pos updating?
ImageImageImageImage
B
26
S
7
G
7
Posts: 572
Reputation: 6,097

Post » Wed Mar 13, 2013 10:53 am

Okey after some testing, the delayed Pos updating turns out to actualy be a V-sync issue. The pos are actualy updated correctly. Its the visiuals that arent.
When it switched the V-Sync into unlimited or Fixed (about 100FPS) the updating is perfect. But thethe CPU suffers greatly.
ImageImageImageImage
B
26
S
7
G
7
Posts: 572
Reputation: 6,097

Post » Wed Mar 13, 2013 2:31 pm

It is a known problem, even in todays modern games. The best solution to have a quick mouse with V-sync is using system mouse cursor, replacing image with a small python script. It works perfectly:

http://www.scirra.com/forum/mouse-lag_topic41235.htmlAritz2013-03-13 14:33:23
B
30
S
15
G
10
Posts: 285
Reputation: 7,144

Post » Wed Mar 13, 2013 3:12 pm

okey but what about the CPU increased usage?
ImageImageImageImage
B
26
S
7
G
7
Posts: 572
Reputation: 6,097

Post » Fri Mar 15, 2013 7:49 am

a friend of my confirmed that its not only on my end. The mouse movement in general eats about 5-7% CPU.
This is a serious issue.
ImageImageImageImage
B
26
S
7
G
7
Posts: 572
Reputation: 6,097

Post » Fri Mar 15, 2013 6:27 pm

Have you tried measuring the cpu usage when moving the mouse without previewing? 5-7% is likely just caused by Windows posting notifications of mouse movements.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Fri Mar 15, 2013 7:46 pm

[QUOTE=R0J0hound] Have you tried measuring the cpu usage when moving the mouse without previewing? 5-7% is likely just caused by Windows posting notifications of mouse movements. [/QUOTE]
this sounds ridiculous but
my gawd Rojo lol you are right!

But this is madness O_O
ImageImageImageImage
B
26
S
7
G
7
Posts: 572
Reputation: 6,097


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests