超级玛丽增强版源代码.docx
- 文档编号:10020828
- 上传时间:2023-02-08
- 格式:DOCX
- 页数:114
- 大小:45.48KB
超级玛丽增强版源代码.docx
《超级玛丽增强版源代码.docx》由会员分享,可在线阅读,更多相关《超级玛丽增强版源代码.docx(114页珍藏版)》请在冰豆网上搜索。
超级玛丽增强版源代码
//bitmaptool.h
#ifndef__BITMAPTOOL
#define__BITMAPTOOL
#include”filereport.h”
#defineBM_BOTTOM_RIGHT0
#defineBM_BOTTOM_CENTER1
#defineBM_CENTER2
#defineBM_USER3
//
classMYBITMAP
{
public:
MYBITMAP();
~MYBITMAP();
//初始化
voidInit(HINSTANCEhInstance,intiResource,introw,intcol);
voidSetDevice(HDChdest,HDChsrc,intwwin,inthwin);
//
voidSetPos(intistyle,intx,inty);
//显示
voidDraw(DWORDdwRop);
voidStretch(intx,inty);
voidStretch(intx,inty,intid);
voidShow(intx,inty);
voidShowCenter(inty);
voidShowLoop(intleft,inttop,intright,intbottom,intiframe);
voidShowNoBack(intx,inty,intiFrame);
voidShowNoBackLoop(intx,inty,intiFrame,intiNum);
//动画播放
voidShowAni();
voidSetAni(intx,inty);
//FILEREPORTf;
HBITMAPhBm;
public:
//按照行列平均分成几个
intinum;
intjnum;
intwidth;
intheight;
intscreenwidth;
intscreenheight;
HDChdcdest;
HDChdcsrc;
//当前位置
intxpos;
intypos;
intiStartAni;
};
classMYBKSKY:
publicMYBITMAP
{
public:
MYBKSKY();
~MYBKSKY();
//show
voidDrawRoll();//循环补空
voidDrawRollStretch(intx,inty);
voidDrawRollStretch(intx,inty,intid);
voidMoveTo(intx,inty);
voidMoveRoll(intx);
//data
intxseparate;
};
#defineBM_SQUARE1
classMYANIOBJ:
publicMYBITMAP
{
public:
MYANIOBJ();
~MYANIOBJ();
//initlist
voidInitAniList(int*pw,int*ph,intinum,intismask);
voidInitAniList(intstyle,inta,intb);
//show
voidDrawItem(intx,inty,intid,intiframe);
voidDrawItemNoMask(intx,inty,intid,intiframe);
//指定宽度
voidDrawItemNoMaskWidth(intx,inty,intid,intw,intiframe);
//自动播放
voidPlayItem(intx,inty,intid);
//
intwlist[20];
inthlist[20];
intylist[20];
intiframeplay;
};
classMYANIMAGIC:
publicMYBITMAP
{
public:
MYANIMAGIC();
~MYANIMAGIC();
//initlist
voidInitAniList(int*pw,int*ph,intinum);
voidSetDevice(HDChdest,HDChsrc,HDChtemp);
//show
voidDrawItem(intx,inty,intid,intiframe);
//
intwlist[20];
inthlist[20];
intylist[20];
HDChdctemp;
};
classMYROLE:
publicMYBITMAP
{
public:
MYROLE();
~MYROLE();
//init
voidInitRole(intxleft,intxright);
voidSetLimit(intxleft,intxright);
//show
voidDraw();
voidDraw(intx,inty,intiframe);
voidChangeFrame();
voidSetState(inti);
voidMove();
voidJump();
//ANI
voidMoveTo(intx,inty);
voidMoveOffset(intx,inty);
voidMoveStepTo(intx,inty);//向目的地移动单位距离
voidPlayAni();//播放一段动画
voidSetAni(intistyle);
intIsInAni();//是否正在播放动画
//data
intiState;
intiFrame;
intminx;
intmaxx;
//move
intmovex;
intmovey;
//jump
intjumpheight;
intjumpx;
//方向
intidirec;
//动画
intiAniBegin;
intiparam1;
intiAniStyle;
};
#endif
//bitmaptool.cpp
//Finishingcodefans。
net
#include"stdafx.h”
#include"bitmaptool.h"
#include”gamemap。
h"
externGAMEMAPgamemap;
externFILEREPORTf1;
MYBITMAP:
:
MYBITMAP()
{}
MYBITMAP:
:
~MYBITMAP()
{
DeleteObject(hBm);
}
voidMYBITMAP:
:
Init(HINSTANCEhInstance,intiResource,introw,intcol)
{
BITMAPbm;
inum=row;
jnum=col;
hBm=LoadBitmap(hInstance,MAKEINTRESOURCE(iResource));
GetObject(hBm,sizeof(BITMAP),&bm);
width=bm.bmWidth/inum;
height=bm.bmHeight/jnum;
}
voidMYBITMAP:
:
SetDevice(HDChdest,HDChsrc,intwwin,inthwin)
{
hdcdest=hdest;
hdcsrc=hsrc;
screenwidth=wwin;
screenheight=hwin;
}
voidMYBITMAP:
:
Show(intx,inty)
{
xpos=x;
ypos=y;
SelectObject(hdcsrc,hBm);
BitBlt(hdcdest,xpos,ypos,width,height,hdcsrc,0,0,SRCCOPY);
}
voidMYBITMAP:
:
ShowCenter(inty)
{
xpos=(screenwidth-width)/2;
ypos=y;
SelectObject(hdcsrc,hBm);
BitBlt(hdcdest,xpos,ypos,width,height,hdcsrc,0,0,SRCCOPY);
}
voidMYBITMAP:
:
ShowLoop(intleft,inttop,intright,intbottom,intiframe)
{
inti,j;
SelectObject(hdcsrc,hBm);
for(j=top;j { for(i=left;i { BitBlt(hdcdest,i,j,width,height,hdcsrc,iframe*width,0,SRCCOPY); } } } voidMYBITMAP: : ShowNoBack(intx,inty,intiFrame) { xpos=x; ypos=y; SelectObject(hdcsrc,hBm); BitBlt(hdcdest,xpos,ypos,width,height/2,hdcsrc,iFrame*width,height/2,SRCAND); BitBlt(hdcdest,xpos,ypos,width,height/2,hdcsrc,iFrame*width,0,SRCPAINT); } voidMYBITMAP: : ShowNoBackLoop(intx,inty,intiFrame,intiNum) { inti; xpos=x; ypos=y; SelectObject(hdcsrc,hBm); for(i=0;i〈iNum;i++) {BitBlt(hdcdest,xpos+i*width,ypos,width,height/2,hdcsrc,iFrame*width,height/2,SRCAND);BitBlt(hdcdest,xpos+i*width,ypos,width,height/2,hdcsrc,iFrame*width,0,SRCPAINT);} } voidMYBITMAP: : ShowAni() { /*if(! iStartAni) return; SelectObject(hdcsrc,hBm); BitBlt(hdcdest,xpos,ypos,width,height/2,hdcsrc,framenow*width,height/2,SRCAND); BitBlt(hdcdest,xpos,ypos,width,height/2,hdcsrc,framenow*width,0,SRCPAINT); framenow++; //播放结束 if(framenow〉=inum) iStartAni=0; */ } voidMYBITMAP: : SetAni(intx,inty) { xpos=x; ypos=y; /* framenow=0; iStartAni=1; */ } voidMYBITMAP: : SetPos(intistyle,intx,inty) { switch(istyle) { caseBM_CENTER: xpos=(screenwidth—width)/2; ypos=y; break; caseBM_USER: xpos=x; ypos=y; break; } } voidMYBITMAP: : Draw(DWORDdwRop) { SelectObject(hdcsrc,hBm); BitBlt(hdcdest,xpos,ypos,width,height,hdcsrc,0,0,dwRop); } voidMYBITMAP: : Stretch(intx,inty) { SelectObject(hdcsrc,hBm); StretchBlt(hdcdest,xpos,ypos,width*x,height*y, hdcsrc,0,0,width,height, SRCCOPY); } voidMYBITMAP: : Stretch(intx,inty,intid) { SelectObject(hdcsrc,hBm); StretchBlt(hdcdest,xpos,ypos,width*x,height*y, hdcsrc,0,id*height, width,height, SRCCOPY); } /////////////////////////bitmapobjectanimation////////////////// MYBKSKY: : MYBKSKY() { xseparate=0; } MYBKSKY: : ~MYBKSKY() {} voidMYBKSKY: : MoveTo(intx,inty) { xpos=x; ypos=y; } voidMYBKSKY: : MoveRoll(intx) { xseparate+=x; xseparate%=width; if(xseparate<0) { xseparate=width; } } voidMYBKSKY: : DrawRoll() { SelectObject(hdcsrc,hBm); BitBlt(hdcdest,xpos,ypos, width—xseparate,height, hdcsrc,xseparate,0,SRCCOPY); BitBlt(hdcdest,xpos+width-xseparate,ypos, xseparate,height, hdcsrc,0,0,SRCCOPY); } voidMYBKSKY: : DrawRollStretch(intx,inty) { SelectObject(hdcsrc,hBm); StretchBlt(hdcdest,xpos,ypos, (width-xseparate)*x,height*y, hdcsrc,xseparate,0, width—xseparate,height, SRCCOPY); StretchBlt(hdcdest,xpos+(width-xseparate)*x,ypos, xseparate*x,height*y, hdcsrc,0,0, xseparate,height, SRCCOPY); } voidMYBKSKY: : DrawRollStretch(intx,inty,intid) { SelectObject(hdcsrc,hBm); StretchBlt(hdcdest,xpos,ypos, (width-xseparate)*x,height*y, hdcsrc,xseparate,id*height, width—xseparate,height, SRCCOPY); StretchBlt(hdcdest,xpos+(width-xseparate)*x,ypos, xseparate*x,height*y, hdcsrc,0,id*height, xseparate,height, SRCCOPY); } /////////////////////////bitmaprole////////////////// MYROLE: : MYROLE() {} MYROLE: : ~MYROLE() {} voidMYROLE: : MoveTo(intx,inty) { xpos=x; ypos=y; } voidMYROLE: : MoveOffset(intx,inty) { if(x==0&&y==0) return; if(! gamemap.RoleCanMove(x,y)) return; xpos+=x; ypos+=y; if(xpos xpos=minx; if(xpos〉maxx) xpos=maxx; } voidMYROLE: : MoveStepTo(intx,inty) { if(xpos〈x) xpos+=ROLE_STEP; if(ypos ypos+=8; if(ypos〉y) ypos=y; } //去背显示 voidMYROLE: : Draw() { if(iAniBegin) { PlayAni(); } else { SelectObject(hdcsrc,hBm); BitBlt(hdcdest,xpos,ypos, width,height/2, hdcsrc,iFrame*width,height/2,SRCAND); BitBlt(hdcdest,xpos,ypos, width,height/2, hdcsrc,iFrame*width,0,SRCPAINT); } } voidMYROLE: : Draw(intx,inty,intframe) { SelectObject(hdcsrc,hBm); BitBlt(hdcdest,x,y, width,height/2, hdcsrc,frame*width,height/2,SRCAND); BitBlt(hdcdest,x,y, width,height/2, hdcsrc,frame*width,0,SRCPAINT); } voidMYROLE: : InitRole(intxleft,intxright) { iFrame=0; iState=0; maxx=xright; minx=xleft; jumpheight=0; movex=0; movey=0; jumpx=0; idirec=0; iAniBegin=0; } voidMYROLE: : SetLimit(intxleft,intxright) { maxx=xright; minx=xleft; } voidMYROLE: : Move() { if(0==movey) { //水平移动 MoveOffset(movex,0); } else { //跳动 MoveOffset(jumpx,0); MoveOffset(0,movey); } //帧控制 if(movex〈0&&iFrame〈3) { iFrame=3; } if(movex〉0&&iFrame〉=3) { iFrame=0; } if(movex! =0) { if(0==idirec) iFrame=1—iFrame; else iFrame=7-iFrame; } if(movey! =0) { iFrame=idirec*3; } if(movey〈0) { //up jumpheight+=(—movey); //根据重力影响,加速度减慢 if(movey〈—1) { movey++; } //到达顶点后向下落 if(jumpheight>=JUMP_HEIGHT*32) { jumpheight=JUMP_HEIGHT*32; movey=4; } } elseif(movey>0) { jumpheight—=movey; //根据重力影响,加速度增大 movey++; } } voidMYROLE: : Jump() { //上升过程 MoveOffset(0,—4); } voidMYROLE: : ChangeFrame() {} voidMYROLE: : SetState(inti) { iState=i; } voidMYROLE: : SetAni(intistyle) {iAniStyle=istyle; iparam1=0; iAniBegin=1; } //是否正在播放动画 intMYROLE: : IsInAni() {returniAniBegin; } voidMYROLE: : PlayAni() { switch(iAniStyle) { caseROLE_ANI_DOWN: if(iparam1〉31) { break; } //人物下降动画 SelectObject(hdcsrc,hBm); BitBlt(hdcdest, xpos,ypos+iparam1, width,height/2-iparam1, hdcsrc, iFrame*width,height/2,SRCAND); BitBlt(hdcdest, xpos,ypos+iparam1, width,height/2—iparam1, hdcsrc, iFrame*width,0,SRCPAINT); iparam1++; break; caseROLE_ANI_UP: if(iparam1>31) { break; } //人物上升动画 SelectObject(hdcsrc,hBm); BitBlt(hdcdest, xpos,ypos+32-iparam1, width,iparam1, hdcsrc, iFrame*width,height/2,SRCAND); BitBlt(hdcdest, xpos,ypos+32—iparam1, width,iparam1, hdcsrc, iFr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 超级 玛丽 增强 源代码
![提示](https://static.bdocx.com/images/bang_tan.gif)