欢迎来到天天文库
浏览记录
ID:32718731
大小:121.80 KB
页数:21页
时间:2019-02-15
《贪吃蛇游戏源代码》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、贪吃蛇游戏源代码#include#include#include#include#include#include#include#defineLEFT_MARGIN140#defineFRAME_UNIT_WIDTH25#defineFRAME_UNIT_HEIGHT15#defineBOX_SIZE15#defineWINDOW_WIDTH640#defineWINDOW_HEIGH
2、T480#defineSNAK_DEFAULT_POS_X10#defineSNAK_DEFAULT_POS_Y5#defineSMD_UP1#defineSMD_DOWN2#defineSMD_RIGHT3#defineSMD_LEFT4#defineUP_MOVE72#defineDOWN_MOVE80#defineLEFT_MOVE75#defineRIGHT_MOVE77#defineSTEP_MOVE7#defineGAME_STOP57#defineESC_OUT1#defineGENERAT_EGG
3、8#defineNO_EVENT0#defineBooleanint#defineTRUTH1#defineFALS0#defineType_GAMESTATUSint#defineON_PALYING2#defineWINNER1#defineGAMEOVER0#defineTIMEINTERVAL6typedefstruct{intp_X;intp_Y;}POS_in_Fram;typedefstructSNode{POS_in_Framcur_pos;intcolor;structSNode*next;}S
4、Node,*LSNode;typedefstruct{intdirection;intlen;POS_in_FramHead_pre_pos;POS_in_FramHead_cur_pos;intHead_color;LSNodenext;BooleanDead;}SNAK;typedefstruct{POS_in_Framegg_pos;integg_color;}EggType;SNAKobj_snake;EggTypeobj_egg;intMessage_Event;intScoreTotal;intSpe
5、edLevel;Type_GAMESTATUSGameStat;voidset_Message_Event(intT){Message_Event=T;}intget_Message_Event(){return(Message_Event);}voidclear_ScoreTotal(){ScoreTotal=0;}intget_ScoreTotal(){return(ScoreTotal);}voiddraw_ScoreTotal(){chartext_buffer[20];intul_X,ul_Y;ul_X
6、=LEFT_MARGIN;ul_Y=WINDOW_HEIGHT-BOX_SIZE*(FRAME_UNIT_HEIGHT-4);setcolor(BLUE);sprintf(text_buffer,"ScoreTotal:%d",get_ScoreTotal());moveto(ul_X,ul_Y);outtext(text_buffer);setcolor(YELLOW);ScoreTotal++;sprintf(text_buffer,"ScoreTotal:%d",get_ScoreTotal());move
7、to(ul_X,ul_Y);outtext(text_buffer);}voidinit_SpeedLevel(){SpeedLevel=1;}intget_SpeedLevel(){return(SpeedLevel);}voiddraw_SpeedLevel(intold_l,intnew_l){chartext_buffer[20];intul_X,ul_Y;ul_X=LEFT_MARGIN;ul_Y=WINDOW_HEIGHT-BOX_SIZE*(FRAME_UNIT_HEIGHT-4);setcolor
8、(BLUE);sprintf(text_buffer,"SpeedLevel:%d",old_l);moveto(ul_X,ul_Y+textheight("H")*2);outtext(text_buffer);setcolor(YELLOW);sprintf(text_buffer,"SpeedLevel:%d",new_l);moveto(ul_X,ul_Y+tex
此文档下载收益归作者所有