版本比较
v2
正文
增加 41 行删除 41 行
17 行未改动1819202122222324252627282930313232333435363 行未改动4041424344444546474849505151525354554 行未改动606162636464656667685 行未改动7475767778787980818276 行未改动15916016116216316316416516616716816916917017117217324 行未改动19819920020120220220320420520520620720820920921021121221321421521621721821921922022122222325 行未改动2492502512522532532542552562574 行未改动26226326426526626626726826927029 行未改动30030130230330430430530630730827 行未改动336337338339340340341342343344345346347348349350350351352353354165 行未改动全部展开5205215225235245245255265275284 行未改动53353453553653753753853954054122 行未改动56456556656756856856957057157297 行未改动6706716726736746746756766776786 行未改动68568668768868968969069169269310 行未改动70470570670770870870971071071171271371481 行未改动79679779879980080080180280380471 行未改动87687787887988088088188288388418 行未改动90390490590690790790890991091143 行未改动95595695795895995996096196296339 行未改动100310041005100610071007100810091010101129 行未改动104110421043104410451045104610471048104919 行未改动106910701071107210731073107410751076107788 行未改动116611671168116911701170117111721173117448 行未改动1223122412251226122712271228122912301231107 行未改动全部展开1339134013411342134313431344134513461347114 行未改动全部展开146214631464146514661466146714681469147051 行未改动15221523152415251526152715261527152815291530153151 行未改动1583158415851586158715871588158915901590159115921593159415951596159715981599160016001601160216031604160516061607160816091609161016111612161316142 行未改动17 行未改动 int anim; }plane;//控制台小飞机
void Handle(bool flag) { 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) void SetConsole(int x, int y)
{
COORD position;3 行未改动
}//建立函数 移动光标 第一个参数为行
void Clear(int x, int y, int lenth) { void Clear(int x, int y, int lenth) { SetConsole(x, y); REP(i, 1, lenth) printf(" "); }//清除第x行y列开始的控制台输出 注:清除完后需要重定向
void Print(string s, int t) { void Print(string s, int t) { for (int i = 0; i < s.size(); i++) { //使用UNICODE if (s[i] < 0) { //汉字 cout << s[i] << s[i + 1]; i++;4 行未改动 }//实现间隔一定时间输出一个字
void Loading() { for (int i = 1; i <= 5; i++) { 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) { 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) { 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) { 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(" "); printf(" "); BackgroundBlack(); }void Drawand(int x, int y) { void Drawand(int x, int y) { x++;//比其他两个字母少一行 y -= 2;//画的时候多了两格出来 SetConsole(x, y + 5); BackgroundWhite(); printf(" "); 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) { 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) { 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() { void PrintPlane() { //(x, y)为机头坐标 所以-2 switch (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) { 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() { 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 * 67
void LoadResource() { void 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) { 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) { if (runTime - lastRushAnim > t) { animRush = (animRush + 70) % 140; lastRushAnim = runTime; } if (player.rush == 1) {//冲刺10 行未改动 } }//绘制高达 t为火焰喷射循环时间
void DrawBullet() { void DrawBullet() { REP(i, 0, 39) { if (bullet[i].alive) { 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() { 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) { 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++; 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;//太快重复bug REP(i, 0, 39) { REP(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) { 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) {//战斗模式 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) { 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("良好")); 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) {
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() { void Chapter2() { InitGraph(); BeginBatchDraw();//双缓冲绘图 while (1) { while (1) { GameDraw(); FlushBatchDraw(); runTime++; Sleep(1); } EndBatchDraw(); }
int main() { int main() { Init(); //_getch();
//Chapter1(); Chapter2();
//Handle(FALSE); //test1();
getchar(); return 0; }
2 行未改动