Drawing a resizable GUI

R

r7465

Guest
I need to draw a map HUD on the top right corner of the screen and it consists of many sprites, but I cannot use the draw gui functions since I am using an old version of game maker. The view of my room is interchangable, meaning the view_wview variable changes a lot and so does the view_xview/view_yview. What is an older version of the draw_gui function I could use, or, alternatively, what is a code I can execute to get the same effect?

EDIT: I genuinely spent full days trying to solve this, this is too headaching and I've done a lot of crazy ideas to try to figure out a way to do it. PLEASE if anyone can suggest anything then give help.
 
Last edited by a moderator:
S

spoonsinbunnies

Guest
if you need a map only in old game maker like before the gui layer exsisted I used to just use a much smaller layer and in draw had things sprite change based on what view was seeing it, this allowed a simple enemies as red dots mini map. Im sorry if this isn't the answer your looking for.
 
Use an orthographic projection; it functions practically identically. Just keep in mind that when a projection is set, anything drawn after will be drawn to it, rather than your view, so make sure it and the GUI are the last things to be drawn each frame.
 
R

r7465

Guest
Use an orthographic projection; it functions practically identically. Just keep in mind that when a projection is set, anything drawn after will be drawn to it, rather than your view, so make sure it and the GUI are the last things to be drawn each frame.
Okay, I know I will have to put all code in the end step event, but what functions will I have to use to do that? Thanks in advance.
 
R

r7465

Guest
d3d_set_projection_ortho(), and it won't be going in any Step event...
So I can see how this would be the right way out, but I was wondering how I could use it? I've tried going through the manual a bit and it doesn't seem to lead anywhere.

Code:
d3d_set_projection_ortho(0,0,room_width,room_height,0)
d3d_set_hidden(false);
draw_sprite(spr_fatninja,0,x,y)
d3d_set_hidden(true);
This here is what I've tried to do (spr_fatninja is just a sprite to test the feature out), however it couldnt work. How could I draw the HUD normally? Thanks in advance.
 
What are the coordinates for x and y? If they're beyond the room's dimensions, you won't see the sprite. You are using a Draw event and not Step, right? The depth for this object allows for this to draw last, right?
 

Kyrieru

Member
What's the reason why you can't draw it to view_xview and view_yview scaled? (Or whereever the camera will be)
Should be fine as long as you're doing it after the camera updates, and it can be scaled to offset the difference in size. The the origin of the sprite is the problem you can give them all the same origin.
 
R

r7465

Guest
What's the reason why you can't draw it to view_xview and view_yview scaled? (Or whereever the camera will be)
Should be fine as long as you're doing it after the camera updates, and it can be scaled to offset the difference in size. The the origin of the sprite is the problem you can give them all the same origin.
It consists of many sprites. If I expand the size of the sprites, theyd all overlap into each other. If i expand them, thered be a few gaps between them.

Also, the views value increases by 1 so the transition for the minimap will look very raggedy
 
Last edited by a moderator:
R

r7465

Guest
What are the coordinates for x and y? If they're beyond the room's dimensions, you won't see the sprite. You are using a Draw event and not Step, right? The depth for this object allows for this to draw last, right?
Okay so I modified the code and did this
Code:
d3d_set_projection_ortho(view_xview,view_yview,view_wview,view_hview,0)
d3d_set_hidden(false);
draw_sprite(spr_fatninja,0,x,y)
d3d_set_hidden(true);
But it has done what it would normally do without the d3d lines, where do I go forward from here? I'm really struggling with this.
 
The problem with the code is that you're not using static values for both the projection and the elements, so you're moving everything out of sight. Think of the ortho projection like drawing to the screen rather than the game world, as the Draw GUI event would, so set up the ortho arguments as you would a GUI.
Code:
d3d_set_projection_ortho(0,0,1280,720,0);
d3d_set_hidden(false);
draw_sprite(spr_fatninja,0,100,100);
d3d_set_hidden(true);

Also, don't bump your thread so frequently.
 
R

r7465

Guest
You could draw it to a surface and then scale the surface.
How could I do that?


The problem with the code is that you're not using static values for both the projection and the elements, so you're moving everything out of sight. Think of the ortho projection like drawing to the screen rather than the game world, as the Draw GUI event would, so set up the ortho arguments as you would a GUI.
Code:
d3d_set_projection_ortho(0,0,1280,720,0);
d3d_set_hidden(false);
draw_sprite(spr_fatninja,0,100,100);
d3d_set_hidden(true);

Also, don't bump your thread so frequently.
I23423423432423.png
I've tried to do it and this happened. The sprite got smaller as the view expanded so it still doesn't work. Any thoughts on how I could improve from here on?
 

Kyrieru

Member
How could I do that?
Create a surface.
Set it as the target when drawing the GUI elements.
Run Camera code, zoom, etc.
Draw the surface scaled proportional to the changed size of the view. You can do this by dividing the current size by whatever the original size is.

If you mean how do you use surfaces, then you should do a tutorial on the subject. Someone else can probably explain it better than I can.
 
R

r7465

Guest
Create a surface.
Set it as the target when drawing the GUI elements.
Run Camera code, zoom, etc.
Draw the surface scaled proportional to the changed size of the view. You can do this by dividing the current size by whatever the original size is.

If you mean how do you use surfaces, then you should do a tutorial on the subject. Someone else can probably explain it better than I can.
Okay, I was wondering, how would I make the surface resizable? I think I got a hold of it but its still confusing, can you please tell me what to write in draw event if i want to make its size instantly change? (and optionally in create)
 
Last edited by a moderator:
Top