Jump to content


Photo

enlarging a room while a game is running


  • Please log in to reply
5 replies to this topic

#1 roller322

roller322

    GMC Member

  • New Member
  • 13 posts

Posted 09 May 2011 - 09:08 AM

I’m in need of something that seems very basic, but I’m not sure how to do it... whilst playing i want to be able to increase the room's width, i don’t really need to know how to increase the rooms height, but after i figure out or get help with width, height should be easy. If i cannot manage to figure this one out i will just make a very large map and only make parts accessible for the meantime, and eventually you can access the new areas. ( something like "room_width += 32;" ) but this doesn’t work, any help would be great, this is not a major project though just very basic, pointless game but if i know this bit of information i can use it later.
  • 0

#2 Medusar

Medusar

    GMC Member

  • GMC Member
  • 1228 posts
  • Version:GM:Studio

Posted 09 May 2011 - 09:41 AM

First I should say that if you can, just create a large map and make areas inaccessible. You shouldn't want to change the room size under normal circumstances.

Second, changing the size of an active room (or a persistent room that has already been active) on-the-fly can lead to some strange issues (according to the manual). So you should make all objects (not the room!) persistent, go to a temporary room, change the size of the original room using room_set_width() and room_set_height(), move back and restore the persistence state of all objects. This can all be done in a single script.

Note that, if you destroyed any objects that were originally in the room, they are created again. If this is an issue, you need to keep track of the objecs you destroy and destroy the same objects when you return to the room.

As you can see, it's quite a hassle and it should be avoided whenever possible.
  • 0

#3 roller322

roller322

    GMC Member

  • New Member
  • 13 posts

Posted 09 May 2011 - 09:45 AM

First I should say that if you can, just create a large map and make areas inaccessible. You shouldn't want to change the room size under normal circumstances.

Second, changing the size of an active room (or a persistent room that has already been active) on-the-fly can lead to some strange issues (according to the manual). So you should make all objects (not the room!) persistent, go to a temporary room, change the size of the original room using room_set_width() and room_set_height(), move back and restore the persistence state of all objects. This can all be done in a single script.

Note that, if you destroyed any objects that were originally in the room, they are created again. If this is an issue, you need to keep track of the objecs you destroy and destroy the same objects when you return to the room.

As you can see, it's quite a hassle and it should be avoided whenever possible.


well this is a very basic game, the room's height is 240 and the width is 640, all i want is in-game it increases to like 700 there 740 then 780 and so on width, by "purchasing" new blocks, its a 2d platform game, i might try using "room_set_width" i didnt try that...
  • 0

#4 roller322

roller322

    GMC Member

  • New Member
  • 13 posts

Posted 09 May 2011 - 09:51 AM

im not sure how i should apply "room_set_width" i tried "room_set_width +=64" everytime spacebar was pressed, it came up an error box, to me it sounds simple but i don't know how this works.... im going to set it so the room increases by 64 width and a new block appears which is 64x64 and you can build/grow things onto that space.
  • 0

#5 creativebunch

creativebunch

    The Bunchiest

  • GMC Member
  • 886 posts
  • Version:GM:Studio

Posted 09 May 2011 - 10:38 AM

'room_set_width()' is a function not a variable, so it would be used like this:
room_set_width(myRoom, 700)

However I would advise against this because as Medusar said it can 'lead to unexpected errors'. What I would do is make the room a normal size and then just do stuff outside the room, there is nothing stopping you using parts outside the room and I myself have made a game which starts off in the room and then the rest of the game play is all outside the room.
  • 0

#6 Medusar

Medusar

    GMC Member

  • GMC Member
  • 1228 posts
  • Version:GM:Studio

Posted 09 May 2011 - 02:06 PM

If you couldn't figure out that room_set_width() was a function I honestly don't think you're ready for things like 3D games or changing resources. I'm sorry to say it like this. But remember that everything in 3D is done using GML. Changing resources, especially things such as rooms, is actually a pretty advanced thing (lots to go wrong as I described above). You've got to be pretty fluent in GML if you want to do such things, which you don't seem to be.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users