I am trying to generate a two-dimensional array of a struct
, but this results in the program not launching. The window freezes and the program quits after a few
Based on update note:
The first thing you can do is easily optimize your struct for space by using unsigned char
for each attribute, using a fixed-point representation for your existing float (for example 0.23 would be stored as the integer 23).
Then store the structs on the heap with vector instead of an array:
struct absCell {
unsigned char material;
unsigned char health;
};
std::vector > cells_;
Then set up the constructor:
Field() : cells_(maxX - minX + 1, std::vector(maxY - minY + 1)) {}