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

Room Settings, from GUI to GML

R

ridiculoid

Guest
New to GMS2

So I can create rooms using the GUI, and sub-sequentially edit those rooms' properties using the left hand "Properties" pane.

Up until now, I've been creating rooms via point and click like this


Room Settings > Width > (Various arbitrary room widths, say 3000)
Room Settings > Height > (Various arbitrary room heights, say 1000)
Viewports & Cameras > Enable Viewports > (Checked)
Viewports & Cameras > Viewport 0 > Visible > (Checked)
Viewports & Cameras > Viewport 0 > Camera Properties > Width > 480
Viewports & Cameras > Viewport 0 > Camera Properties > Height > 270
Viewports & Cameras > Viewport 0 > Viewport Properties > Width > 1440
Viewports & Cameras > Viewport 0 > Viewport Properties > Height > 810​

Also, just in case it's relevant... I have a camera object that I snagged from a tutorial somewhere:

/// create
target_=obChar;
width_=camera_get_view_width(view_camera[0]);
height_=camera_get_view_height(view_camera[0]);
/// step
if not instance_exists(target_) exit;
x = lerp(x,target_.x, 0.1);
y = lerp(y,target_.y-height_/8, 0.1);
camera_set_view_pos(view_camera[0],x-width_/2,y-height_/2);​

Now I'm graduating my game to procedural level generation

I want to create rooms using GML, and set the same, otherwise GUI-accessible, properties which I mentioned above. That's 3 different widths and 3 different heights.

r00m = room_add();
room_set_width(r00m, 768);
room_set_height(r00m, 576);
room_set_view_enabled(r00m, true);
room_set_viewport(r00m,0,true,0,0,480,270);​

However, here I have two widths, and two heights. What am I missing... and how do I access it? Thanks!
 
R

ridiculoid

Guest
sounds like you are looking for camera_set_view_size()
Thanks for the reply

This has me confused

With the GUI, you can set individual room properties prior to running the game and prior entering the rooms

This function reads as though you can only use this within the room, however all the other functions I described allow you to pass a room id. Is there a reason that this doesn't take a room id? It feels oddly like GML is more limiting than the user interface in this regard...

I expect that I would use this function, move to a different room and lose the setting, right?

Or am I wrong alltogether? Are cameras not "tied" to rooms the way the UI suggests? If not, why does each room have an explicit camera width/height setting in it's properties pane?

Sorry if my wording is confusing, I really can't wrap my head around this.
 
Top