超级玛丽制作揭秘1

两个版本的超级玛丽下载量已达到5000,谢谢大家支持。谁无法下载,请告诉我邮箱,我直接发。现在普遍反映两个问题,一没有帮助文档,二代码注释太少。今天起,我揭秘制作过程,保证讲解到每一行代码,每一个变量。

代码我已经发布了,可见做这样一个游戏并不难。今天讲准备工作,也就是所需要的开发工具。代码编写调试:VC 6.0,美术工具:Windows自带的画图(开始-程序-附件-画图)。这是最简陋的开发工具,但已足够。最好再有Photoshop,记事本或UltraEdit等等你喜欢的文本编辑工具。

游戏代码分两部分,图像部分,逻辑部分。先说图像部分:图像分两种,矩形图片和不规则图片。可在工程中的PIC文件夹下,看到所有图像资源

矩形图片有:

地面、砖块、水管、血条、血条背景。

不规则图片有:

蘑菇(玩家,敌人1,敌人2),子弹、旋风、爆炸效果、金币、撞击金币后的得分、攻击武器(那个从魂斗罗里抠来的东东)、火圈1、火圈2、箭头(用于开始菜单选择)、树木、河流、WIN标志、背景图片(游戏背景和菜单背景)。

所有图片都分成几个位图BMP文件存储。一个文件中,每种图片,都纵向排列。每种图片可能有多帧。比如,金币需要4帧图像,才能构成一个旋转的动画效果,那么,各帧图像横向排列。

图像层的结构就这样简单,逻辑层只需要确定“哪个图像,哪一帧”这两个参数,就能在屏幕上绘制出所有图片。

图像层的基类是:

class MYBITMAP

 

 void Init(HINSTANCE hInstance,int iResource,int row,int col);
 void SetDevice(HDC hdest,HDC hsrc,int wwin,int hwin);

 void Draw(DWORD dwRop);

 HBITMAP hBm;
public:
 //按照行列平均分成几个
 int inum;
 int jnum;

 int width;
 int height;

 HDC hdcdest;
 HDC hdcsrc; 

这只是一个基类,上面是几个重要的数据成员和函数。它所描述的图片,是一个m行n列构成的m*n个图片,每个图片大小一致,都是矩形。显然,这并不能满足上面的设计要求,怎么解决呢?派生,提供更多的功能。但是,这个基类封装了足够的物理层信息:设备上下文HDC,和位图句柄HBITMAP。矩形图片的显示、不规则图片的显示、图片组织排列信息,这些功能交给它的派生类MYANIOBJ。

 

还有,我们最关心的问题是图片坐标,比如,不同位置的砖块、精灵、金币,这些由逻辑层处理,以后再讲,先到这里吧。

======================================================================== WIN32 APPLICATION : mario01 ======================================================================== AppWizard has created this mario01 application for you. This file contains a summary of what you will find in each of the files that make up your mario01 application. mario01.cpp This is the main application source file. mario01.dsp This file (the project file) contains information at the project level and is used to build a single project or subproject. Other users can share the project (.dsp) file, but they should export the makefiles locally. ///////////////////////////////////////////////////////////////////////////// AppWizard has created the following resources: mario01.rc This is a listing of all of the Microsoft Windows resources that the program uses. It includes the icons, bitmaps, and cursors that are stored in the RES subdirectory. This file can be directly edited in Microsoft Visual C++. res\mario01.ico This is an icon file, which is used as the application's icon (32x32). This icon is included by the main resource file mario01.rc. small.ico %%This is an icon file, which contains a smaller version (16x16) of the application's icon. This icon is included by the main resource file mario01.rc. ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named mario01.pch and a precompiled types file named StdAfx.obj. Resource.h This is the standard header file, which defines new resource IDs. Microsoft Visual C++ reads and updates this file. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" to indicate parts of the source code you should add to or customize. by cwc206.5d6d.com /////////////////////////////////////////////////////////////////////////////
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值