Trouble creating a Function
Posted: August 16th, 2019, 7:36 pm
I'm on tutorial 6 of Chili's and he's creating a function in that one for DrawBox.
I followed it the way he did it exactly the only difference is I named my function DrawTree because it's drawing a tree not a box.
I'm getting an error when I declare the function: /********************************/
/* User Functions */
void DrawTree( int tx, int ty, int tr, int tg, int tb);
/********************************/
Error reads "Function definition cannot be found"
BUT... I have the function definition under ComposeFrame (which is part of the Game class I thought) as below:
void Game::DrawTree( int tx, int ty, int tr, int tg, int tb);
{
gfx.PutPixel(0, 0, 0, 255, 0);
gfx.PutPixel(-1, 0, 0, 255, 0);
gfx.PutPixel(-2, 0, 0, 255, 0);
gfx.PutPixel(-3, 0, 0, 255, 0);
gfx.PutPixel(-4, 0, 0, 255, 0);
gfx.PutPixel(-5, 0, 0, 255, 0);
gfx.PutPixel(0, +1, 0, 255, 0);
gfx.PutPixel(-1, +1, 0, 255, 0);
gfx.PutPixel(-2, +1, 0, 255, 0);
gfx.PutPixel(-3, +1, 0, 255, 0);
gfx.PutPixel(-4, +1, 0, 255, 0);
gfx.PutPixel(-5, +1, 0, 255, 0);
gfx.PutPixel(+1, 0, 0, 255, 0);
gfx.PutPixel(+2, 0, 0, 255, 0);
gfx.PutPixel(+3, 0, 0, 255, 0);
gfx.PutPixel(+4, 0, 0, 255, 0);
gfx.PutPixel(+5, 0, 0, 255, 0);
gfx.PutPixel(+1, +1, 0, 255, 0);
gfx.PutPixel(+2, +1, 0, 255, 0);
gfx.PutPixel(+3, +1, 0, 255, 0);
gfx.PutPixel(+4, +1, 0, 255, 0);
gfx.PutPixel(+5, +1, 0, 255, 0);
gfx.PutPixel(0, +2, 50, 0, 0);
gfx.PutPixel(0, +3, 50, 0, 0);
gfx.PutPixel(0, +4, 50, 0, 0);
gfx.PutPixel(0, +5, 50, 0, 0);
gfx.PutPixel(0, +6, 50, 0, 0);
gfx.PutPixel(0, +7, 50, 0, 0);
gfx.PutPixel(0, +8, 50, 0, 0);
gfx.PutPixel(-1, +2, 50, 0, 0);
gfx.PutPixel(-1, +3, 50, 0, 0);
gfx.PutPixel(-1, +4, 50, 0, 0);
gfx.PutPixel(-1, +5, 50, 0, 0);
gfx.PutPixel(-1, +6, 50, 0, 0);
gfx.PutPixel(-1, +7, 50, 0, 0);
gfx.PutPixel(-1, +8, 50, 0, 0);
gfx.PutPixel(+1, +2, 50, 0, 0);
gfx.PutPixel(+1, +3, 50, 0, 0);
gfx.PutPixel(+1, +4, 50, 0, 0);
gfx.PutPixel(+1, +5, 50, 0, 0);
gfx.PutPixel(+1, +6, 50, 0, 0);
gfx.PutPixel(+1, +7, 50, 0, 0);
gfx.PutPixel(+1, +8, 50, 0, 0);
}
and I'm also getting an error here that states "member function DrawTree may not be redeclared outside it's class"
What am I doing wrong?
I followed it the way he did it exactly the only difference is I named my function DrawTree because it's drawing a tree not a box.
I'm getting an error when I declare the function: /********************************/
/* User Functions */
void DrawTree( int tx, int ty, int tr, int tg, int tb);
/********************************/
Error reads "Function definition cannot be found"
BUT... I have the function definition under ComposeFrame (which is part of the Game class I thought) as below:
void Game::DrawTree( int tx, int ty, int tr, int tg, int tb);
{
gfx.PutPixel(0, 0, 0, 255, 0);
gfx.PutPixel(-1, 0, 0, 255, 0);
gfx.PutPixel(-2, 0, 0, 255, 0);
gfx.PutPixel(-3, 0, 0, 255, 0);
gfx.PutPixel(-4, 0, 0, 255, 0);
gfx.PutPixel(-5, 0, 0, 255, 0);
gfx.PutPixel(0, +1, 0, 255, 0);
gfx.PutPixel(-1, +1, 0, 255, 0);
gfx.PutPixel(-2, +1, 0, 255, 0);
gfx.PutPixel(-3, +1, 0, 255, 0);
gfx.PutPixel(-4, +1, 0, 255, 0);
gfx.PutPixel(-5, +1, 0, 255, 0);
gfx.PutPixel(+1, 0, 0, 255, 0);
gfx.PutPixel(+2, 0, 0, 255, 0);
gfx.PutPixel(+3, 0, 0, 255, 0);
gfx.PutPixel(+4, 0, 0, 255, 0);
gfx.PutPixel(+5, 0, 0, 255, 0);
gfx.PutPixel(+1, +1, 0, 255, 0);
gfx.PutPixel(+2, +1, 0, 255, 0);
gfx.PutPixel(+3, +1, 0, 255, 0);
gfx.PutPixel(+4, +1, 0, 255, 0);
gfx.PutPixel(+5, +1, 0, 255, 0);
gfx.PutPixel(0, +2, 50, 0, 0);
gfx.PutPixel(0, +3, 50, 0, 0);
gfx.PutPixel(0, +4, 50, 0, 0);
gfx.PutPixel(0, +5, 50, 0, 0);
gfx.PutPixel(0, +6, 50, 0, 0);
gfx.PutPixel(0, +7, 50, 0, 0);
gfx.PutPixel(0, +8, 50, 0, 0);
gfx.PutPixel(-1, +2, 50, 0, 0);
gfx.PutPixel(-1, +3, 50, 0, 0);
gfx.PutPixel(-1, +4, 50, 0, 0);
gfx.PutPixel(-1, +5, 50, 0, 0);
gfx.PutPixel(-1, +6, 50, 0, 0);
gfx.PutPixel(-1, +7, 50, 0, 0);
gfx.PutPixel(-1, +8, 50, 0, 0);
gfx.PutPixel(+1, +2, 50, 0, 0);
gfx.PutPixel(+1, +3, 50, 0, 0);
gfx.PutPixel(+1, +4, 50, 0, 0);
gfx.PutPixel(+1, +5, 50, 0, 0);
gfx.PutPixel(+1, +6, 50, 0, 0);
gfx.PutPixel(+1, +7, 50, 0, 0);
gfx.PutPixel(+1, +8, 50, 0, 0);
}
and I'm also getting an error here that states "member function DrawTree may not be redeclared outside it's class"
What am I doing wrong?