正文
增加 41 行删除 41 行
17 行未改动181920212223242526272829303132333435363 行未改动404142434445464748495051525354554 行未改动6061626364656667685 行未改动74757677787980818276 行未改动15916016116216316416516616716816917017117217324 行未改动19819920020120220320420520620720820921021121221321421521621721821922022122222325 行未改动2492502512522532542552562574 行未改动26226326426526626726826927029 行未改动30030130230330430530630730827 行未改动336337338339340341342343344345346347348349350351352353354165 行未改动全部展开5205215225235245255265275284 行未改动53353453553653753853954054122 行未改动56456556656756856957057157297 行未改动6706716726736746756766776786 行未改动68568668768868969069169269310 行未改动70470570670770870971071171271371481 行未改动79679779879980080180280380471 行未改动87687787887988088188288388418 行未改动90390490590690790890991091143 行未改动95595695795895996096196296339 行未改动10031004100510061007100810091010101129 行未改动10411042104310441045104610471048104919 行未改动10691070107110721073107410751076107788 行未改动11661167116811691170117111721173117448 行未改动122312241225122612271228122912301231107 行未改动全部展开133913401341134213431344134513461347114 行未改动全部展开14621463146414651466146714681469147051 行未改动152215231524152515261527152815291530153151 行未改动158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316142 行未改动17 行未改动int anim;}plane;//控制台小飞机void Handle(bool flag) {HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_CURSOR_INFO cci;GetConsoleCursorInfo(hOut, &cci);cci.bVisible = flag;SetConsoleCursorInfo(hOut, &cci);}//隐藏控制台光标void SetConsole(int x, int y){COORD position;3 行未改动}//建立函数 移动光标 第一个参数为行void Clear(int x, int y, int lenth) {SetConsole(x, y);REP(i, 1, lenth)printf(" ");}//清除第x行y列开始的控制台输出 注:清除完后需要重定向void Print(string s, int t) {for (int i = 0; i < s.size(); i++) { //使用UNICODEif (s[i] < 0) { //汉字cout << s[i] << s[i + 1];i++;4 行未改动}//实现间隔一定时间输出一个字void Loading() {for (int i = 1; i <= 5; i++) {printf("/ ");Sleep(200); printf("\b\b");printf("- ");Sleep(200); printf("\b\b");5 行未改动printf(" ");}//转圈圈void DrawDialogBox(int x, int y, int numLine) {SetConsole(x, y);printf(" ————————");for (int i = 1; i <= numLine - 2; i++) {SetConsole(x + i, y);76 行未改动printf("—");}//绘制从x1到x2的控制台操作窗口void AnimMap(int x1, int x2, int y, int lenth) {int mid = (x1 + x2) / 2;SetConsole(mid, y);Print(" ", 3);REP(i, 1, lenth)Print("—", 3);REP(i, 1, (x2 - x1) / 2) {DrawMap(mid - i, mid + i, y, lenth);Sleep(10);}}24 行未改动printf(" "); SetConsole(x + 3, y);printf(" "); BackgroundBlack(); printf(" "); BackgroundWhite(); printf(" "); SetConsole(x + 4, y);printf(" "); BackgroundBlack(); printf(" "); BackgroundWhite(); printf(" "); SetConsole(x + 5, y);printf(" "); BackgroundBlack(); printf(" "); BackgroundWhite(); printf(" "); SetConsole(x + 6, y);printf(" ");BackgroundBlack();}void Drawand(int x, int y) {x++;//比其他两个字母少一行y -= 2;//画的时候多了两格出来SetConsole(x, y + 5); BackgroundWhite();printf(" ");SetConsole(x + 1, y + 4); printf(" ");SetConsole(x + 1, y + 8); printf(" ");SetConsole(x + 2, y + 5); printf(" ");SetConsole(x + 3, y + 3); printf(" "); SetConsole(x + 3, y + 7); printf(" ");SetConsole(x + 3, y + 9); printf(" ");SetConsole(x + 4, y + 2); printf(" "); SetConsole(x + 4, y + 8); printf(" ");SetConsole(x + 5, y + 3); printf(" "); SetConsole(x + 5, y + 9); printf(" ");BackgroundBlack();}void DrawK(int x, int y) {BackgroundWhite();SetConsole(x, y);printf(" "); SetConsole(x, y + 8); printf(" ");SetConsole(x + 1, y); printf(" "); SetConsole(x + 1, y + 6); printf(" ");SetConsole(x + 2, y); printf(" "); SetConsole(x + 2, y + 4); printf(" ");25 行未改动}//输出对话,定位跟随对话框int consoleX, consoleY;void PrintConsole(int x, string content, int speed, bool stop) {SetConsole(consoleX + x, consoleY);cout << " ";SetConsole(consoleX + x, consoleY);Print(content, speed);4 行未改动}//从控制台第x行输出控制台内容(从0开始)void PrintPlane() {//(x, y)为机头坐标 所以-2switch (plane.anim) { //先写绘制case 0 :SetConsole(plane.x, plane.y - 2);29 行未改动if (plane.y < 3)plane.y = 3;if (plane.y > 61)plane.y = 61;}void MovePlane(int speed) {plane.preX = plane.x, plane.preY = plane.y;Clear(plane.preX, plane.preY - 2, 6);Clear(plane.preX + 1, plane.preY - 2, 6);Clear(plane.preX + 2, plane.preY - 2, 6);27 行未改动if (consolePlaneLeftTime < 7000) {SetConsole(consoleX + 1, consoleY);cout << "通讯记录云同步信号: ";ForeYellow(); cout << "一般"; BackgroundBlack();}if (consolePlaneLeftTime < 6400) {SetConsole(consoleX + 1, consoleY);cout << "通讯记录云同步信号: ";ForeGreen(); cout << "良好"; BackgroundBlack();}return 1;}void Chapter1() {puts("GRIFFIN & KRYUGER Combat Operation System[版本 10.0.19042.1348]");puts("(c) GRIFFIN & KRYUGER Corporation。保留所有权利。\n");printf("C:\\Users\\Commander>");Sleep(3000);165 行未改动全部展开IMAGE img_heliEnemy[2];//55 * 67void LoadResource() {loadimage(&img_background, _T("./image/background/Background.jpg"));loadimage(&img_backbackground, _T("./image/background/backbackground4.png"));loadimage(&img_dialoguebox, _T("./image/UI/dialoguebox.png"));4 行未改动loadimage(&img_gundam[1], _T("./image/player/Gundam.png"));loadimage(&img_rush[0], _T("./image/player/rushxor.jpg"));loadimage(&img_rush[1], _T("./image/player/rush2.png"));loadimage(&img_idle[0], _T("./image/player/Idlexor.jpg"));loadimage(&img_idle[1], _T("./image/player/Idle.png"));loadimage(&img_idle[2], _T("./image/player/Idledark1.png"));22 行未改动}//载入图片资源int lastUpdateBackground, backgroundY = 981;void PrintBackground(int t) {if (runTime - lastUpdateBackground > t && backgroundY > 0) {backgroundY--;lastUpdateBackground = runTime;}97 行未改动}eBullet[210];int lastRushAnim, animRush = 0;void DrawPlayer(){if (!player.animHit) {putimage(player.x + 59, player.y, 70, 85, &img_gundam[0], (player.anim + 2) * 70, 0, NOTSRCERASE);//绘制高达本体putimage(player.x + 59, player.y, 70, 85, &img_gundam[1], (player.anim + 2) * 70, 0, SRCINVERT);}6 行未改动int t;//喷射闪烁时间if (player.rush == -1)t = 10;//惩罚闪烁变慢else t = 5;if (runTime - lastRushAnim > t) {animRush = (animRush + 70) % 140;lastRushAnim = runTime;}if (player.rush == 1) {//冲刺10 行未改动}}//绘制高达 t为火焰喷射循环时间void DrawBullet() {REP(i, 0, 39) {if (bullet[i].alive) {putimage(bullet[i].x + 59, bullet[i].y, &img_bullet[0], NOTSRCERASE);putimage(bullet[i].x + 59, bullet[i].y, &img_bullet[1], SRCINVERT);}}81 行未改动}}}void GundamPositionJudge() {if (player.x < 0)player.x = 0;if (player.y < 0)player.y = 0;if (player.x + 70 > 850)player.x = 850 - 70;if (player.y + 85 > 720)player.y = 720 - 85;71 行未改动player.speed = 5;player.rush = 0;}REP(i, 0, 39) { //子弹相关if (bullet[i].alive) {bullet[i].x += bullet[i].speedX;bullet[i].y += bullet[i].speedY;if (bullet[i].y < -30 || bullet[i].x < -4 || bullet[i].x > 831) { bullet[i].alive = false; continue; }REP(j, 0, 39) {18 行未改动}}}}REP(i, 0, 39) {//敌机相关if (enemy[i].alive) {enemy[i].x += enemy[i].speedX;//更新位置enemy[i].y += enemy[i].speedY;43 行未改动shootDir *= -1;if (shootDir < 0)speedX *= -1;CreatEBullet(enemy[i].type, enemy[i].x + shootDir, enemy[i].y, speedX, speedY);}enemy[i].shootCD++;if (enemy[i].shootCD == 30)enemy[i].shootCD = 0;}}}39 行未改动//检查位置合法、检查状态更新等void CreatBullet(int x, int y, bool isplayer, int speedX) {static int lastCreatBulletTime = -999, creatBulletCD = 5;//太快重复bugREP(i, 0, 39) {if (!bullet[i].alive && runTime - lastCreatBulletTime > creatBulletCD) {lastCreatBulletTime = runTime;bullet[i].x = x + 21, bullet[i].y = y;bullet[i].speedX = speedX;29 行未改动}}int animValue, bulletDegree, degreeValue;void MoveGundam(int speed) {if (player.opt == -1)return;bool flag1 = false, flag2 = false;if (GetAsyncKeyState('W'))player.y -= speed;if (GetAsyncKeyState('S'))player.y += speed;19 行未改动if (GetAsyncKeyState(VK_SPACE)) {if (player.opt == 1 && singleFinish) {continueDialogue = true;}else if (player.opt == 2) {//战斗模式CreatBullet(player.x, player.y, true, bulletDegree);}}if (!flag1) {//AD没按或者全按,复位88 行未改动}break;case 10:if (indexDialogue < 4)return;//到第三句前不触发if (indexDialogue == 4) {player.opt = 0;//对话禁止bulletDegree = 0;rushCD = 2000;//CD 999999 -> 2000 就是开启这个功能if (player.rush) {48 行未改动case 36:if (indexDialogue == 16) {//生成敌机static int flag36 = 1;if (flag36)CreatEnemy(1, 400, -80, 0, 1, false, 999), flag36 = 0;stage++;}break;case 37:107 行未改动全部展开if (numEnemy == 0) {continueDialogue = true;player.opt = 1;stage += 10;}}break;case 110:if (indexDialogue == 29) {114 行未改动全部展开}void PrintConsoleText() {outtextxy(920, 452, _T("通讯记录云同步信号:"));//第一行if (tongxun == 1) setcolor(GREEN),outtextxy(1080, 452, _T("良好"));else if (tongxun == 0) setcolor(YELLOW), outtextxy(1080, 452, _T("一般"));else setcolor(RED), outtextxy(1080, 452, _T("极差"));setcolor(WHITE);51 行未改动else setcolor(RGB(255, 215, 0)), outtextxy(1040, 552, s), setcolor(WHITE);}}}if (indexDialogue >= 9) {outtextxy(920, 572, _T(" >战斗模块:"));if (indexDialogue == 9) {setcolor(RGB(255, 215, 0));outtextxy(1020, 572, _T("LOADING"));51 行未改动printf("%d\n", player.hp);}//总绘制函数void Chapter2() {InitGraph();BeginBatchDraw();//双缓冲绘图while (1) {GameDraw();FlushBatchDraw();runTime++;Sleep(1);}EndBatchDraw();}int main() {Init();//_getch();//Chapter1();Chapter2();//Handle(FALSE);//test1();getchar();return 0;}2 行未改动17 行未改动181920212223242526272829303132333435363 行未改动404142434445464748495051525354554 行未改动6061626364656667685 行未改动74757677787980818276 行未改动15916016116216316416516616716816917017117217324 行未改动19819920020120220320420520620720820921021121221321421521621721821922022122222325 行未改动2492502512522532542552562574 行未改动26226326426526626726826927029 行未改动30030130230330430530630730827 行未改动336337338339340341342343344345346347348349350351352353354165 行未改动全部展开5205215225235245255265275284 行未改动53353453553653753853954054122 行未改动56456556656756856957057157297 行未改动6706716726736746756766776786 行未改动68568668768868969069169269310 行未改动70470570670770870971071171271371481 行未改动79679779879980080180280380471 行未改动87687787887988088188288388418 行未改动90390490590690790890991091143 行未改动95595695795895996096196296339 行未改动10031004100510061007100810091010101129 行未改动10411042104310441045104610471048104919 行未改动10691070107110721073107410751076107788 行未改动11661167116811691170117111721173117448 行未改动122312241225122612271228122912301231107 行未改动全部展开133913401341134213431344134513461347114 行未改动全部展开14621463146414651466146714681469147051 行未改动152215231524152515261527152815291530153151 行未改动158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316142 行未改动17 行未改动int anim;}plane;//控制台小飞机void Handle(bool flag) {HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_CURSOR_INFO cci;GetConsoleCursorInfo(hOut, &cci);cci.bVisible = flag;SetConsoleCursorInfo(hOut, &cci);}//隐藏控制台光标void SetConsole(int x, int y){COORD position;3 行未改动}//建立函数 移动光标 第一个参数为行void Clear(int x, int y, int lenth) {SetConsole(x, y);REP(i, 1, lenth)printf(" ");}//清除第x行y列开始的控制台输出 注:清除完后需要重定向void Print(string s, int t) {for (int i = 0; i < s.size(); i++) { //使用UNICODEif (s[i] < 0) { //汉字cout << s[i] << s[i + 1];i++;4 行未改动}//实现间隔一定时间输出一个字void Loading() {for (int i = 1; i <= 5; i++) {printf("/ ");Sleep(200); printf("\b\b");printf("- ");Sleep(200); printf("\b\b");5 行未改动printf(" ");}//转圈圈void DrawDialogBox(int x, int y, int numLine) {SetConsole(x, y);printf(" ————————");for (int i = 1; i <= numLine - 2; i++) {SetConsole(x + i, y);76 行未改动printf("—");}//绘制从x1到x2的控制台操作窗口void AnimMap(int x1, int x2, int y, int lenth) {int mid = (x1 + x2) / 2;SetConsole(mid, y);Print(" ", 3);REP(i, 1, lenth)Print("—", 3);REP(i, 1, (x2 - x1) / 2) {DrawMap(mid - i, mid + i, y, lenth);Sleep(10);}}24 行未改动printf(" "); SetConsole(x + 3, y);printf(" "); BackgroundBlack(); printf(" "); BackgroundWhite(); printf(" "); SetConsole(x + 4, y);printf(" "); BackgroundBlack(); printf(" "); BackgroundWhite(); printf(" "); SetConsole(x + 5, y);printf(" "); BackgroundBlack(); printf(" "); BackgroundWhite(); printf(" "); SetConsole(x + 6, y);printf(" ");BackgroundBlack();}void Drawand(int x, int y) {x++;//比其他两个字母少一行y -= 2;//画的时候多了两格出来SetConsole(x, y + 5); BackgroundWhite();printf(" ");SetConsole(x + 1, y + 4); printf(" ");SetConsole(x + 1, y + 8); printf(" ");SetConsole(x + 2, y + 5); printf(" ");SetConsole(x + 3, y + 3); printf(" "); SetConsole(x + 3, y + 7); printf(" ");SetConsole(x + 3, y + 9); printf(" ");SetConsole(x + 4, y + 2); printf(" "); SetConsole(x + 4, y + 8); printf(" ");SetConsole(x + 5, y + 3); printf(" "); SetConsole(x + 5, y + 9); printf(" ");BackgroundBlack();}void DrawK(int x, int y) {BackgroundWhite();SetConsole(x, y);printf(" "); SetConsole(x, y + 8); printf(" ");SetConsole(x + 1, y); printf(" "); SetConsole(x + 1, y + 6); printf(" ");SetConsole(x + 2, y); printf(" "); SetConsole(x + 2, y + 4); printf(" ");25 行未改动}//输出对话,定位跟随对话框int consoleX, consoleY;void PrintConsole(int x, string content, int speed, bool stop) {SetConsole(consoleX + x, consoleY);cout << " ";SetConsole(consoleX + x, consoleY);Print(content, speed);4 行未改动}//从控制台第x行输出控制台内容(从0开始)void PrintPlane() {//(x, y)为机头坐标 所以-2switch (plane.anim) { //先写绘制case 0 :SetConsole(plane.x, plane.y - 2);29 行未改动if (plane.y < 3)plane.y = 3;if (plane.y > 61)plane.y = 61;}void MovePlane(int speed) {plane.preX = plane.x, plane.preY = plane.y;Clear(plane.preX, plane.preY - 2, 6);Clear(plane.preX + 1, plane.preY - 2, 6);Clear(plane.preX + 2, plane.preY - 2, 6);27 行未改动if (consolePlaneLeftTime < 7000) {SetConsole(consoleX + 1, consoleY);cout << "通讯记录云同步信号: ";ForeYellow(); cout << "一般"; BackgroundBlack();}if (consolePlaneLeftTime < 6400) {SetConsole(consoleX + 1, consoleY);cout << "通讯记录云同步信号: ";ForeGreen(); cout << "良好"; BackgroundBlack();}return 1;}void Chapter1() {puts("GRIFFIN & KRYUGER Combat Operation System[版本 10.0.19042.1348]");puts("(c) GRIFFIN & KRYUGER Corporation。保留所有权利。\n");printf("C:\\Users\\Commander>");Sleep(3000);165 行未改动全部展开IMAGE img_heliEnemy[2];//55 * 67void LoadResource() {loadimage(&img_background, _T("./image/background/Background.jpg"));loadimage(&img_backbackground, _T("./image/background/backbackground4.png"));loadimage(&img_dialoguebox, _T("./image/UI/dialoguebox.png"));4 行未改动loadimage(&img_gundam[1], _T("./image/player/Gundam.png"));loadimage(&img_rush[0], _T("./image/player/rushxor.jpg"));loadimage(&img_rush[1], _T("./image/player/rush2.png"));loadimage(&img_idle[0], _T("./image/player/Idlexor.jpg"));loadimage(&img_idle[1], _T("./image/player/Idle.png"));loadimage(&img_idle[2], _T("./image/player/Idledark1.png"));22 行未改动}//载入图片资源int lastUpdateBackground, backgroundY = 981;void PrintBackground(int t) {if (runTime - lastUpdateBackground > t && backgroundY > 0) {backgroundY--;lastUpdateBackground = runTime;}97 行未改动}eBullet[210];int lastRushAnim, animRush = 0;void DrawPlayer(){if (!player.animHit) {putimage(player.x + 59, player.y, 70, 85, &img_gundam[0], (player.anim + 2) * 70, 0, NOTSRCERASE);//绘制高达本体putimage(player.x + 59, player.y, 70, 85, &img_gundam[1], (player.anim + 2) * 70, 0, SRCINVERT);}6 行未改动int t;//喷射闪烁时间if (player.rush == -1)t = 10;//惩罚闪烁变慢else t = 5;if (runTime - lastRushAnim > t) {animRush = (animRush + 70) % 140;lastRushAnim = runTime;}if (player.rush == 1) {//冲刺10 行未改动}}//绘制高达 t为火焰喷射循环时间void DrawBullet() {REP(i, 0, 39) {if (bullet[i].alive) {putimage(bullet[i].x + 59, bullet[i].y, &img_bullet[0], NOTSRCERASE);putimage(bullet[i].x + 59, bullet[i].y, &img_bullet[1], SRCINVERT);}}81 行未改动}}}void GundamPositionJudge() {if (player.x < 0)player.x = 0;if (player.y < 0)player.y = 0;if (player.x + 70 > 850)player.x = 850 - 70;if (player.y + 85 > 720)player.y = 720 - 85;71 行未改动player.speed = 5;player.rush = 0;}REP(i, 0, 39) { //子弹相关if (bullet[i].alive) {bullet[i].x += bullet[i].speedX;bullet[i].y += bullet[i].speedY;if (bullet[i].y < -30 || bullet[i].x < -4 || bullet[i].x > 831) { bullet[i].alive = false; continue; }REP(j, 0, 39) {18 行未改动}}}}REP(i, 0, 39) {//敌机相关if (enemy[i].alive) {enemy[i].x += enemy[i].speedX;//更新位置enemy[i].y += enemy[i].speedY;43 行未改动shootDir *= -1;if (shootDir < 0)speedX *= -1;CreatEBullet(enemy[i].type, enemy[i].x + shootDir, enemy[i].y, speedX, speedY);}enemy[i].shootCD++;if (enemy[i].shootCD == 30)enemy[i].shootCD = 0;}}}39 行未改动//检查位置合法、检查状态更新等void CreatBullet(int x, int y, bool isplayer, int speedX) {static int lastCreatBulletTime = -999, creatBulletCD = 5;//太快重复bugREP(i, 0, 39) {if (!bullet[i].alive && runTime - lastCreatBulletTime > creatBulletCD) {lastCreatBulletTime = runTime;bullet[i].x = x + 21, bullet[i].y = y;bullet[i].speedX = speedX;29 行未改动}}int animValue, bulletDegree, degreeValue;void MoveGundam(int speed) {if (player.opt == -1)return;bool flag1 = false, flag2 = false;if (GetAsyncKeyState('W'))player.y -= speed;if (GetAsyncKeyState('S'))player.y += speed;19 行未改动if (GetAsyncKeyState(VK_SPACE)) {if (player.opt == 1 && singleFinish) {continueDialogue = true;}else if (player.opt == 2) {//战斗模式CreatBullet(player.x, player.y, true, bulletDegree);}}if (!flag1) {//AD没按或者全按,复位88 行未改动}break;case 10:if (indexDialogue < 4)return;//到第三句前不触发if (indexDialogue == 4) {player.opt = 0;//对话禁止bulletDegree = 0;rushCD = 2000;//CD 999999 -> 2000 就是开启这个功能if (player.rush) {48 行未改动case 36:if (indexDialogue == 16) {//生成敌机static int flag36 = 1;if (flag36)CreatEnemy(1, 400, -80, 0, 1, false, 999), flag36 = 0;stage++;}break;case 37:107 行未改动全部展开if (numEnemy == 0) {continueDialogue = true;player.opt = 1;stage += 10;}}break;case 110:if (indexDialogue == 29) {114 行未改动全部展开}void PrintConsoleText() {outtextxy(920, 452, _T("通讯记录云同步信号:"));//第一行if (tongxun == 1) setcolor(GREEN),outtextxy(1080, 452, _T("良好"));else if (tongxun == 0) setcolor(YELLOW), outtextxy(1080, 452, _T("一般"));else setcolor(RED), outtextxy(1080, 452, _T("极差"));setcolor(WHITE);51 行未改动else setcolor(RGB(255, 215, 0)), outtextxy(1040, 552, s), setcolor(WHITE);}}}if (indexDialogue >= 9) {outtextxy(920, 572, _T(" >战斗模块:"));if (indexDialogue == 9) {setcolor(RGB(255, 215, 0));outtextxy(1020, 572, _T("LOADING"));51 行未改动printf("%d\n", player.hp);}//总绘制函数void Chapter2() {InitGraph();BeginBatchDraw();//双缓冲绘图while (1) {GameDraw();FlushBatchDraw();runTime++;Sleep(1);}EndBatchDraw();}int main() {Init();//_getch();//Chapter1();Chapter2();//Handle(FALSE);//test1();getchar();return 0;}2 行未改动