免費(fèi)預(yù)覽已結(jié)束,剩余11頁(yè)可下載查看
下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
精選文庫(kù)#include#include#include#include#includeusing namespace std;/*= all the structures =*/typedef struct FrameCOORD position2;int flag;Frame;/*= all the functions =*/void SetPos(COORD a)/ set cursor HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(out, a);void SetPos(int i, int j)/ set cursorCOORD pos=i, j;SetPos(pos);void HideCursor()CONSOLE_CURSOR_INFO cursor_info = 1, 0; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);/把第y行,x1, x2) 之間的坐標(biāo)填充為 chvoid drawRow(int y, int x1, int x2, char ch)SetPos(x1,y);for(int i = 0; i = (x2-x1); i+)coutch;/在a, b 縱坐標(biāo)相同的前提下,把坐標(biāo) a, b 之間填充為 chvoid drawRow(COORD a, COORD b, char ch)if(a.Y = b.Y)drawRow(a.Y, a.X, b.X, ch);elseSetPos(0, 25);couterror code 01:無(wú)法填充行,因?yàn)閮蓚€(gè)坐標(biāo)的縱坐標(biāo)(x)不相等;system(pause);/把第x列,y1, y2 之間的坐標(biāo)填充為 chvoid drawCol(int x, int y1, int y2, char ch)int y=y1;while(y!=y2+1)SetPos(x, y);coutch;y+;/在a, b 橫坐標(biāo)相同的前提下,把坐標(biāo) a, b 之間填充為 chvoid drawCol(COORD a, COORD b, char ch)if(a.X = b.X)drawCol(a.X, a.Y, b.Y, ch);elseSetPos(0, 25);couterror code 02:無(wú)法填充列,因?yàn)閮蓚€(gè)坐標(biāo)的橫坐標(biāo)(y)不相等;system(pause);/左上角坐標(biāo)、右下角坐標(biāo)、用row填充行、用col填充列void drawFrame(COORD a, COORD b, char row, char col)drawRow(a.Y, a.X+1, b.X-1, row);drawRow(b.Y, a.X+1, b.X-1, row);drawCol(a.X, a.Y+1, b.Y-1, col);drawCol(b.X, a.Y+1, b.Y-1, col);void drawFrame(int x1, int y1, int x2, int y2, char row, char col)COORD a=x1, y1;COORD b=x2, y2;drawFrame(a, b, row, col);void drawFrame(Frame frame, char row, char col)COORD a = frame.position0;COORD b = frame.position1;drawFrame(a, b, row, col);void drawPlaying()drawFrame(0, 0, 48, 24, =, |);/draw map frame;drawFrame(49, 0, 79, 4, -, |);/draw output framedrawFrame(49, 4, 79, 9, -, |);/draw score framedrawFrame(49, 9, 79, 20, -, |);/draw operate framedrawFrame(49, 20, 79, 24, -, |);/draw other message frameSetPos(52, 6);cout得分:;SetPos(52, 7);cout稱(chēng)號(hào):;SetPos(52,10);cout操作方式:;SetPos(52,12);cout a,s,d,w 控制戰(zhàn)機(jī)移動(dòng)。;SetPos(52,14);cout p 暫停游戲。;SetPos(52,16);cout=frame.position0.X)if(spot.X=frame.position0.Y)if(spot.Y=frame.position0.Y)return true;return false;void printCoord(COORD a)cout( a.X , a.Y );void printFrameCoord(Frame a)printCoord(a.position0);cout - ;printCoord(a.position1);int drawMenu()SetPos(30, 1);coutP l a n e W a r;drawRow(3, 0, 79, -);drawRow(5, 0, 79, -);SetPos(28, 4);coutw 和 s 選擇, k 確定;SetPos(15, 11);cout1. 簡(jiǎn)單的敵人;SetPos(15, 13);cout2. 冷酷的敵人;drawRow(20, 0, 79, -);drawRow(22, 0, 79, -);SetPos(47, 11);cout簡(jiǎn)單的敵人:;SetPos(51, 13);cout簡(jiǎn)單敵人有著較慢的移動(dòng)速度。;SetPos(24, 21);cout制作: 中北大學(xué) 12060341 夢(mèng)筆西談;int j=11;SetPos(12, j);cout;/drawFrame(45, 9, 79, 17, =, |);while(1)if( _kbhit() )char x=_getch();switch (x)case w :if( j = 13)SetPos(12, j);cout;j = 11;SetPos(12, j);cout;SetPos(51, 13);cout;SetPos(47, 11);cout簡(jiǎn)單的敵人:;SetPos(51, 13);cout簡(jiǎn)單敵人有著較慢的移動(dòng)速度。;break;case s :if( j = 11 )SetPos(12, j);cout;j = 13;SetPos(12, j);cout;SetPos(51, 13);cout;SetPos(47, 11);cout冷酷的敵人:;SetPos(51, 13);cout冷酷的敵人移動(dòng)速度較快。;break;case k :if (j = 8)return 1;else return 2;/* DWORD WINAPI MusicFun(LPVOID lpParamte)/DWORD OBJ;sndPlaySound(TEXT(bgm.wav), SND_FILENAME|SND_ASYNC);return 0;*/*= the Game Class =*/class Gamepublic:COORD position10;COORD bullet10;Frame enemy8;int score;int rank;int rankf;string title;int flag_rank;Game ();/初始化所有void initPlane();void initBullet();void initEnemy();/初始化其中一個(gè)/void initThisBullet( COORD );/void initThisEnemy( Frame );void planeMove(char);void bulletMove();void enemyMove();/填充所有void drawPlane();void drawPlaneToNull();void drawBullet();void drawBulletToNull();void drawEnemy();void drawEnemyToNull();/填充其中一個(gè)void drawThisBulletToNull( COORD );void drawThisEnemyToNull( Frame );void Pause();void Playing();void judgePlane();void judgeEnemy();void Shoot();void GameOver();void printScore();Game:Game()initPlane();initBullet();initEnemy();score = 0;rank = 25;rankf = 0;flag_rank = 0;void Game:initPlane()COORD centren=39, 22;position0.X=position5.X=position7.X=position9.X=centren.X;position1.X=centren.X-2;position2.X=position6.X=centren.X-1;position3.X=position8.X=centren.X+1;position4.X=centren.X+2;for(int i=0; i=4; i+)positioni.Y=centren.Y;for(int i=6; i=8; i+)positioni.Y=centren.Y+1;position5.Y=centren.Y-1;position9.Y=centren.Y-2;void Game:drawPlane()for(int i=0; i9; i+)SetPos(positioni);if(i!=5)coutO;else if(i=5)cout|;void Game:drawPlaneToNull()for(int i=0; i9; i+)SetPos(positioni);cout ;void Game:initBullet()for(int i=0; i10; i+)bulleti.Y = 30;void Game:drawBullet()for(int i=0; i10; i+)if( bulleti.Y != 30)SetPos(bulleti);cout;void Game:drawBulletToNull()for(int i=0; i10; i+)if( bulleti.Y != 30 )COORD pos=bulleti.X, bulleti.Y+1;SetPos(pos);cout ;void Game:initEnemy()COORD a=1, 1;COORD b=45, 15;for(int i=0; i8; i+)enemyi.position0 = random(a, b);enemyi.position1.X = enemyi.position0.X + 3;enemyi.position1.Y = enemyi.position0.Y + 2;void Game:drawEnemy()for(int i=0; i8; i+)drawFrame(enemyi.position0, enemyi.position1, -, |);void Game:drawEnemyToNull()for(int i=0; i8; i+)drawFrame(enemyi.position0, enemyi.position1, , );void Game:Pause()SetPos(61,2);cout ;SetPos(61,2);cout暫停中.;char c=_getch();while(c!=p)c=_getch();SetPos(61,2);cout ;void Game:planeMove(char x)if(x = a)if(position1.X != 1)for(int i=0; i=9; i+)positioni.X -= 2;if(x = s)if(position7.Y != 23)for(int i=0; i=9; i+)positioni.Y += 1;if(x = d)if(position4.X != 47)for(int i=0; i=9; i+)positioni.X += 2;if(x = w)if(position5.Y != 3)for(int i=0; i=9; i+)positioni.Y -= 1;void Game:bulletMove()for(int i=0; i10; i+)if( bulleti.Y != 30)bulleti.Y -= 1;if( bulleti.Y = 1 )COORD pos=bulleti.X, bulleti.Y+1;drawThisBulletToNull( pos );bulleti.Y=30;void Game:enemyMove()for(int i=0; i8; i+)for(int j=0; j2; j+)enemyi.positionj.Y+;if(24 = enemyi.position1.Y)COORD a=1, 1;COORD b=45, 3;enemyi.position0 = random(a, b);enemyi.position1.X = enemyi.position0.X + 3;enemyi.position1.Y = enemyi.position0.Y + 2;void Game:judgePlane()for(int i = 0; i 8; i+)for(int j=0; j9; j+)if(judgeCoordInFrame(enemyi, positionj)SetPos(62, 1);cout墜毀;drawFrame(enemyi, +, +);Sleep(1000);GameOver();break;void Game:drawThisBulletToNull( COORD c)SetPos(c);cout ;void Game:drawThisEnemyToNull( Frame f )drawFrame(f, , );void Game:judgeEnemy()for(int i = 0; i 8; i+)for(int j = 0; j 10; j+)if( judgeCoordInFrame(enemyi, bulletj) )score += 5;drawThisEnemyToNull( enemyi );COORD a=1, 1;COORD b=45, 3;enemyi.position0 = random(a, b);enemyi.position1.X = enemyi.position0.X + 3;enemyi.position1.Y = enemyi.position0.Y + 2;drawThisBulletToNull( bulletj );bulletj.Y = 30;void Game:Shoot()for(int i=0; i10; i+)if(bulleti.Y = 30)bulleti.X = position5.X;bulleti.Y = position5.Y-1;break;void Game:printScore()if(score = 120 & flag_rank = 0)rank -= 3;flag_rank = 1;else if( score = 360 & flag_rank = 1)rank -= 5;flag_rank = 2;else if( score = 480 & flag_rank = 2)rank -= 5;flag_rank = 3;int x=rank/5;SetPos(60, 6);coutscore;if( rank!=rankf )SetPos(60, 7);if( x = 5)title=初級(jí)飛行員;else if( x = 4)title=中級(jí)飛行員;else if( x = 3)title=高級(jí)飛行員;else if( x = 2 )
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026四川機(jī)場(chǎng)集團(tuán)校招面試題及答案
- 2026四川港航投資集團(tuán)校招面筆試題及答案
- 2026順邦安防公司校招試題及答案
- 2026數(shù)字孿生技術(shù)招聘面試題及答案
- 2026年半導(dǎo)體材料科學(xué)全國(guó)考試試卷及答案
- 文學(xué)審美能力考察試題及答案
- 2025年網(wǎng)絡(luò)工程師技術(shù)考核試題及答案
- 昆明市中小學(xué)心理健康教育教師考試試題及答案
- 全國(guó)聽(tīng)力康復(fù)師資格認(rèn)證試題及答案
- 2026浙江臺(tái)州椒江區(qū)第三中心幼兒園總園及分園教師招聘?jìng)淇碱}庫(kù)帶答案詳解(能力提升)
- 上海市歷年中考語(yǔ)文現(xiàn)代文之議論文閱讀6篇(含答案)(2003-2022)
- 煙氣脫硝裝置安裝單位工程質(zhì)量驗(yàn)收表
- AQ 1046-2007 地勘時(shí)期煤層瓦斯含量測(cè)定方法(正式版)
- 軟裝配飾合同范本
- 蘇教版三年級(jí)下冊(cè)數(shù)學(xué)計(jì)算能手1000題帶答案
- 新媒體藝術(shù)的發(fā)展歷程及藝術(shù)特征
- 依法行醫(yī)教學(xué)課件
- 《日語(yǔ)零基礎(chǔ)學(xué)習(xí)》課件
- 講課學(xué)生數(shù)學(xué)學(xué)習(xí)成就
- 西葫蘆栽培技術(shù)要點(diǎn)
- 高中學(xué)生學(xué)籍表模板(范本)
評(píng)論
0/150
提交評(píng)論