俄羅斯方塊課程設(shè)計(jì)報(bào)告_第1頁
俄羅斯方塊課程設(shè)計(jì)報(bào)告_第2頁
俄羅斯方塊課程設(shè)計(jì)報(bào)告_第3頁
俄羅斯方塊課程設(shè)計(jì)報(bào)告_第4頁
俄羅斯方塊課程設(shè)計(jì)報(bào)告_第5頁
已閱讀5頁,還剩19頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上目 錄1. 系統(tǒng)概述 12. 設(shè)計(jì)說明書 43. 系統(tǒng)操作界面 64. 源程序編碼 75. 測試計(jì)劃366. 改進(jìn)意見397課程設(shè)計(jì)心得體會(huì) 408. 參考書籍、資料 40 系統(tǒng)概述1.1現(xiàn)狀分析在個(gè)人電腦日益普及的今天,一些有趣的桌面游戲已經(jīng)成為人們在使用計(jì)算機(jī)進(jìn)行工作或?qū)W習(xí)之余休閑娛樂的首選,而俄羅斯方塊游戲是人們最熟悉的小游戲之一,它以其趣味性強(qiáng),易上手等諸多特點(diǎn)得到了大眾的認(rèn)可,因此開發(fā)此游戲軟件可滿足人們的一些娛樂的需求。此俄羅斯方塊游戲可以為用戶提供一個(gè)可在普通個(gè)人電腦上運(yùn)行的,界面美觀的,易于控制的俄羅斯方塊游戲。1.2項(xiàng)目要求俄羅斯方塊游戲是一款適合大

2、眾的游戲軟件,它適合不同年齡的人玩。本軟件要實(shí)現(xiàn)的功能如下:(1)游戲區(qū):玩家可以在游戲區(qū)中堆積方塊,并能夠在游戲過程中隨時(shí)了解得分情況。(2)游戲控制:玩家可以通過游戲控制功能來選擇開始新的一局游戲,暫?;蛲顺鲇螒?。(3) 級別設(shè)置:玩家可以根據(jù)自己的需要自行設(shè)定游戲的開始級別,級別越高,游戲的速度越快,難度越大。(4) 1.3系統(tǒng)功能模塊示意圖俄羅斯方塊游戲游戲區(qū)游戲控制顯示玩家操作顯示操作結(jié)果開始暫停/繼續(xù)提高等級退出降低等級項(xiàng)目開發(fā)計(jì)劃書項(xiàng)目開發(fā)計(jì)劃書名稱時(shí)間工作內(nèi)容下達(dá)設(shè)計(jì)任務(wù)1天(集中)說明如何著手設(shè)計(jì)的方法和設(shè)計(jì)任務(wù)的解釋說明。收集、分析資料及文檔2天項(xiàng)目組在項(xiàng)目經(jīng)理的組織下選題

3、、分析,識別實(shí)體,完成項(xiàng)目開發(fā)計(jì)劃書及小組人員分工。設(shè)計(jì)2天各項(xiàng)目組完成系統(tǒng)層次圖、用戶界面設(shè)計(jì)、數(shù)據(jù)庫表設(shè)計(jì)、報(bào)表設(shè)計(jì),完成設(shè)計(jì)說明書程序編寫和測試7天根據(jù)方案進(jìn)行現(xiàn)場編程、調(diào)試。編寫設(shè)計(jì)文檔2天完成軟件測試以及用戶操作手冊的編寫。文檔提交、答辯1天各小組提交文檔,教師根據(jù)情況選擇是否答辯及答辯方式(抽樣答辯或全員答辯)。 設(shè)計(jì)說明1.1游戲區(qū)模塊游戲區(qū)模塊創(chuàng)建游戲區(qū)處理玩家游戲操作顯示游戲結(jié)果1.2控制區(qū)模塊游戲控制模塊開始游戲暫停游戲初始級別設(shè)置退出游戲1.3系統(tǒng)流程圖是否到頂部處理玩家操作開始設(shè)置初始級別創(chuàng)建游戲區(qū)游戲開局隨機(jī)選擇方塊類型是否到頂部方塊下落一行游戲結(jié)束是否1.4模塊簡介

