Windows Gameboy-Zelda-type status bar

E

Earth2Ryan

Guest
So as a way to learn GML i decided to recreate Link's Awakening in GM. I've come to a wall and i need some help.
The status bar in the Gameboy Zelda games is not part of the playable game world.
an example:

That's the playable game area AND the size of each map screen. (this always only scrolls 160px or 128px in any direction)


And that's the menu bar i'm referring to. This is persistent throughout all screens of the game but is not part of any map tiles and does not scroll
How would I achieve this in GM and keep the size of my rooms at 160x128?
 
Q

Quackertree

Guest
The menu bar is a thing called a GUI (General User Interface) element.

GUI is always displayed on top of the view, so it doesn't actually exist within the room itself. Instead, you draw this seperately in a Draw GUI event. The Draw GUI event will look at the actual screen, with {0, 0} being the top-left and {view_width, view_height} being the bottom-right of the window. This is different from the Draw event, since the Draw event actually refers to {0, 0} as the top-left of the room (game world) and not the actual screen.

This is called a difference in "space". The Draw event works in "world space", but the Draw GUI event works in "screen space".

What you want for you GUI element, is to draw in screen space. This way, it'll always draw on the same position, relative to your view. For example: If I draw a rectangle at {10, 10} in screen space, it'll always draw that rectangle 10 pixels down and 10 pixels to the right, from the top-left corner of the screen.

As for the view itself, you can use the built-in view system from GM. It's somewhere under the properties of your room. Simply open the room editor and head to the tab "View", which allows you to setup the width and height of the view, aswell as what object / instance to follow and with what speed.

Hope this helps!
 
S

SoulTie

Guest
The menu bar is a thing called a GUI (General User Interface) element.
I always thought that GUI was shorthand for Graphical User Interface.
Other than that, I agree. Read up on the Draw GUI event.
 
E

Earth2Ryan

Guest
Thanks a ton! Some really helpful stuff there.
Now, is there a way to scale everything in the window all at once including gui elements? Like, i want to be able to hit + or - on my numpad and then the game scales up or down accordingly.
I actually already can do this but the gui doesn't scale with everything else

edit: I figured it out but the game is not correctly positioned inside the window.


needs to be moved up 8px so there is no black bar and you can see the rest of the gui
 
Last edited by a moderator:

TheouAegis

Member
I think you would have to keep track of the scale factor yourself and then use draw_???_ext() functions 2 draw the GUI scaled up. As for the 8 pixels that you are displaced, if you are using views you may need to check your view position or viewport.
 
E

Earth2Ryan

Guest
The view is set correctly to (0, 0). And that's exactly what i'm doing, manually keeping track of the scale factor with variables. It scales correctly now, I just need to figure out why its positioned incorrectly.

heres the code:

so, the camera handles all of the screen scaling. The surface_resize is there to make room for the gui on screen. And then window_set_rectangle is what actually scales and centers the window based on the manual-scale variables witch can be changed by pressing either - or +.
 
Last edited by a moderator:
Top