Legacy GM Draw GUI and Text

E

Emil

Guest
I am making a very pixelated game with room/view sizes being around 200 x 81 and the port size being 1632x918.

I figured the best way to do text would be using GUI. So far it looks but I am having trouble placing the text in the room. No matter what value I put in for display_set_gui_size it doesnt seem to make a difference. It always shows up in the left hand corner. Ideally I want it to follow my character but when i use this:

draw_text(obj_player.x-32,obj_player.y-32,"TEST, A BLOODY TEST")

The text does move but at half(approx) the distance the player does.

Is there a step I am missing? or am I going in the wrong direction with this?
 

CloseRange

Member
the draw GUI always takes the top left corner of what ever you are seeing and sets that at 0, 0. meaning if you used 0, 0 it would be in the top left corner of the screen, i could be wrong but, i belive its display_get_gui_width to get the far right side of the screen. Anyway there are pros and cons to using the draw GUI instead of draw event, what i just meantiond could be a good thing, or a bad thing in your case because you are using views (this wouldnt be a problem if you wern't)

You could just switch to using the regular draw function but then you lose some of the draw quality that you get with the draw GUI. So if you must have it in the draw GUI then the solution is slightly complex:
Code:
var new_x = obj_player.x - view_xview[view_current];
var new_y = obj_player.y - view_yview[view_current];

draw_text(new_x -32, new_y -32, "TEST, A BLOODY TEST");
i guess maybe not the most complex thing in the world but basically this should (I'm assuming I havn't actually tested it) get a variable cheking the x value and the y value of the player subtracting where the current view is.
honestly this could be complelty wrong and im just stupid or It's dead on and I will be shocked but I hope it helps! if not just say and I'll take another look at it:D

-CloseRange
 
E

Emil

Guest
Unfortunately this doesn't work. It has the same result as before. While the text does move it does not move as much as the obj_player. It is almost like is is parallaxing. It's weird.

Thanks for the great reply as well, probably one of the most polite and kindest replies to a post I have ever had.
 

FrostyCat

Member
You still haven't scaled the in-room coordinates to on-screen coordinates. Use only on-screen coordinates to draw in the Draw GUI event.

Get the relerp script here and use that to translate the coordinates first, then draw.
Code:
var gui_x = relerp(view_xview[0], view_xview[0]+view_wview[0], obj_player.x, view_xport[0], view_xport[0]+view_wport[0]),
    gui_y = relerp(view_yview[0], view_yview[0]+view_hview[0], obj_player.y, view_yport[0], view_yport[0]+view_hport[0]);
draw_text(gui_x-32, gui_y-32, "TEST, A BLOODY TEST");
 
E

Emil

Guest
Thanks. That works perfectly, except in the draw_text, it doesnt matter what value I put in with the gui_x or gui_y, the text always draws at the obj_player's sprite origin, which in this case is located at (16,32) on a sprite that is 32x32. Any idea why that is?
*EDIT*

All Good I found out how. Thank you so much for your help.
 
Last edited by a moderator:
Top