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

GameMaker Setting up dynamic room view/camera

A

anomalous

Guest
It's been a while since I messed with these and I apparently have forgotten (or never knew), how to fix this.

Goal:
From start room
Change a different room's size
set up the view/camera such that when I go to the new room, I see the entire room on the screen (at the appropriate room aspect ration, not stretched obviously).

It seems like I see my room0 first room size only. Do I even need to create a camera? Aren't there default cameras? (I updated it based on some tutorial but failed).

I'd like to see on my screen (1900x1200 display), an approximately 1200x1200 area of the entire 6240x6240 pixel room.
This is an a control object and it's run from room0, prior to going to room_dungeon.

Code:
target_room = room_dungeon;
// room stuff
target_room_grid_width = 130;
target_room_grid_height = 130;
target_room_width = target_room_grid_width * ts;
target_room_height = target_room_grid_height * ts;

room_set_width(target_room,  target_room_width);
room_set_height(target_room,  target_room_height);


/// camera stuff
var cc = global.camera;
camera_set_view_size(cc,target_room_width,target_room_height);
var cw = camera_get_view_width(cc);
var ch = camera_get_view_height(cc);
show_debug_message("Cw = " + string(cw) + " ch = " + string(ch));

view_set_visible(0,true);
room_set_camera(target_room,0,cc);
room_set_view_enabled(target_room,true)
room_set_viewport(target_room, 0, true, 0,0,cw,ch);

// go there
room_goto(target_room);
 
Top