So for my first game I'm making an asteroids clone and I'm trying to draw an asteroid with lines that has pseudo 3D "rotation". I'm trying to do this without getting overly complicated and just moving 4 y coords when the "z" coord is increased .2 every frame. It changes to -.2 when a y coord is at the edge of the asteroid (distance from the center is greater than radius).
The problem is I think the functions decrease slower than they increase so every 2nd rotation or so the asteroid looks fatter when all the y coords are passing each other in the center. If that makes sense. Any help would be appreciated. I left out the SFML drawing in my example, but obviously I would create lines with the x and y coords.
//init
double x[6] = {90,150,210,150,150,150};
double y[6] = {100,100,100,100,40,160};
double radius = 60;
double centerY = 100;
double spinSpeed = .2;
//in game loop
//Reverse function when halfway to simulate spin
if ((y[1] - centerY) >= radius)
{
count = -spinSpeed;
}
else if ((y[1] - centerY) <= -radius)
{
count = spinSpeed;
}
if ((y[4] - centerY) >= radius-5)
{
count2 = -spinSpeed;
}
else if ((y[4] - centerY) <= -radius)
{
count2 = spinSpeed;
}
double z2 = sqrt(y[1]) + count;
double z6 = sqrt(y[5]) - count2;
y[1] = pow(z2,2.0);
y[3] = centerY-(y[1] - centerY);
y[5] = pow(z6,2.0) ;
y[4] = centerY-(y[5] - centerY);