I have a problem with translation of sphere. I make a game-Frozen Bubbles. The goal is to move the middle sphere in the bottom of the screen to the last row spheres from up to down. But the sphere doesn’t move. I tried different variants-with translation of every point of the sphere, translation of the sphere, change of the coordinates of every point ot the sphere. This must happen, when the left button of mouse is down. That`s why this code is in mouse() function. The thing, that happen is that the arrow, which define the direction of the sphere stop moving.
This is my code:
[LEFT]void mouse(int button, int state, int x, int y)
{
int t=132, s=8;
if (button==GLUT_LEFT_BUTTON) {
if (state==GLUT_DOWN) {
if (((248x-32736-16xl+2112l)/(y-8)>=0) && ((248x-32736-16xl+2112l)/(y-8)<=264)) {
for (int p=0; p<=304; p++)
{
for (int v=0; v<=272; v++)
{
if ((p-132)(p-132) + (v-8)(v-8)<=64)
{
glPushMatrix();
p+=(248x-16xl+2112l-132y-31680)/(y-8);
v+=240-16l;
glTranslatef((248x-16xl+2112l-132y-31680)/(y-8), 240-16l, 0);
glVertex2f(p, v);
glPopMatrix();
}
}
}
}
else if ((248x-32736-16xl+2112l)/(y-8)<0)
{
int f=0;
if (l%2)
{
for (int p=0; p<=304; p++)
{
for (int v=0; v<=272; v++)
{
if ((p-132)(p-132)+(v-8)(v-8)<=64)
{
glPushMatrix();
p-=124;
v+=240-16l;
glTranslatef(-124, 240-16l, 0);
glVertex2f(p, v);
glPopMatrix();
}
}
}
}
else
{
for (int p=0; p<=304; p++)
{
for (int v=0; v<=272; v++)
{
if ((p-132)(p-132)+(v-8)(v-8)<=64)
{
glPushMatrix();
p-=116;
v+=240-16l;
glTranslatef(-116, 240-16l, 0);
glVertex2f(p, v);
glPopMatrix();
}
}
}
}
}
else
{
int b=15;
if (l%2)
{
for (int p=0; p<=304; p++)
{
for (int v=0; v<=272; v++)
{
if ((p-132)(p-132)+(v-8)(v-8)<=64)
{
glPushMatrix();
p+=116;
v+=240-16l;
glTranslatef(116, 240-16l, 0);
glVertex2f(p, v);
glPopMatrix();
}
}
}
}
else
{
for (int p=0; p<=304; p++)
{
for (int v=0; v<=272; v++)
{
if ((p-132)(p-132)+(v-8)(v-8)<=64)
{
glPushMatrix();
p+=124;
v+=240-16l;
glTranslatef(124, 240-16l, 0);
glVertex2f(p, v);
glPopMatrix();
}
}
}
}
}
}
}
}[/LEFT]
And this is the screen:
[ATTACH=CONFIG]236[/ATTACH]