Adam's Lair Forum
https://forum.adamslair.net:80/

How many tiles are too much? Also GameObjects in general
https://forum.adamslair.net:80/viewtopic.php?f=4&t=1237
Page 3 of 3

Author:  StrigoiTyrannus [ 2018/08/21, 09:11 ]
Post subject:  Re: How many tiles are too much? Also GameObjects in general

SirePi wrote:
There is not a right or wrong way to do it, as with many other things, it pretty much depends on your own preference.
Personally, if it's an object that provides engine-related behavior (i.e. implements any of the ICmpInterfaces), then it's a Component; if it's something that multiple objects or entities reference, and does not require ICmpInterfaces, then probably it's modeled as a static object, or at the very least accessed through a game-wide singleton. In all other cases it's a simple object.

That's pretty much how I was thinking it. It feels pretty straight forward that when ICmpUpdatable is needed, it's a component. But when ICmpInitializable could be used, often it feels easier to just make it so that some active component calls the methods of that said class, instead of using the ICmpInitializable. Maybe a good way to learn this would be that first I make extensive use of Components ( make pretty much everything a component) and start dropping the components if it seems it won't make sense for the said class to be a component?

SirePi wrote:
why not use an enum? the small size of an int (or even just a byte, really) with the full expressiveness of a string

I must look into that, I guess that's the best solution. But generally, how important it is to make the objects as small as possible? Let's say the map size is between 100x100 and 1000x1000 and basically all of those tiles would contain X amount of characters ( some of which are very simple, like the bear example and some more complex)

Author:  Adam [ 2018/08/21, 18:35 ]
Post subject:  Re: How many tiles are too much? Also GameObjects in general

StrigoiTyrannus wrote:
But generally, how important it is to make the objects as small as possible? Let's say the map size is between 100x100 and 1000x1000 and basically all of those tiles would contain X amount of characters ( some of which are very simple, like the bear example and some more complex)


Smaller is always better, but usually you don't need to worry about that at all. If you want to get an idea of how much memory you need, just sum up the field sizes of your data to get a rough estimate. Let's say you express a single cell as follows:

Code:
public struct CellInfo
{
    public float SomeValue;
    public int SomethingElse;
    public Vector3 SomeVector;
    public bool SomeFlag;
    public Foo SomeReference;
}


A float is 4 bytes, an int is 4 bytes. A Vector3 consists of three floats, so it's 12 bytes. A bool is just one byte, but let's assume it's 4 for padding reasons. Foo is a class, and references are 4 or 8 bytes depending on architecture, but let's go with 8. The entire struct is now 4 + 4 + 12 + 4 + 8 = 32 bytes. Now let's say you put it in a Grid<CellInfo> that's 1000x1000, so you'll get 1000 * 1000 * 32 bytes of data, which is about 30 MB. Still pretty okay, considering 1000x1000 is a really huge map.

Another thing to consider: If you say a tile contains characters, that doesn't mean you have to model your tiles in a way that they actually have a list of charactes in them - lists can get costly when you have 1000x1000 of them, and most of them will probably be empty almost all the time. Just put your characters or groups somewhere else, and let each of them point to the cell they're in right now with a Point2 or similar. Same effect, much more efficient!

Author:  StrigoiTyrannus [ 2018/12/24, 18:59 ]
Post subject:  Re: How many tiles are too much? Also GameObjects in general

Hi!
I have been quite busy with my studies and haven't really got any time to continue my game. I have thinked about it a lot though.
I have been thinking about the tiles and came to the conclusion that hexagon shaped tiles would be a lot better compared to square ones. How can I use hexes in Duality?

Merry Christmas!

Author:  SirePi [ 2018/12/26, 09:23 ]
Post subject:  Re: How many tiles are too much? Also GameObjects in general

StrigoiTyrannus wrote:
How can I use hexes in Duality?

I'm afraid you should come out with your own implementation, data structure and renderer. There are many generic tutorials online but nothing built-in in Duality. I think a good place to start would be the Tilemap plugin, and it should be only a matter of adapting said structures and the renderer to be able to deal with hexagonal shapes.
The editor plugin then (the tiles palette, painting, selection, etc..) would be on another level I believe though.

And delayed Merry Chritsmas to you too :mrgreen:

Page 3 of 3 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/