• 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 [SOLVED]How to convert obj.x,y coords to the GUI x,y coords

Soso

Member
Need some help with converting an objects x,y room position to the draw GUI x,y, position if its possible.

Info about the view im using
view[o]
view_wview = 400;
view_hview = 400;

view_wport = 1024
view_hport = 768

obj.gui_x = objects room pos converted into GUI coords
 

Simon Gust

Member
You need the view_xview and view_yview variables for this.
Code:
gui_x = x - view_xview;
gui_y = y - view_yview;
 

Soso

Member
dosen't seem to do the trick. I think my problem might be my camera obj since i use this code for the view movement.

view_xview[0] += ((x-(view_wview[0] /2)) - view_xview[0]) * 0.05;
view_yview[0] += ((y-(view_hview[0] /2)) - view_yview[0]) * 0.05;
 
D

drowned

Guest
x - view_xview will only get you the x position relative to the view. You still need to account for your GUI to view scale
 

Simon Gust

Member
If didn't resize your GUI, then it's initially the size of your screen.
I suggest you resize your GUI.
Code:
display_set_gui_size(view_wview, view_hview);
 

Soso

Member
thanks for the replies the code below solved my problem


vishnya code

gui_x = (x - view_xview)/view_wview*view_wport;
gui_y = (y - view_yview)/view_hview*view_hport;
 
Top