❔ Making 2D map for simple worms style game
I am making basic worms game and I need map for it, I thought to just make map class with name and List<List<int>> mapMass variable but I am not sure if that will make sense. 0 would mean tile is empty and 1 that it is filled
36 Replies
Lists are great for when you dont know the total count ahead of time. For a map, I imagine you do know the size.
So I would recommend either a jagged array, or a multi dim array
but do you think idea itself makes sense?
int[][]
or int[,]
respectively
its a very common way to make 2d mapsI know one of these is limited to squire type cuz both height and length had to be the same which one is that
neither.
jagged allows different lengths per row, so to speak
oh just each element can have different length
yeah
which one do you reccomend then
while a 2d array enforces that all "rows" have the same length
I'm used to jagged, so thats what I often end up using.
multidimensional arrays in C# generally have incomplete API and are kind of terrible
now that I found about Point class in C# maybe I should use that
that can be slow
what for?
for indexing?
for player movement and location
yeah thats fine
because half of things are written with Point class
but it is good maybe
Point class will just be indexes for map tile array
use it if it's a struct
1 for map tile being filled, 0 for empty and 2+ for players
but then I will need to somehow track which player it is
what do u mean?
if I have map made out of tiles and certain tiles will be marked as player tiles I will also need to know which player is on those tiles
ah well in strategy games
they use something like
Tile[,]
not int[,]
it will be Worms type of game
is Tile another c# standart class?
you have to define one
but maybe I can just use int and assign each player a continues number from 2+
you can put some data in the
Tile
instance like what player is on itsince 1 and 0 is for map terrain
or if its filled, or empty
but making class would be better yeah
Tile[0,0].IsEmpty = false;
or like Tile[0,0].EnterPlayer(worm);
you can define properties,fields, and methods for class Tileyeah it will be easier this way
a tile is like a pixel in worms games right?
well for my game it is
it is like 2D but not from top but from side
I have made something like this
3 of those symbols is 1 tile
but I still wonder how can I make it better
should I even call it tile?
tile sounds like something when you make it 2D from top
so I should keep multidimensional array of tiles?
why not, it IS a tile, right?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.