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
You are allocating 801 * 401 (=321201) elements of struct absCell on the stack. Assuming you have a 32bit machine it is 2569608 Byte (~2.45 MB). According to this it is blowing up your stack.
Move the elements to heap like:
class Field {
public:
static const int minX = -400;
static const int maxX = 400;
static const int minY = 0;
static const int maxY = 400;
Field() {
cells = new absCell*[maxX - minX + 1];
for(int i=0; i
Material and health can be saved in a char. Accessing health you have to recalculate it:
put -> x*100
get -> x/100
Except you have some reasons, using a vector is most likely the better option, as Mark B 's answer describes.