H
HanNic3197
Guest
Hello! I am using DND, but understand a bit a coding/gamemaker language.
I am making a game similar to Doodle jump. As the player sprite leaves the top of any room it moves to the next room and if it hits the bottom of any room it goes to the previous room - simulating an endless sky.
I originally tried doing this by just making a really large room and for now obvious reasons, that doesn't work. Next idea was to just make multiple rooms of the same size, but doing this by hand creates a limited number of rooms/levels the player can go into the sky.
It was suggested to me to use the room_duplicate(ind) function, which seems to work fine when increasing the rooms. However, I do not want it to actually spawn infinite rooms due to memory leak. Rather, I want it to do something like the following (I don't really know how to code as I use DND but the commands are similar I believe)
if object_player collides with obj_room_roof;
global.room_number = room_duplicate(room1)
go to room (global.room_number)
if object_player collides with obj_room_floor;
go to room (global.room_number -1)
destroy room_duplicate(global.room_number)
So when the player collides with the roof it duplicates the room and goes to the duplicate room index number. When the player collides with the floor, it goes back to the original room and destroys the duplicated room. Additionally I have added a global variable that is rooms_switched and it changes by 1 everytime the player leaves through the top of the room and -1 when the player goes back a room. This way when colliding with the floor it will only go back room until it's reached the original room.
I have a feeling that this way would still have potential for infinite rooms & memory leak. I'd like to delete the duplicate everytime is changes a new room and goes back a room. So there is always only the base room with a floor (room0) the middle room with roof and floor collision objects (room1) and the current duplicated room the player is in (room1.x). If the player has switched rooms 5 times, when the player leaves the current room it goes backwards to a new duplicate and deletes the current duplicate 3 times. When leaving the 3rd duplicate it goes back to room1, then room2 with an end rooms_switched of 0.
I have not been able to find a destroy room duplicate function anywhere, so I'm not even sure if this is possible with GMS2. If you have any other suggestions, it would be greatly appreciated!
I am making a game similar to Doodle jump. As the player sprite leaves the top of any room it moves to the next room and if it hits the bottom of any room it goes to the previous room - simulating an endless sky.
I originally tried doing this by just making a really large room and for now obvious reasons, that doesn't work. Next idea was to just make multiple rooms of the same size, but doing this by hand creates a limited number of rooms/levels the player can go into the sky.
It was suggested to me to use the room_duplicate(ind) function, which seems to work fine when increasing the rooms. However, I do not want it to actually spawn infinite rooms due to memory leak. Rather, I want it to do something like the following (I don't really know how to code as I use DND but the commands are similar I believe)
if object_player collides with obj_room_roof;
global.room_number = room_duplicate(room1)
go to room (global.room_number)
if object_player collides with obj_room_floor;
go to room (global.room_number -1)
destroy room_duplicate(global.room_number)
So when the player collides with the roof it duplicates the room and goes to the duplicate room index number. When the player collides with the floor, it goes back to the original room and destroys the duplicated room. Additionally I have added a global variable that is rooms_switched and it changes by 1 everytime the player leaves through the top of the room and -1 when the player goes back a room. This way when colliding with the floor it will only go back room until it's reached the original room.
I have a feeling that this way would still have potential for infinite rooms & memory leak. I'd like to delete the duplicate everytime is changes a new room and goes back a room. So there is always only the base room with a floor (room0) the middle room with roof and floor collision objects (room1) and the current duplicated room the player is in (room1.x). If the player has switched rooms 5 times, when the player leaves the current room it goes backwards to a new duplicate and deletes the current duplicate 3 times. When leaving the 3rd duplicate it goes back to room1, then room2 with an end rooms_switched of 0.
I have not been able to find a destroy room duplicate function anywhere, so I'm not even sure if this is possible with GMS2. If you have any other suggestions, it would be greatly appreciated!