4、1 功能模塊(1)游戲區(qū)模塊(創(chuàng)建游戲區(qū),處理玩家操作,顯示操作結(jié)果)(2)游戲控制模塊(開始,暫停繼續(xù),提高等級,降低等級,停止,新游戲,幫助) 系統(tǒng)操作界面游戲打開界面 游戲進(jìn)行中界面源代碼編碼#include #include #include #include #include #include #define true 1#define false 0#define BoardWidth 12#define BoardHeight 23#define _INNER_HELPER /*inner helper method */*Scan Codes Define*/enum KEYC

5、ODES K_ESC =0x011b, K_UP =0x4800, /* upward arrow */ K_LEFT =0x4b00, K_DOWN =0x5000, K_RIGHT =0x4d00, K_SPACE =0x3920, K_P =0x1970;/* the data structure of the block */typedef struct tagBlock char c44; /* cell fill info array, 0-empty, 1-filled */ int x; /* block position cx 0,BoardWidht -1 */ int y

6、; /* block position cy -4,BoardHeight-1 */ char color; /* block color */ char size; /* block max size in width or height */ char name; /* block name (the blocks shape) */ Block;/* games global info */int FrameTime= 1300;int CellSize= 18;int BoardLeft= 30;int BoardTop= 30;/* next block grid */int NBB

7、oardLeft= 300;int NBBoardTop= 30;int NBCellSize= 10;/* score board position */int ScoreBoardLeft= 300;int ScoreBoardTop=100;int ScoreBoardWidth=200;int ScoreBoardHeight=35;int ScoreColor=LIGHTCYAN;/* infor text postion */int InfoLeft=300;int InfoTop=200;int InfoColor=YELLOW;int BorderColor=DARKGRAY;

8、int BkGndColor=BLACK;int GameRunning=true;int TopLine=BoardHeight-1; /* top empty line */int TotalScore=100;char info_score20;char info_help255;char info_common255;/* our board, Boardxy0-isFilled, Boardxy1-fillColor */unsigned char BoardBoardWidthBoardHeight2;char BufferCells44; /* used to judge if

9、can rotate block */Block curBlock; /* current moving block */Block nextBlock; /* next Block to appear */* function list */int GetKeyCode();int CanMove(int dx,int dy);int CanRotate();int RotateBlock(Block *block);int MoveBlock(Block *block,int dx,int dy);void DrawBlock(Block *block,int,int,int);void

