Upgradable & Expandable Background Option?

J

JOSEPHPERKS

Guest
Hi everyone,
I'm new to gamemaker2 and I a developing an idea have had for a while. One of the most popular features of games such as prison architect, Sim airport and many more, is that you are not limited by the canvas size. In these games, you can "buy" additional land to build on, when you buy this land, it extends the background, thus leading to infinity.
How could I create this with Gamemaker 2?
 
D

DarthTenebris

Guest
I don't use GMS2, but should be about the same as GMS1.4.

First of all, I would like to mention that in those kinds of games, while expansion is possible, it has a certain limit - you can't just expand like crazy. Check out the top guys - if it is possible to expand, why aren't they expanding? Sure it costs money, you could say they're saving up for expansions, but then you can wait it out say for a year or two. They still aren't expanding (unless in that period of time the game updated and introduced more expansions - that is beyond what I'm talking about). That is because the game limits the expansions - the available buildings aren't meant to be sufficient for infinite expansion. Therefore they make expansions available slowly - ensuring there are buildings left to build (usually those games have a limit to how many buildings and what kind of buildings you can buy at a certain level - to buy more you have to level up).

However, if you want infinite rooms, I have to say, theoretically a room is infinite in size. The room editor size is just to ease placing around objects and tiles, and setting the view. However, all this is achievable by code as well. Setting the view, placing objects and tiles. Moreover, it is more powerful than the room editor - for example, if you use the follow object option in the room view settings, it is limited to the room size. However, if you manually move it by code, it can go as far as you want. But with great power comes with great responsibility. Eventually when things get too big, you'll run out of memory, your game will crash, and it will ruin player experience. So I suggest making a chunk management system - that way you'll only load what you need.

Check out this video about infinite rooms. You can adapt it to suit your needs. Video:

TLDR: Infinite rooms are possible, but it means you'll have to do everything yourself. Also consider making a memory management system.
Hope my post wasn't too long, and hope I helped :)
 
A simple version would be to limit the view range in a room and allow them to 'purchase land' which simply increases the range in which the view can move. Combining that with the ideas behind infinite terrain generation should give you a relatively unlimited land purchasing system.
 
J

JOSEPHPERKS

Guest
I don't use GMS2, but should be about the same as GMS1.4.

First of all, I would like to mention that in those kinds of games, while expansion is possible, it has a certain limit - you can't just expand like crazy. Check out the top guys - if it is possible to expand, why aren't they expanding? Sure it costs money, you could say they're saving up for expansions, but then you can wait it out say for a year or two. They still aren't expanding (unless in that period of time the game updated and introduced more expansions - that is beyond what I'm talking about). That is because the game limits the expansions - the available buildings aren't meant to be sufficient for infinite expansion. Therefore they make expansions available slowly - ensuring there are buildings left to build (usually those games have a limit to how many buildings and what kind of buildings you can buy at a certain level - to buy more you have to level up).

However, if you want infinite rooms, I have to say, theoretically a room is infinite in size. The room editor size is just to ease placing around objects and tiles, and setting the view. However, all this is achievable by code as well. Setting the view, placing objects and tiles. Moreover, it is more powerful than the room editor - for example, if you use the follow object option in the room view settings, it is limited to the room size. However, if you manually move it by code, it can go as far as you want. But with great power comes with great responsibility. Eventually when things get too big, you'll run out of memory, your game will crash, and it will ruin player experience. So I suggest making a chunk management system - that way you'll only load what you need.

Check out this video about infinite rooms. You can adapt it to suit your needs. Video:

TLDR: Infinite rooms are possible, but it means you'll have to do everything yourself. Also consider making a memory management system.
Hope my post wasn't too long, and hope I helped :)
Thank you for your post. The problem with using a chunk based system is that whilst elements are not loaded, they wont be functioning as intended. I.E if a ride is supposed to be operating and earning money in one corner of the map, but that chunk isn't loaded, it effectively becomes worthless thus in a way limiting the actual expansion vs the theoretical. I should clarify as well that when I said infinite, that was a throwaway comment. I am willing to set an absolute maximum size and then if required at a later stage I can expand or switch to a modified chunk system, but I don't think that will be necessary. I'm simply looking for a way that the player can scroll to the edge of the current game and the next purchasable section will highlight in red and when you click, new land is generated. I just can't think what the logic behind it would need to be as I don't know enough about rooms etc.
 
J

JOSEPHPERKS

Guest
A simple version would be to limit the view range in a room and allow them to 'purchase land' which simply increases the range in which the view can move. Combining that with the ideas behind infinite terrain generation should give you a relatively unlimited land purchasing system.
How would I increase the range in which the view can move? Would this be via script? Can you give me an example please?
 

Yal

šŸ§ *penguin noises*
GMC Elder
Thank you for your post. The problem with using a chunk based system is that whilst elements are not loaded, they wont be functioning as intended. I.E if a ride is supposed to be operating and earning money in one corner of the map, but that chunk isn't loaded, it effectively becomes worthless thus in a way limiting the actual expansion vs the theoretical. I should clarify as well that when I said infinite, that was a throwaway comment. I am willing to set an absolute maximum size and then if required at a later stage I can expand or switch to a modified chunk system, but I don't think that will be necessary. I'm simply looking for a way that the player can scroll to the edge of the current game and the next purchasable section will highlight in red and when you click, new land is generated. I just can't think what the logic behind it would need to be as I don't know enough about rooms etc.
For the most simple system, let's say you can buy more land to the right that lets you scroll the view further right. Then you have a max_x_scroll variable, you can't scroll further than there. When you buy more land, this limit increases.

Another idea is to generate everything at the start, with unpurchased lands as special big squares labelled as 'not yours'. You can scroll over them if you want, but you can't do anything with them until you buy them, and you can only buy them if they neighbor land you already own.
 
Yal explained it, but here's a pseudocode version.

Let's say you have a room that is 2000x2000 and your view is 500x500 (using round numbers for simplicity sake). You would set up 4 variables (this won't work perfectly, but hopefully it will give you an idea):

Create event
Code:
view_left = 250;
view_right = 250;
view_top = 250;
view_bottom = 250;
You would limit your view movement to the center of the screen like this:

Step event
Code:
if (view_xview[0] < room_width/2-view_left) {
    view_xview[0] = room_width/2-view_left;
}
else if (view_xview[0]+view_wview[0] > room_width/2+view_right) {
    view_xview[0] = room_width/2+view_right-view_wview[0];
}
if (view_yview[0] < room_height/2-view_top) {
    view_yview[0] = room_height/2-view_top;
}
else if (view_yview[0]+view_hview[0] > room_height/2+view_bottom) {
    view_yview[0] = room_height/2+view_bottom-view_hview[0];
}
Then when they buy more land (whichever side they buy land on) you increase that variable. So if they buy land at the bottom, you could add another 500 to the view_bottom variable.

Of course, this is buggy, as the corner land areas will be accessible without purchase after a horizontal and then vertical purchase and my code might not work exactly (I'm typing this on a phone) but that's the general idea.
 
Top