SFML 2.0 Too Many Variables in Class Preventing Draw To Screen
- by Josh
This is a very strange phenomenon to me. I have a class definition for a game, but when I add another variable to the class, the draw method does not print everything to the screen. It will be easier understood showing the code and output.
Code for good draw output:
class board
{
protected:
RectangleShape rect;
int top, left;
int i, j;
int rowSelect, columnSelect;
CircleShape circleArr[4][10];
CircleShape codeArr[4];
CircleShape keyArr[4][10];
//int pegPresent[4];
public:
board(void);
void draw(RenderWindow& Window);
int mouseOver(RenderWindow& Window);
void placePeg(RenderWindow& Window, int pegSelect);
};
Screen:
Code for missing draw:
class board
{
protected:
RectangleShape rect;
int top, left;
int i, j;
int rowSelect, columnSelect;
CircleShape circleArr[4][10];
CircleShape codeArr[4];
CircleShape keyArr[4][10];
int pegPresent[4];
public:
board(void);
void draw(RenderWindow& Window);
int mouseOver(RenderWindow& Window);
void placePeg(RenderWindow& Window, int pegSelect);
};
Screen:
As you can see, all I do is un-comment the protected array and most of the pegs are gone from the right hand side. I have checked and made sure that I didn't accidentally created a variable with that name already. I haven't used it anywhere.
Why does it not draw the remaining pegs as it should?
My only thought is that maybe I am declaring too many variables for the class, but that doesn't really make sense to me. Any thoughts and help is greatly appreciated.