• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Views following player working weirdly with my cursor system and with resolution

Y

Yoflaines

Guest
Hi, I'm currently making a top down stealth game, nothing big, got some of the mecanics working but im trying to fix a small issue I've had. My views are 640x360 if anyone wants to know. The cursor system I have is that the cursor moves with the player and it works fine untill I move outside the view and the camera follows my character, the cursor get extra "speed" to the direction im moving, it works fine in the default view. Also my system works fine when i have it in windowed but if i scale the window or go in to fullscreen the "speed" of the cursor also goes up. I'll post some code to show what I do to move the cursors around corresponding to the players movement.

Code:
if keyboard_check(ord("A"))
{
    x -= movespeed
    display_mouse_set(display_mouse_get_x()-movespeed,display_mouse_get_y())
}

if keyboard_check(ord("D"))
{
    x += movespeed
    display_mouse_set(display_mouse_get_x()+movespeed, display_mouse_get_y())
}

if keyboard_check(ord("W"))
{
    y -= movespeed
    display_mouse_set(display_mouse_get_x(), display_mouse_get_y()-movespeed)
}

if keyboard_check(ord("S"))
{
    y += movespeed
    display_mouse_set(display_mouse_get_x(), display_mouse_get_y()+movespeed)
}
The movespeed just equals the players speed so they are the same and wont move when I'm colliding with something
 

NicoFIDI

Member
the logic wil allways move your mouse, but if your backgroud it's scrolling then your player will keep his position in monitor pixels.
so the mouse will move alone.
 
Y

Yoflaines

Guest
What would be a fix to this then? Settings the cursors speed to 0 when moving outside of the view or something?
 

Brodie

Member
It depends what you're trying to do, but is there a reason you can't just use the following:
Code:
if keyboard_check(ord("A"))
{
   x -= movespeed // Update x coordinate
   display_mouse_set(x,y) // Set mouse to new object coordinates
}
etc
 
Y

Yoflaines

Guest
I've been testing that before and apperantly it doesn't work, this was the way i got the best outcome.
 

NicoFIDI

Member
I whould only move the mouse in x
if (view_xview ==0 || view_xview+view_wview == room_width)

Same with y and height
 
Top