#include <stdio.h>
int main() {
int hungry = 5, happy = 5, health = 5;
char name[10];
scanf("%s", name);
while(1){
for(int i=0; i<10; i++){
printf("%c", name[i]);
}
printf(" [펫 상태]\n");
printf("배고픔: %d, 행복감: %d, 체력: %d\n", hungry, happy, health);
printf("시작! 1: 밥 주기 2: 놀아주기 3: 쉬기 4: 종료\n\n");
int choice;
scanf("%d", &choice);
if (choice == 1){
hungry += 2;
}else if (choice == 2){
happy += 2;
}else if(choice == 3){
health += 2;
}else if(choice == 4){
break;
}
hungry--;
happy--;
health--;
if (hungry <= 2 || happy <= 2 || health <= 2){
printf(" /|__|\\\n");
printf("(=ㅠ.ㅠ=)\n");
printf(" |v v|\n\n");
}else{
printf(" /|__|\\\n");
printf("(=^ㅁ^=)\n");
printf("<| |>\n\n");
}
//스탯의 최대치를 10으로 설정
if(hungry >= 10){
hungry = 10;
}
if(happy >= 10){
happy = 10;
}
if(health >= 10){
health = 10;
}
//스탯 중 하나라도 0이되면 게임오버
if (hungry == 0 || happy == 0 || health == 0){
printf("\nGame Over!");
break;
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: