Room size like Terraria.

G

gerard

Guest
Hi everyone, I am creating a game more than anything to learn, like terraria, but I have a problem, I don't Know how render 10.000x10.000 objects array in the room as each object is a part of the map (land, water, sand ...). The main idea is to create a huge room and put a smaller view but may have performance problems. I would like to know what methods exist to solve this problem and not run all objects if not displayed in the room and how
dynamically generate the room with objects in the array.
 
N

NizarPlayz

Guest
Hi everyone, I am creating a game more than anything to learn, like terraria, but I have a problem, I don't Know how render 10.000x10.000 objects array in the room as each object is a part of the map (land, water, sand ...). The main idea is to create a huge room and put a smaller view but may have performance problems. I would like to know what methods exist to solve this problem and not run all objects if not displayed in the room and how
dynamically generate the room with objects in the array.
You can use the camera views go open your room enable the views and if you want the camera follow your player just do this thing
Camera following object
Select object
 
G

gerard

Guest
You can use the camera views go open your room enable the views and if you want the camera follow your player just do this thing
Camera following object
Select object
But, if I use camere views I think that objects still instantiated.
 
T

TesloStep

Guest
But, if I use camere views I think that objects still instantiated.
in terraria, imho, most objects deactivates as they moved far enough from player. in gms there is same stuff like instance_deactivate(), you can read about it.
 
D

DyingSilence

Guest
Create 2D array, or 3D if you plan having multiple object on the same coords, generate the map with external generator (you can do it inside the array, but good luck with that), save objects inside the array in according coordinates. Now, to avoid performance drops, make the objects disappear (destroy) if far enough from the player injecting them into the array at the same time, and create them if he comes close enough (by checking the array, creating them and deleting the record).
 
T

TesloStep

Guest
Create 2D array, or 3D if you plan having multiple object on the same coords, generate the map with external generator (you can do it inside the array, but good luck with that), save objects inside the array in according coordinates. Now, to avoid performance drops, make the objects disappear (destroy) if far enough from the player injecting them into the array at the same time, and create them if he comes close enough (by checking the array, creating them and deleting the record).
just curious, isnt 3d arrays denied in gms?
 
G

gerard

Guest
I'm going to try what teslostep says. Thanks if there are more ideas please comment.
 
A

anomalous

Guest
I have always assumed terraria did not use anything like a GMS object. Its likely just grids + tiles, and written in a language where those can be optimized.
I would approach it as a grid based platformer and use tiles. You can use objects for enemies though.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Indeed, Terraria uses equivalent of a grid for terrain (since it's worlds are of fixed size, a single one, if I'm not mistaken) and what would have been instances for entities such as players, enemies, and items. Items have very minimal physics and are cleaned up in a few minutes. Enemies far enough from players are cleaned up too, meaning that the total number of active instances is always pretty low.
 
Top