欢迎来到天天文库
浏览记录
ID:52564120
大小:160.50 KB
页数:15页
时间:2020-03-28
《C语言打砖块游戏.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C语言打砖块游戏一、游戏截图二、游戏源码#include#include#include#include/*DEFINES********************************************************************************///definesforwindows#defineWINDOW_CLASS_NAMETEXT("WIN32CLASS")#defineWINDOW_WIDTH640#defineWINDOW_H
2、EIGHT480//statesforgameloop#defineGAME_STATE_INIT0#defineGAME_STATE_START_LEVEL1#defineGAME_STATE_RUN2#defineGAME_STATE_SHUTDOWN3#defineGAME_STATE_EXIT4//blockdefines#defineNUM_BLOCK_ROWS6#defineNUM_BLOCK_COLUMNS8#defineBLOCK_WIDTH64#defineBLOCK_HEIGHT16#defineBLOCK_ORIGIN_X8#d
3、efineBLOCK_ORIGIN_Y8#defineBLOCK_X_GAP80#defineBLOCK_Y_GAP32//paddledefines#definePADDLE_START_X(WINDOW_WIDTH/2-16)#definePADDLE_START_Y(WINDOW_HEIGHT-32);#definePADDLE_WIDTH32#definePADDLE_HEIGHT8#definePADDLE_COLORRGB(0,0,255)//balldefines#defineBALL_START_Y(WINDOW_HEIGHT/2)#
4、defineBALL_SIZE4//colordefines#defineBACKGROUND_COLORRGB(0,0,0)#defineBLOCK_COLORRGB(125,0,0)#defineBALL_COLORRGB(222,0,222)//thesereadthekeyboardasynchronously#defineKEY_DOWN(vk_code)((GetAsyncKeyState(vk_code)&0x8000)?1:0)#defineKEY_UP(vk_code)((GetAsyncKeyState(vk_code)&0x80
5、00)?0:1)/*basicunsignedtypes*******************************************************************/typedefunsignedshortUSHORT;typedefunsignedshortWORD;typedefunsignedcharUCHAR;typedefunsignedcharBYTE;/*FUNCTIONDECLARATION************************************************************
6、*******/intGame_Init(void*parms=NULL);intGame_Shutdown(void*parms=NULL);intGame_Main(void*parms=NULL);DWORDStart_Clock(void);DWORDWait_Clock(DWORDcount);/*GLOBALS*********************************************************************************/HWNDmain_window_handle=NULL;//save
7、thewindowhandleHINSTANCEmain_instance=NULL;//savetheinstanceintgame_state=GAME_STATE_INIT;//startingstateintpaddle_x=0,paddle_y=0;//trackspositionofpaddleintball_x=0,ball_y=0;//trackspositionofballintball_dx=0,ball_dy=0;//velocityofballintscore=0;//thescoreintlevel=1;//thecurre
8、ntlevelintblocks_hit=0;//tracksnumberofblockshitDWORDs
此文档下载收益归作者所有