纯C语言写的一个小型游戏源代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
else
{
p_rover->pwr = 100;
printf( "You have charged up your rover!\n\n");
}
break ;
default:
printf( "\n\n*****ERROR*****\ nln valid Selectio n\n\n");
break ;
}
break ;
case 3:
p_rover->pwr -= 10;/*Dista nee arou nd object- value gained from mapper module. 1
square = -1 power*/
printf( "You have avoided the object!\n\n");
else
{
(p_rover->pwr) -= 7;
printf( "You have destroyed the object!\n\n");
}
break ;
case 2:
if (p_rover->pwr < 3)
printf( "\n\nYou do not have eno ugh power to perform this acti on!\n\n");
struct object_fix
{
char name[20];
char id[5];
char desc[500];
char action[30];
char im[5];
};
struct object_move
{
char name[20];
char id[5];
char desc[500];
int loc;
prin tf( "\nYou have en cou ntered: Dust\n\n");
/* A simple game*/
/*CopyRight: Gua nlin */
#i nclude
<stdio.h>
#i nclude
<stdlib.h>
#i nclude
<stri ng.h>
#i nclude
<time.h>
#i nclude
vconi o.h>
#in clude
<process.h>
}
}
void action( char object, struct rover *p_rover)
{
int selection;
switch (object)
{
case 1:
printf( "\nYou have en cou ntered: A Sandy Rock\ n\n");
printf( "This object can be:\n1.\tDestroyed\n2.\tCollected\nPlease choose acti on 1 or 2:\t");
{
char data[20];
char add_data[20];
int amount;
int x; /* this were the successor keeps it's x&y values*/
int y;
};
struct locati on /*this structure is for the successor lister*/ {
else if (p_rover->strg > 90)
printf( "\n\nYou do not have eno ugh storage space for this object!\n\n");
else
{
(p_rover->pwr) -= 3;
(p_rover->strg) += 10;
printf( "You have collected a sample of the object!\n\n");
printf( "This object can be:\ n1.\tAvoided\nPlease en ter 1:\t");
scanf( "%d" ,&selection);
selecti on = 3;
stats_update(selecti on, p_rover);
break ;
case 4:
float height;
char obj;
};
void stats_update( int selected, struct rover *p_rover)
{
switch (selected)
{
case 1:
if (p_rover->pwr < 7)
printf( "\n\nYou do not have eno ugh power to perform this acti on!\n\n");
int pwr;
int strg;
char im[5];
};
struct rover
{
char name[20];
char id[5];
char desc[500];
int pwr;
int strg;
int location[2];
char im[5];};来自struct map /* this is the map structure*/
break ;
case 4:
p_rover->pwr -= 2;
prin tf( "You have drive n through the obstacle!\n\n");
break ;
case 5:
if (p_rover->pwr == 100)
printf( "\n\nYou do not n eed to charge up!\n\n");
scanf( "%d" ,&selection);
if (selectio n == 1)
selecti on = 3;
stats_update(selecti on, p_rover);
break ;
case 3:
printf( "\nYou have en cou ntered: A Mountain\n\n");
scanf( "%d" ,&selection);
stats_update(selecti on, p_rover);
break ;
case 2:
printf( "\nYou have en cou ntered: A Solid Rock\ n\n");
printf( "This object can be:\ n1.\tAvoided\n2.\tCollected\nPlease choose acti on 1 or 2:\t");
相关文档
最新文档