0
\$\begingroup\$

I'm building a tile-based game with a similar art style as Stardew Valley, but have a few questions around technique. My understanding is that it's best to store the maps as a byte array of tile ids and render based on that.

But:

  • In the render loop, is it efficient to simply iterate that byte array every time and pull the tile image from a tilesheet?
  • How are "overlaid" items typically modeled in these type of games? e.g. In SV, there are often rocks/trees/houses/boundaries that expand over multiple tiles. Should these be treated as items consisting of tiles as well, or as a separate "layer" of individual items that are placed at x/y coordinates?
  • Is multiple byte arrays with tile properties (e.g. isPassable) more efficient than an array of objects?
\$\endgroup\$
5
  • 1
    \$\begingroup\$ There's not really such a thing as "efficient" in an absolute yes/no sense, just "efficient enough for this use pattern". So, when you code up an experiment using the approach you've described, do you find it's efficient enough for your game's needs? If not, where do you observe a specific bottleneck that we can help you solve? \$\endgroup\$ Commented Jan 2, 2021 at 16:27
  • \$\begingroup\$ Yeah, definitely true. I'm moreso approaching this from a place of ignorance as to best practices here. Maybe it's best I start with whatever's easiest, and optimize later. But it would be nice to know what's standard practice for these type of things. e.g. for drawing items that span across multiple tiles, it seems simpler to place these at specific x,y coords on top of the tilemap rather than subdividing into special tiles. But maybe there's a reason to do the latter? For rendering efficiency, having a single huge tilemap is probably more performant? \$\endgroup\$ Commented Jan 2, 2021 at 17:50
  • 1
    \$\begingroup\$ There are very few game features for which we have a well-defined, widely-agreed "best practice". What worked best for one game is often sub-optimal for another. So I'd recommend not waiting for strangers to provide you with a recommendation — proceed with what makes sense to you, and ask the strangers for help only if you hit a problem that you don't have an idea how to solve. \$\endgroup\$ Commented Jan 2, 2021 at 17:52
  • \$\begingroup\$ Apologies, but your tone is a bit dismissive. Agreed that there aren't generic one size fits all solutions, but it's pretty clear there are "right" and "wrong" ways to model this. I put it in quotes, because if you ship a working game with it, it wasn't "wrong", but clearly somebody with experience building tile based games could speak to the tradeoffs of one approach over the other. There are plenty of games that were successful with poor design under the hood. The point of this site is to generate discussion and answers to these type of questions, is it not? \$\endgroup\$ Commented Jan 2, 2021 at 23:35
  • 1
    \$\begingroup\$ I apologize for coming off as dismissive, but this is coming from years of experience seeing requests for "best practices" on this site languish without definitive answers. It's simply not something our format here does well at answering the way folks who ask these questions hope it will. Often this kind of question arises out of analysis paralysis, and adding more cooks to the kitchen doesn't necessarily solve that. My impression is that you have a good enough plan to make a start, and if you run into a snag in that plan you can use that to ask a more concrete question we can better answer. \$\endgroup\$ Commented Jan 2, 2021 at 23:44

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.