1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <windows.h>
struct Monster { float blood; int num; int level; float coordinate[3]; char name[10]; };
struct Monster a;
void InitializationMonster() { a.num = 1; a.level = 10; a.blood = 100.0; a.coordinate[0] = 1.0; a.coordinate[1] = 2.0; a.coordinate[2] = 3.0; strcpy(a.name, "Monster1"); }
void PrintMonster() { printf("怪物数量:%d------怪物坐标:%.2f , %.2f , %.2f------怪物等级:%d------怪物血量:%.2f------怪物名称:%s", a.num, a.coordinate[0], a.coordinate[1], a.coordinate[2], a.level, a.blood, a.name); }
void Monster_attacked() { a.blood -= 20; }
int main() { InitializationMonster(); PrintMonster(); SetConsoleTitleA("Game V1.0");
printf("欢迎来到本游戏!本游戏将带你进行全新的体验!\n\n\n"); printf("初始化ing."); for (int i = 0; i < 6; i++) { printf("."); Sleep(500); } Sleep(2000); InitializationMonster(); printf("\n\n\n初始化完成!!!\n\n\n-----------------------------------------------------------------------------------------------------------------\n\n\n\n"); printf("怪物结构体地址:0x%X \n\n", &a); printf("进入地图----[地狱之眼]:\n\n"); printf("发现怪物!血量是否进行攻击 (Y/N):"); while (1) { char Getkey; scanf_s("%c", &Getkey); switch (Getkey) { case 'Y': do { PrintMonster(); Monster_attacked(); } while (a.blood>0); PrintMonster(); printf("\n怪物已经死亡!获得经验:200 \n\n"); break; case 'N': printf("你取消了打怪!\n\n"); break; default: break; } } getchar(); return 0; }
|