Dynamic 2D Top-Down terrain/tilemap

Howdy fellow devolders! I have been planning a project for a while. It is a farm sim with much more enphasis on the sim side, so for example the crops and plants you can grow can suffer from pests, seasons like winter, summer, need an irrigation system and alike. As of now the project is a planning thing only, here some screenshots of how it should look like:
image

everything is on proof of concept phase as of now. The project was meant to be built on Love2D framework. Thing is, now that i think of it, Defold is not only fast and lightweight like love2d, but it is far more robust too. Particle editor, tileset handler, collision detection… The list goes on, thing is this project was planned on love2d, it uses lots of optimizations and quirks that idk how to properly transport to Defold. There are several examples, but the main one is the terrain. On the first screenshot i sent, the player would first be presented with an area they could plant on and they could expand that area as the game progresses. In love2d everything is so bare bones that i had to manually call a draw routine for the terrain, crops, etc. As such it was really easy to have a 2d array representing the map and each entry of the array had information about what tile it is, etc. And i could change that at any moment. But in Defold i have to use either a sprite or a tilemap. How can i have a dynamic terrain that can change, grow/shrink in size and alike? Any help is greatly appreciated!

I would either use game objects with sprites that I create our destroy or a mesh component that I dynamically update.

3 Likes

Sorry for the late response, its semesters end here were i live, lots of test lately. Anyway, the problem with using GOs is that:

How can i know which GO is at position (X, Y, Z)? I mean, the user needs to click on the tile to interact with it. If i could purposefully decide where each tile would be drawn, like for example if there were an array of tiles and each tile would be called manually to draw it would be simple, i just use a formula to get the mouse position and transform it to a xyz coordinate, and then pass that coordinate from a 3D vector to a 1D array position. How could i do that in Defold? I thought of some solutions over these days:

Have the game generate Game Objects in real time, using the factory i think or some way to load in data arbitrarily. That way, i can run over the world and put each GO in a specific object, and then have that GO put its reference (self) inside an array that would be the World array. To examplify, suppose a 3x3 world, a total of 9 isometric tiles would in thy world. With the approach i just described, id have a way to load or create GOs in real time, and with that i could go for every position of an array local array = {} with size 9. I could go like:

for i = 1,  9 do
   array[i] = createNewTileObject()
end

or something similar. So in short, create tiles in real time and as theyr being created, add them to the array and put their position corresponding to the array. To interact with the tile just use a function to get the position from camera space to an isometric space, this i already have working from old code.

Anyway, it might be possible but still, how much memory should this cost? In all engines i could take on that have the requirements i need, in special exporting to WebGL, all of those options (Defold and Solar2D) would have problem with memory maybe. Tho again, i might just be exagerating things, not like it would even reach a half gig anyways. Here are some tests i made to see how the game would look like, still making stuff to look better:
image