When I initialize my grid array I have no problem initializing it changing my row values
like so
grid[0][0] = 0;
grid[1][0] = 0;
grid[2][0] = 0;
grid[3][0] = 0;
...but when I do this "grid[0][1] = 0;" or "grid[0][2] = 0;" and all the way up to 8 the program will crash. I am confused I originally made a simple nested loop to cut down on the code to initialize the array but that won't work. The problem might be an out of bounds error but my array is setup in the constructor as int grid[4][9]. Its been awhile since I initialized an array in a constructor so please help its probably something simple I missed. Thank ya!
// Class automatically generated by Dev-C++ New Class wizard
//header
#ifndef BACKGROUND_H
#define BACKGROUND_H
#include <allegro.h>
#include "mouse.h"
#include "character.h"
#include <iostream>
using namespace std;
/*
* No description
*/
class background
{
public:
// class constructor
background();
// class destructor
~background();
BITMAP* changeBackground(BITMAP *buffer, mouse& click, character& murderface);
void setLevel(int counter);
private:
BITMAP *startUpScreen;
BITMAP *level;
BITMAP *secondLevel;
BITMAP *thirdLevel;
BITMAP *fourthLevel;
BITMAP *rightArrow;
BITMAP *leftArrow;
BITMAP *upArrow;
BITMAP *shiftKey;
bool nextLevel;
int counter;
int grid[4][9];
};
#endif // BACKGROUND_H
//cpp
#include "background.h" // class's header file
// class constructor
background::background()
{
startUpScreen = load_bitmap( "C:\\VGArt\\Dethklokbackground.bmp", NULL);
level = load_bitmap( "C:\\VGArt\\firstBack.bmp", NULL);
secondLevel = load_bitmap( "C:\\VGArt\\secondBack.bmp", NULL);
thirdLevel = load_bitmap( "C:\\VGArt\\thirdBack.bmp", NULL);
fourthLevel = load_bitmap( "C:\\VGArt\\fourthBack.bmp", NULL);
rightArrow = load_bitmap( "C:\\VGArt\\right-arrow.bmp", NULL);
leftArrow = load_bitmap( "C:\\VGArt\\left-arrow.bmp", NULL);
upArrow = load_bitmap( "C:\\VGArt\\up-arrow.bmp", NULL);
shiftKey = load_bitmap( "C:\\VGArt\\shift-key.bmp", NULL);
nextLevel = false;
counter = 0;
grid[0][0] = 0;
grid[1][0] = 0;
grid[2][0] = 0;
grid[3][0] = 0;
}