I’m working on a horse racing game. Each time the game starts a random horse wins because of the intervals I randomly add to their speed . I ve no problem until here. My question is about the sprites seen per second. I ve four sprites for each horse and using sourceRect and DestRect method I draw them. So, the horses all are running in the game:) and one of them wins. But frame shown per second , I cant adjust it. Below , I just copied the codes I used for the fifth horse: (the same codes also for other horses like 1,2,3,4)
Texture2D horse5;
float elapsed5;
float delay5 = 100f;
int frames5 = 0;
Rectangle destRect5;
Rectangle sourceRect5;
destRect5 = new Rectangle(500, 435, 100, 100);
horse5 = Content.Load(“horse5”);
elapsed5 += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
if (elapsed5 >= delay5)
{
if (frames5 >= 3)
{
frames5 = 0;
}
else
{
frames5++;
}
elapsed5 = 0;
}
sourceRect5 = new Rectangle(100 * frames, 0, 100, 100);
spriteBatch.Draw(horse5, destRect5, sourceRect5, Color.White);
The other horses delay times are all the same. So, things seem ok. But when I want one of the horses run slower or faster ( i mean the frame rate), that I change the delay=100f to delay=1f or delay=5000f , nothing changes. Still all the horses frame speeds are same. How can I control this?
float elapsed4;
float delay4 = 100f;
int frames4 = 0;
float elapsed3;
float delay3 = 100f;
int frames3 = 0;
float elapsed2;
float delay2 = 100f;
int frames2 = 0;
float elapsed1;
float delay1 = 100f;
int frames1 = 0;