Jump to content


Photo

Dynamic room resizing


  • Please log in to reply
4 replies to this topic

#1 mcoot

mcoot

    GMC Member

  • New Member
  • 387 posts

Posted 04 July 2010 - 11:19 AM

I have made scripts that write all the information about a room to a file, which can then be read.

It all works, except for one thing: room resizing. I know why: Game Maker's manual warns you against manipulating the currently active room. And it doesn't work.

Is there any way to resize the active room? Because if I leave the room, all of the rest of the data disappears. And I can't make it persistant because that has the same effect as the room being active.

My code is basically:

room_set_width(room,file_text_read_real(myfile));
file_text_readln(myfile);
room_set_height(room,file_text_read_real(myfile));

The obvious answer is to use room_add(); and just make a new room, but that defeats the purpose of having externally stored levels in the first place.

So: is there any way around the limitations on the active room, and if there isn't, how could I load the room data in beforehand?

Edited by mcoot, 04 July 2010 - 09:18 PM.

  • 0

#2 top hunter7

top hunter7

    GMC Member

  • New Member
  • 1043 posts

Posted 04 July 2010 - 11:58 AM

I have looked into this myself before, and the only way I have been successful in achieving the desired effect is something like this.

var file,width,height;
file = file_text_open_read("level.lvl");
width = file_text_read_real(file);
file_text_readln(file);
height = file_text_read_real(file);
/* LOAD ALL OTHER NECESSARY DATA*/
file_text_close(file);

room_set_width(myRoom,width);
room_set_height(myRoom,height);
/* APPLY OTHER SETTINGS TO THE ROOM */
room_goto(myRoom);

If this isn't what you meant, I'm sorry. :P
  • 0

#3 Kresjah

Kresjah

    GMC Member

  • GMC Member
  • 45 posts

Posted 04 July 2010 - 12:26 PM

I have made scripts that write all the information about a room to a file, which can then be read.

It all works, except for one thing: room resizing. I know why: Game Maker's manual warns you against manipulating the currently active room. And it doesn't work.

Is there any way to resize the active room? Because if I leave the room, all of the rest of the data disappears. And I can't make it persistant because that has the same effect as the room being active.

My code is basically:

room_set_width(room,file_text_read_real(myfile));
file_text_readln(myfile);
room_set_height(room,file_text_read_real(myfile));

The obvious answer is to use room_add(); and just make a new room, but that defeats the purpose of having externally stored levels in the first place.

So: is there any way around the limitations on the active room, and if there isn't, how could I load the room data in beforehand?


I haven't actually tried this myself, but seen this as a solution in a fair lot of other topics. Go through all instances in the room, save their persistence state (whether they are persistent or not), then turn "persistent" on for all of them. Move to a temporary room (which makes all of the objects follow along with you since they are now persistent). Now, set the width and height of the original room, then move back to that room. It should now have the right size. The rest is a matter of resetting the persistence states.

Hope that helps.
  • 0

#4 jsorgeagames

jsorgeagames

    GMC Member

  • GMC Member
  • 622 posts
  • Version:GM8.1

Posted 04 July 2010 - 02:44 PM

What if you read the room size first, before you had entered the room, and then all the level editor data?

Or you could ignore room size (as the view can go outside the boundaries) and just not let the player go outside of the level.
  • 0

#5 mcoot

mcoot

    GMC Member

  • New Member
  • 387 posts

Posted 04 July 2010 - 09:17 PM

Yes, probably the best way to go is to load the room size separately.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users