0
\$\begingroup\$

I'm working on a harvest moon type game and I've already created lots of assets and have a working player. Now the issue is with the tile map. I use Tiled Map Editor to make the map and it renders fine.

But if I want to be able to turn grass into farmland and plant seeds and such to allow crops to grow, how would I do that?

It would be rather simple using different classes like a Farmland and Crop class and make so that Farmland has a Crop currentCrop; attached to it. But putting this together while still using a Tilemap editor seems rather difficult, since I don't actually get any Tile objects from the .tmx.

The way I could do it with Tiled is in my MapManager class I could have a

public void setCell(int x, int y, int type) {
    Cell cell = new Cell();
    switch(type) {
    case 0:
        cell.setTile(map.getTileSets().getTile(0);
    break;
}

etc.

But it feels like that would be a pain to keep track on how much thing have grown and so on and just feels like a clumsy system.

Am I going about this the right way?

Thanks in advance!

\$\endgroup\$
0
\$\begingroup\$

If anyone else wonders the same thing, instead of directly editing the tile map itself you just add objects above it.

For example have a Farmland class and when using let's say a Hoe you add a new object to an ArrayList which keeps track on all your placed objects in the game which could be anything. A tree, farmland, furniture etc.

Then to get the tile, add a method which checks if a temporary Rectangle collides with one of the Rectangle's in your object list.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.