I am trying to make a function that counts down from 255, and compares the value to a set variable, and then if it compares, sets another variable, and then does something based on what this last variable is. I figured that the best way to do this would be using a for loop, like so:
Code: Select all
for(i = 255; i > 0; i--) {
if(i == stats[0].stats.speed)
turn = 0;
if(i == stats[1].stats.speed)
turn = 1;
if(i == stats[2].stats.speed)
turn = 2;
if(i == stats[3].stats.speed)
turn = 3;
if(i == enemies[0].stats.speed)
turn = 10;
if(i == enemies[1].stats.speed)
turn = 11;
if(i == enemies[2].stats.speed)
turn = 12;
if(i == enemies[3].stats.speed)
turn = 13;
if(i == enemies[4].stats.speed)
turn = 14;
if(i == enemies[5].stats.speed)
turn = 15;
if(i == enemies[6].stats.speed)
turn = 16;
if(i == enemies[7].stats.speed)
turn = 17;
if(i == enemies[8].stats.speed)
turn = 18;
if(turn > -1 || turn < 4) {
bat_do_menu();
break;
}
if(turn > 9 || turn < 19) {
bat_enemy_ai();
break;
}
// Some other code here for stuff to do while in the for loop
}