Hi there,
i have a ball:
void ball (void) {
glColor3f(0.0, 1.0, 0.0); //set ball colour
glTranslatef(0.0,0.0,1); //moving it toward the screen a bit on creation
glutSolidSphere (0.6, 7, 7); //create ball.
}
I am trying to get the ball to move in a direction when i press the J key.
I attempt this:
void keyboard_s (int key, int x, int y)
{
switch (key)
{
case 'j': case 'J':
glPushMatrix(); // to save the current matrix
glTranslatef(ball.posX += 1, ball.posY, ball.posZ); //move ball +1 on it's x axis
ball(); // draw our object
glPopMatrix(); // restore the previous matrix
}
I get an error:
error C2228: left of '.posX' must have class/struct/union
error C2228: left of '.posY' must have class/struct/union
error C2228: left of '.posZ' must have class/struct/union
I am stuck at this.
I believe i must make the ball a class/struct or union instead of void?
I am unsure on how to go about this.
Any help on the matter?
Thanks in advance.
ps: i've kept out alot of code i didnt think was necessary, so if something is, please do ask :)