void food£¨void£© {
int i;
int food_crush_on = 0;//food°¡ ¹ì ¸öÅëÁÂÇ¥¿¡ »ý±æ °æ¿ì on
int r = 0; //³¼ö »ý¼º¿¡ »çµ¿µÇ´Â º¯¼ö
gotoxy£¨MAP_ADJ_X, MAP_ADJ_Y + MAP_Y, " YOUR SCORE: "£©; //Á¡¼öÇ¥½Ã
printf£¨"%3d, LAST SCORE: %3d, BEST SCORE: %3d", score, last_score, best_score£©;
while £¨1£© {
food_crush_on = 0;
srand£¨£¨unsigned£©time£¨NULL£© + r£©; //³¼öÇ¥»ý¼º
food_x = £¨rand£¨£© % £¨MAP_X - 2£©£© + 1; //³¼ö¸¦ ÁÂÇ¥°ª¿¡ ³ÖÀ½
food_y = £¨rand£¨£© % £¨MAP_Y - 2£©£© + 1;
for £¨i = 0; i < length; i++£© { //food°¡ ¹ì ¸öÅë°ú °ãÄ¡´ÂÁö È®ÀÎ
if £¨food_x == x[i] && food_y == y[i]£© {
food_crush_on = 1; //°ãÄ¡¸é food_crush_on ¸¦ on
r++;
break;
}
}
if £¨food_crush_on == 1£© continue; //°ãÃÆÀ» °æ¿ì while¹®À» ´Ù½Ã ½ÃÀÛ
gotoxy£¨MAP_ADJ_X + food_x, MAP_ADJ_Y + food_y, "¤¥"£©; //¾È°ãÃÆÀ» °æ¿ì ÁÂÇ¥°ª¿¡ food¸¦ Âï°í
speed -= 3; //¼Óµµ Áõ°¡
break;
}
}
void item£¨void£© {
int i;
int item_crush_on = 0;//itemÀÌ ¹ì ¸öÅëÁÂÇ¥¿¡ »ý±æ °æ¿ì on
int r1 = 1; //³¼ö »ý¼º¿¡ »çµ¿µÇ´Â º¯¼ö
gotoxy£¨MAP_ADJ_X, MAP_ADJ_Y + MAP_Y, " YOUR SCORE: "£©; //Á¡¼öÇ¥½Ã
printf£¨"%3d, LAST SCORE: %3d, BEST SCORE: %3d", score, last_score, best_score£©;
while £¨1£© {
item_crush_on = 0;
srand£¨£¨unsigned£©time£¨NULL£© + r1£©; //³¼öÇ¥»ý¼º
item_x = £¨rand£¨£© % £¨MAP_X - 2£©£© + 1; //³¼ö¸¦ ÁÂÇ¥°ª¿¡ ³ÖÀ½
item_y = £¨rand£¨£© % £¨MAP_Y - 2£©£© + 1;
for £¨i = 0; i < length; i++£© { //food°¡ ¹ì ¸öÅë°ú °ãÄ¡´ÂÁö È®ÀÎ
if £¨item_x == x[i] && item_y == y[i]£© {
item_crush_on = 1; //°ãÄ¡¸é food_crush_on ¸¦ on
r1++;
break;
}
}
if £¨item_crush_on == 1£© continue; //°ãÃÆÀ» °æ¿ì while¹®À» ´Ù½Ã ½ÃÀÛ
gotoxy£¨MAP_ADJ_X + item_x, MAP_ADJ_Y + item_y, "¤£"£©; //¾È°ãÃÆÀ» °æ¿ì ÁÂÇ¥°ª¿¡ item¸¦ Âï°í
speed -= 1; //¼Óµµ Áõ°¡
break;
}
}
¹ì°ÔÀÓ ÄÚµåÁß ÀϺÎÀÔ´Ï´Ù.
¾ÆÀÌÅÛÀ» ¸ÔÀ¸¸é ²¿¸®°¡ ÁÙ¾îµé±äÇϴµ¥ ¸ÔÀº¼ø°£ ¸ÇµÚ ²¿¸®°¡ ±×ÀÚ¸®¿¡ ³²¾Æ¹ö¸®´Âµ¥ ¾î¶»°ÔÇØ¾ßÇÒ±î¿ä ¤Ð¤Ð
±×¸®°í Àå¾Ö¹°µµ °¡ÀåÃÖ±Ù¿¡ ³ª¿Â Àå¾Ö¹°¸¸ ´êÀ¸¸é Á×°í ÀÌÀü°ÍµéÀº À̹ÌÁö¸¸ Á¸ÀçÇÏ³×¿ä ¾î¶²½ÄÀ¸·Î ¼öÁ¤ÇؾßÇÒ±î¿ä..