My animated sprite routine worked, but I was worried. You see it did the delay between frames by using Time=Time+1; As you know a commnd like this on a machine twice as fast as my computer would run that command faster. So I had a go at updating my animated sprite function.
I just found a command which is in time.h called clock(); It seems to count the milliseconds passed since the program has started. Anyway now I have updated it. I can actually time my sprite animation in milliseconds.
This is my old routine
Code: Select all
bool SpriteLoader::Sprite(double x,double y, int Frametime,D3DGraphics* gfx)
{
DrawSprite(x,y,gfx);
if (Time==Frametime) {
Frame=Frame+1;
Time=0;
}
if (Frame==NumberOfFrames) {
Frame=0;
return false;
} // This starts the animation again
Time=Time+1;
return true;
}
Code: Select all
bool SpriteLoader::Sprite(double x,double y, float Frametime,D3DGraphics* gfx)
{
DrawSprite(x,y,gfx);
if (Time==0)
{
endtime= clock()+Frametime;
Time=1;
}
if (clock()>=endtime) {
Frame=Frame+1;
Time=0;
}
if (Frame==NumberOfFrames) {
Frame=0;
return false;
} // This starts the animation again
return true;
}
Also in my Missile routine. I have a velocity, but I am also thinking this might compute faster on a faster computer. So do you think I should do something like velocity * time; I think I had to do something like this in XNA.
Asimov