• 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!

Multiple controller pointers

J

JMonella

Guest
Hi All,

I've been struggling with this problem for quite a while now and haven't seen anything on it so either its painfully obvious or it may require someone a little bit smarter to help!
Essentially i'm making a multiplayer game that is predominately controller based. Each player has a pointer on screen which their characters follow.
I have created a version which works in single player by utilising the mouse but as far as I am aware you can only have one mouse cursor at a time.
I have tried to make the 'cursor' objects GUI based so that they don't fly off the screen when the characters move but as soon as the object goes near the border of the camera the Gui is no longer representative of where the object is.
Any help is greatly appreciated and if I've made this too wordy I apologise :)
 

TsukaYuriko

☄️
Forum Staff
Moderator
Sounds like you've tried making the cursors relative to GUI and instance coordinates so far. The correct set to use in calculations should be relative to the room.

Without knowing how you're handling calculations and drawing, going any further than that would prove to be equivalent to taking shots in the dark, though, as the amount of provided information about the actual implementation of any of this is minimal. Please post all relevant code instead of just paraphrasing it - your explanation serves as a representation of what you want your code to do, and since this doesn't seem to match reality, it will, by itself, not allow us to see what's wrong.
 
J

JMonella

Guest
Sounds like you've tried making the cursors relative to GUI and instance coordinates so far. The correct set to use in calculations should be relative to the room.

Without knowing how you're handling calculations and drawing, going any further than that would prove to be equivalent to taking shots in the dark, though, as the amount of provided information about the actual implementation of any of this is minimal. Please post all relevant code instead of just paraphrasing it - your explanation serves as a representation of what you want your code to do, and since this doesn't seem to match reality, it will, by itself, not allow us to see what's wrong.
Thanks for your response, I didn't initially post and code because I went at it a couple of ways and non proved successful so I wasn't sure which code would be the most useful.
I'll go with the code that involves most of the GUI issues.

Create Event:
///grab the width and height of view
var cw = camera_get_view_width(view_camera);
var ch = camera_get_view_height(view_camera);
///set some variables to hold the value and div that by width and height
display_scalex = display_get_gui_width()/cw;
display_scaley = display_get_gui_height()/ch;
scrollSpeed = 10;

Step Event:
var inputx = gamepad_axis_value(0, gp_axisrh);
var inputy = gamepad_axis_value(0, gp_axisrv);
cursorx = x + inputx * scrollSpeed;
cursory = y + inputy * scrollSpeed;
x = cursorx;
y = cursory;

Draw GUI:
///get camera coords
var cx = camera_get_view_x(view_camera);
var cy = camera_get_view_y(view_camera);
///make the adjustment to gui
var xx = (x-cx)*display_scalex;
var yy = (y-cy)*display_scaley;
///draw the sprite
draw_sprite(spr_mouse1,image_index,xx,yy-75);
 
J

JMonella

Guest
Thanks for your response, I didn't initially post and code because I went at it a couple of ways and non proved successful so I wasn't sure which code would be the most useful.
I'll go with the code that involves most of the GUI issues.

Create Event:
///grab the width and height of view
var cw = camera_get_view_width(view_camera);
var ch = camera_get_view_height(view_camera);
///set some variables to hold the value and div that by width and height
display_scalex = display_get_gui_width()/cw;
display_scaley = display_get_gui_height()/ch;
scrollSpeed = 10;

Step Event:
var inputx = gamepad_axis_value(0, gp_axisrh);
var inputy = gamepad_axis_value(0, gp_axisrv);
cursorx = x + inputx * scrollSpeed;
cursory = y + inputy * scrollSpeed;
x = cursorx;
y = cursory;

Draw GUI:
///get camera coords
var cx = camera_get_view_x(view_camera);
var cy = camera_get_view_y(view_camera);
///make the adjustment to gui
var xx = (x-cx)*display_scalex;
var yy = (y-cy)*display_scaley;
///draw the sprite
draw_sprite(spr_mouse1,image_index,xx,yy-75);
I also tried to make it a non gui object, and then clamp the object inside the bounds of the camera but couldn't get any code that would be of use.
 
Top