Hi,
Im fairly new to opengl, and im trying to move a small rectangle (will eventually be a polygon) from
the bottom of my window to the top, not all in one go, just so it
moves from the bottom to top in an animated fashion (its a rocket in a
game if that makes more sense...).
So i approached this as follows, basically every time the main draw
function is called the rectangles y coordinate values are incremented, now
obviously this results in a super fast animation that is barely
visible due to high fps.
So can someone tell me if firstly im approaching this correctly? And secondly how i can get control over the speed the rectangle moves from bottom to top. I think i might need to calculate the delta time, but if i did this i wouldn't know how to use the delta time on the updating of the coordinates?
Here is the relevant code:
Thanks for any help,
Jack
Im fairly new to opengl, and im trying to move a small rectangle (will eventually be a polygon) from
the bottom of my window to the top, not all in one go, just so it
moves from the bottom to top in an animated fashion (its a rocket in a
game if that makes more sense...).
So i approached this as follows, basically every time the main draw
function is called the rectangles y coordinate values are incremented, now
obviously this results in a super fast animation that is barely
visible due to high fps.
So can someone tell me if firstly im approaching this correctly? And secondly how i can get control over the speed the rectangle moves from bottom to top. I think i might need to calculate the delta time, but if i did this i wouldn't know how to use the delta time on the updating of the coordinates?
Here is the relevant code:
Code:
void CShip::DrawMissiles()
{
glColor3f(1.0f, 0.0f, 0.0f);
// Draw missile
if(Missiles.size() != 0)
{
for(int i = 0; i < Missiles.size(); i++)
{
glRectd(Missiles[i].x1, Missiles[i].y1, Missiles[i].x2,
Missiles[i].y2);
}
}
// Move missiles upwards
if(Missiles.size() != 0)
{
for(int i = 0; i < Missiles.size(); i++)
{
Missiles[i].y1++;
Missiles[i].y2++;
}
}
Thanks for any help,
Jack