10、EraseBlock(Block *block,int,int,int);void DisplayScore();void DisplayInfo(char* text);void GenerateBlock(Block *block);void NextBlock();void InitGame();int PauseGame();void QuitGame();/*Get Key Code */int _INNER_HELPER GetKeyCode() int key=0; if(bioskey(1) key=bioskey(0); return key;/* display text!

11、 */void _INNER_HELPER DisplayInfo(char *text) setcolor(BkGndColor); outtextxy(InfoLeft,InfoTop,info_common); strcpy(info_common,text); setcolor(InfoColor); outtextxy(InfoLeft,InfoTop,info_common);/* create a new block by key number,* the block anchor to the top-left corner of 4*4 cells*/void _INNER_

12、HELPER GenerateBlock(Block *block) int key=(random(13)*random(17)+random(1000)+random(3000)%7; block-size=3;/* because most blocks size=3 */ memset(block-c,0,16); switch(key) case 0: block-name=T; block-color=RED; block-c10=1; block-c11=1, block-c21=1; block-c12=1; break; case 1: block-name=L; block

13、-color=YELLOW; block-c10=1; block-c11=1; block-c12=1, block-c22=1; break; case 2: block-name=J; block-color=LIGHTGRAY; block-c10=1; block-c11=1; block-c12=1, block-c02=1; break; case 3: block-name=z; block-color=CYAN; block-c00=1, block-c10=1; block-c11=1, block-c21=1; break; case 4: block-name=5; b

14、lock-color=LIGHTBLUE; block-c10=1, block-c20=1; block-c01=1, block-c11=1; break; case 5: block-name=o; block-color=BLUE; block-size=2; block-c00=1, block-c10=1; block-c01=1, block-c11=1; break; case 6: block-name=I; block-color=GREEN; block-size=4; block-c10=1; block-c11=1; block-c12=1; block-c13=1;

15、 break; /* get next block! */void NextBlock() /* copy the nextBlock to curBlock */ curBlock.size=nextBlock.size; curBlock.color=nextBlock.color; curBlock.x=(BoardWidth-4)/2; curBlock.y=-curBlock.size; memcpy(curBlock.c,nextBlock.c,16); /* generate nextBlock and show it */ EraseBlock(&nextBlock,NBBoa

16、rdLeft,NBBoardTop,NBCellSize); GenerateBlock(&nextBlock); nextBlock.x=1,nextBlock.y=0; DrawBlock(&nextBlock,NBBoardLeft,NBBoardTop,NBCellSize);/* rotate the block, update the block struct data */int _INNER_HELPER RotateCells(char c44,char blockSize) char temp,i,j; switch(blockSize) case 3: temp=c00;

17、 c00=c20, c20=c22, c22=c02, c02=temp; temp=c01; c01=c10, c10=c21, c21=c12, c12=temp; break; case 4: /* only I block arived here! */ c10=1-c10, c12=1-c12, c13=1-c13; c01=1-c01, c21=1-c21, c31=1-c31; break; /* judge if the block can move toward the direction */int CanMove(int dx,int dy) int i,j,tempX,

18、tempY; for(i=0;icurBlock.size;i+) for(j=0;jcurBlock.size;j+) if(curBlock.cij) /* cannot move leftward or rightward */ tempX = curBlock.x + i + dx; if(tempX(BoardWidth-1) return false; /* make sure x is valid! */ /* cannot move downward */ tempY = curBlock.y + j + dy; if(tempY(BoardHeight-1) return f

19、alse; /* y is only checked lower bound, maybe negative! */ /* the cell already filled, we must check Ys upper bound before check cell ! */ if(tempY=0 & BoardtempXtempY0) return false; return true;/* judge if the block can rotate */int CanRotate() int i,j,tempX,tempY; /* update buffer */ memcpy(Buffe

20、rCells, curBlock.c, 16); RotateCells(BufferCells,curBlock.size); for(i=0;icurBlock.size;i+) for(j=0;jcurBlock.size;j+) if(BufferCellsij) tempX=curBlock.x+i; tempY=curBlock.y+j; if(tempX(BoardWidth-1) return false; if(tempY(BoardHeight-1) return false; if(tempY=0 & BoardtempXtempY0) return false; ret

21、urn true;/* draw the block */void _INNER_HELPER DrawBlock(Block *block,int bdLeft,int bdTop,int cellSize) int i,j; setfillstyle(SOLID_FILL,block-color); for(i=0;isize;i+) for(j=0;jsize;j+) if(block-cij & (block-y+j)=0) floodfill( bdLeft+cellSize*(i+block-x)+cellSize/2, bdTop+cellSize*(j+block-y)+cel

22、lSize/2, BorderColor); /* Rotate the block, if success, return true */int RotateBlock(Block *block) char temp,i,j; int b_success; if(block-size=2) return true; if( b_success=CanRotate() EraseBlock(block,BoardLeft,BoardTop,CellSize); memcpy(curBlock.c,BufferCells,16); DrawBlock(block,BoardLeft,BoardT

23、op,CellSize); return b_success;/* erase a block, only fill the filled cell with background color */void _INNER_HELPER EraseBlock(Block *block,int bdLeft,int bdTop,int cellSize) int i,j; setfillstyle(SOLID_FILL,BkGndColor); for(i=0;isize;i+) for(j=0;jsize;j+) if(block-cij & (block-y+j=0) floodfill( b

24、dLeft+cellSize*(i+block-x)+cellSize/2, bdTop+cellSize*(j+block-y)+cellSize/2, BorderColor); /* move by the direction if can, donothing if cannot* return value: true - success, false - cannot move toward this direction*/int MoveBlock(Block *block,int dx,int dy) int b_canmove=CanMove(dx,dy); if(b_canm

25、ove) EraseBlock(block,BoardLeft,BoardTop,CellSize); curBlock.x+=dx; curBlock.y+=dy; DrawBlock(block,BoardLeft,BoardTop,CellSize); return b_canmove;/* drop the block to the bottom! */int DropBlock(Block *block) EraseBlock(block,BoardLeft,BoardTop,CellSize); while(CanMove(0,1) curBlock.y+; DrawBlock(b

26、lock,BoardLeft,BoardTop,CellSize); return 0;/* return value is assign to the blocks alive */* init the graphics mode, draw the board grid */void InitGame() int i,j,gdriver=DETECT,gmode; struct time sysTime; /* draw board cells */ memset(Board,0,BoardWidth*BoardHeight*2); memset(nextBlock.c,0,16); st

27、rcpy(info_help,P: Pause Game. -by hoodlum1980); initgraph(&gdriver,&gmode,); setcolor(BorderColor); for(i=0;i=BoardWidth;i+) line(BoardLeft+i*CellSize, BoardTop, BoardLeft+i*CellSize, BoardTop+ BoardHeight*CellSize); for(i=0;i=BoardHeight;i+) line(BoardLeft, BoardTop+i*CellSize, BoardLeft+BoardWidth

28、*CellSize, BoardTop+ i*CellSize); /* draw board outer border rect */ rectangle(BoardLeft-CellSize/4, BoardTop-CellSize/4, BoardLeft+BoardWidth*CellSize+CellSize/4, BoardTop+BoardHeight*CellSize+CellSize/4); /* draw next block grids */ for(i=0;i=4;i+) line(NBBoardLeft+i*NBCellSize, NBBoardTop, NBBoar

29、dLeft+i*NBCellSize, NBBoardTop+4*NBCellSize); line(NBBoardLeft, NBBoardTop+i*NBCellSize, NBBoardLeft+4*NBCellSize, NBBoardTop+ i*NBCellSize); /* draw score rect */ rectangle(ScoreBoardLeft,ScoreBoardTop,ScoreBoardLeft+ScoreBoardWidth,ScoreBoardTop+ScoreBoardHeight); DisplayScore(); /* set new seed!

30、*/ gettime(&sysTime); srand(sysTime.ti_hour*3600+sysTime.ti_min*60+sysTime.ti_sec); GenerateBlock(&nextBlock); NextBlock(); /* create first block */ setcolor(DARKGRAY); outtextxy(InfoLeft,InfoTop+20,Up -rotate Space-drop); outtextxy(InfoLeft,InfoTop+35,Left-left Right-right); outtextxy(InfoLeft,Info

31、Top+50,Esc -exit); DisplayInfo(info_help);/* set the isFilled and fillcolor data to the board */void _INNER_HELPER FillBoardData() int i,j; for(i=0;icurBlock.size;i+) for(j=0;j=0) BoardcurBlock.x+icurBlock.y+j0=1; BoardcurBlock.x+icurBlock.y+j1=curBlock.color; /* draw one line of the board */void _I

32、NNER_HELPER PaintBoard() int i,j,fillcolor; for(j=max(TopLine-4),0);jBoardHeight;j+) for(i=0;iBoardWidth;i+) fillcolor=Boardij0? Boardij1:BkGndColor; setfillstyle(SOLID_FILL,fillcolor); floodfill(BoardLeft+i*CellSize+CellSize/2,BoardTop+j*CellSize+CellSize/2,BorderColor); /* check if one line if fil

33、led full and increase the totalScore! */void _INNER_HELPER CheckBoard() int i,j,k,score=10,sum=0,topy,lines=0; /* we find the top empty line! */ j=topy=BoardHeight-1; do sum=0; for(i=0;i0 & topy0); /* remove the full filled line (max remove lines count = 4) */ do sum=0; for(i=0;i topy;k-) for(i=0;iB

34、oardWidth;i+) Boardik0=Boardik-10; Boardik1=Boardik-11; /*make the top line empty! */ for(i=0;iBoardWidth;i+) Boarditopy0=0; Boarditopy1=0; topy+; /* move the topline downward one line! */ lines+; /* lines 0 & jtopy & lines=FrameTime) /* our block has dead! (cant move down), we get next block */ if(

35、!MoveBlock(&curBlock,0,1) UpdateBoard(); NextBlock(); if(!CanMove(0,1) goto GameOver; tick=0; delay(100); switch(key) case K_LEFT: MoveBlock(&curBlock,-1,0); break; case K_RIGHT: MoveBlock(&curBlock,1,0); break; case K_DOWN: MoveBlock(&curBlock,0,1); break; case K_UP: RotateBlock(&curBlock); break;

36、case K_SPACE: DropBlock(&curBlock); break; case K_P: PauseGame(); break; GameOver: DisplayInfo(GAME OVER! Press any key to exit!); getch(); /* wait the user Press any key. */ QuitGame(); 測試計(jì)劃 1.1測試方案 本游戲的測試方法采用檢查各個(gè)功能能否實(shí)現(xiàn)的方法 1.2測試項(xiàng)目及功能控制區(qū)開始:實(shí)現(xiàn)游戲的開始暫停:實(shí)現(xiàn)游戲暫停繼續(xù):實(shí)現(xiàn)游戲繼續(xù)提高級數(shù):提高級數(shù)增加游戲的難度降低級數(shù):降低級數(shù)減小游戲的難度菜單區(qū)

37、新游戲:游戲結(jié)束從新開始新一輪的游戲提高級數(shù):提高游戲難度降低級數(shù):減小游戲難度退出:退出游戲開始:開始游戲暫停:暫停正在進(jìn)行的游戲從新開始:重新開始游戲停止:停止正在進(jìn)行的游戲幫助信息: 游戲控制鍵顯示區(qū):顯示俄羅斯方塊提前顯示窗口:顯示下一個(gè)方塊的樣式測試進(jìn)度:本游戲在我和同組李帥同學(xué)的辛苦努力下用了半天的時(shí)間完成了1.3測試準(zhǔn)備編寫相應(yīng)的驅(qū)動(dòng)模塊,并精心設(shè)計(jì)測試用例1.4 測試機(jī)構(gòu) 測試人員: 王新勃職責(zé):找出程序中的錯(cuò)誤,實(shí)現(xiàn)游戲的功能1.5 測試項(xiàng)目說明測試1:名稱:控制區(qū)功能測試 目的:測試控制區(qū)各個(gè)功能的按鈕。 內(nèi)容: 包括游戲開始,暫停,繼續(xù),停止,提高級數(shù),降低級數(shù)的功能 步驟:打開游戲窗口,按下開始按鈕,看游戲區(qū)是否有方塊下落,若有則在按暫停按鈕看其是否暫停,若暫停,則按繼續(xù)看其是否繼續(xù)下落。按停止按鈕方塊觀察方塊是否停止不動(dòng),按提高級數(shù),降低級數(shù)看顯示區(qū)級數(shù)是否在變化,并觀察游戲中方塊的下落書讀是否變化,按提高級數(shù)按鈕,方塊的下落速度應(yīng)加快;按降低級數(shù)按鈕,方塊的速度應(yīng)減慢。測試2:名稱:菜單區(qū)功能測試 目的:測試菜單區(qū)各個(gè)子菜單的功能 內(nèi)容:游戲菜單下的子菜單:新游戲,提高級數(shù),降低級數(shù),退出按鈕的功能實(shí)現(xiàn),控制菜單下的子菜單:開始,暫停,重新開始,停止的功能實(shí)現(xiàn)。步驟:打開游戲窗口,按下控制菜單下的開始按鈕,看游戲區(qū)是否有方塊下落,預(yù)顯區(qū)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論