SFML 2.0 Too Many Variables in Class Preventing Draw To Screen
Posted
by
Josh
on Game Development
See other posts from Game Development
or by Josh
Published on 2013-11-06T21:52:47Z
Indexed on
2013/11/06
22:10 UTC
Read the original article
Hit count: 283
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.
© Game Development or respective owner