Created
August 27, 2019 10:10
-
-
Save deviceplususer/733df25b990438cedb7c34159076fd2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
struct Animal | |
{ | |
float x; | |
float y; | |
int life; | |
bool isDead; | |
RGB color; | |
}; | |
... | |
Animal animals[ANIMAL_MAX_NUM];//動物の情報を保持する配列 | |
... | |
for ( int i = 0; i < ANIMAL_MAX_NUM; i++) | |
{ | |
if ( !animals[i].isDead ) | |
{ | |
moveMaxGrass(i);//一番大きな草に向かって移動 | |
//現在地の草を食べて体力回復 | |
animals[i].life += grassMatrix[int(animals[i].x)][int(animals[i].y)]; | |
grassMatrix[int(animals[i].x)][int(animals[i].y)] = 0; | |
//体力減少 | |
animals[i].life -= ANIMAL_DECREASE; | |
//体力が0になったら死亡 | |
if ( animals[i].life <= 0 ) | |
{ | |
animals[i].life = 0; | |
animals[i].isDead = true; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment