Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created August 27, 2019 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviceplususer/733df25b990438cedb7c34159076fd2c to your computer and use it in GitHub Desktop.
Save deviceplususer/733df25b990438cedb7c34159076fd2c to your computer and use it in GitHub Desktop.
...
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