(译)win32asm实例-0

类别:编程语言 点击:0 评论:0 推荐:

  这个教程写得非常好,希望你能喜欢。



-译者



Mosaic tutorial拼图游戏教程



Introduction介绍

In this lesson you will create a simple mosaic game. You probably know this kind of puzzles. An image or a matrix of numbers have to be placed in the right order by shuffeling the pieces into place. This lesson will teach you how to create this game step by step. It is useful to read the tutorials first before you start with this lesson. It's level is aimed at the beginner, everything is explained.



在本教程中,你将创建一个简单的拼图游戏。你可能知道这种字画迷。一幅画或一个数字矩阵必须由从一个地方拖到另一个地方来摆好顺序。本教程将一步步教你怎样创建这个游戏。在开始这个教程前,读一读前面的教程(win32asm教程-译者注)是很有帮助的。难度面向初学者,每件事都会得到解释。








Prologue前言

This lesson is aimed at the beginner in asm. Every step in creating the program is explained. It is not just source code with comments, but it teaches you how to build up a program from scratch. My advice is to fully read the tutorial, and try to make the program yourself. This lesson is quite long but it will help you very much if you read it all.



本教程着眼于asm的初学者。程序创建中的每一步都会解释。这不仅仅是带有注释的源代码,而是教你如何白手起家的创建一个程序。我的建议是通读前面的教程,并且试着自己来写程序。本教程相当的长,但如果你都读了的话将对你很有益处。





Checklist清单

Make sure you have the following installed:



确保你安装了一下工具:



·         The masm32 package, version 6 with at least service pack 2 (win32asm.cjb.net)



·         A good resource editor. This is not necessary, but a lot easier to do it by hand. To make this lesson accessible for anyone, I'll explain how to write the resources by hand (they are simply text files), but if you know how to use a resource editor you can use that instead. Good resource editors are: Borland Resource Workshop* (protools.cjb.net) and the resource editor in Microsoft Visual Studio (Visual C++).



·         A resource compiler (rc.exe will do for hand written files and microsoft visual studio's resource editor, but not for BRW).



·         make sure that you have included the \masm32\bin folder and the paths of the other necessairy tools included in your path.



 



·         masm32包,版本6加上至少sp2



·         一个好用的资源编辑器。这不是必须的,但用它做会更加容易。为了使得本教程对所有人都可用,我将用手工的办法来解释如何写资源(它们仅仅是文本文件)。但如果你知道怎样使用资源编辑器,你也可以用它代替。好的资源编辑器有:Borland Resource Workshop(protools.cjb.net)和微软Visual Studio(Visual C++)中的资源编辑器。



·         一个资源编译器(rc.exe可以用于手工写的文件和微软Visual Studio的资源编辑器,但不可以用于BRW)



·         确保你把\masm32\bin文件夹和其他必要工具的路径包含在你的路径(path环境变量)中了。



* BRW is no longer supported by Borland so you can download this legally (although I don't know for sure), but you need the brc32 tool to compile it (their resoure format is somewhat different from microsoft's, so using rc.exe wouldn't work). This tool is included in the TASM package but you cannot download this legally.



*BRW已经不再由Borland支持因而你可以合法地下载(虽然我不确知),但你需要brc32工具来编译它(它们地格式和微软地有些不同,因而使rc.exe工作不正常),这个工具包含在TASM包中,但你不能合法地下载它。





Glossary小字典

As this is a lesson for the real beginners, this list of definitions can be useful. Read them if you don't know them already, it will help you understand the rest of the lesson.



因为这是一本面向初学者的教程,这个定义列表可能会有用。如果你还不知道它们,读一读吧。它将对你理解后面的课程很有帮助。











Resources




A resource is data that is stored in the program file. A resource can be an icon, a table with strings, menu, dialog, bitmap, user defined data etc. The resources are first defined in a .rc file. This is a simple text file which you can write manually but it's much easier to use a resource editor like borland resource workshop or the editor in visual studio. The resources are then compiled into a binary file (.res). This file is then linked (yes with link) to the executable. Resources are accessed by their IDs. These IDs can be set in the resource file and in your source code you use the same ID to access the resource.







Owner-drawn windows





Owner-drawn windows are windows that are drawn by the program instead of the system. In this lesson a static control is used as an owner-drawn window. A WM_DRAWITEM message is sent to the window when the control needs to be drawn.







Local variables





Local variables are variables (i.e. data) that is used only in a specific procedure. Local data is saved while the procedure is running, but deleted afterwards (it is stored on the stack). Local variables are declared with LOCAL at the start of a procedure:
SomeProc proc ....
LOCAL localvar:DWORD







资源





资源是储存在程序文件中的数据。一个资源可以是图标,字符串的表格,菜单,位图,用户定义的数据等。资源先在rc文件中定义。这是一个你可以手工写的简单纯文本文件但用像Borland Resource Workshop或Visual Studio中的工具会更简单。然后,资源被编译为二进制文件(.res)。再后,文件被链接(是的,用链接器)到可执行文件中。资源通过它们的ID(s),存储。这些ID可以在资源文件中设置而且在你的源代码中,你使用相同的ID来读取资源。





Owner-drawn 窗口




Owner-drawn 窗口是由程序代替系统画出的窗口。在本教程中,一个静态控件被用作Owner-drawn窗口。WM_DRAWITEM消息在控件需要画出的时候发送给窗口






局部变量




局部变量仅仅是用于指定过程的变量(就是数据)。局部变量在过程运行时被保存但之后就删除了(他储存在栈中)。局部变量在过程开始处用LOCAL声明:
SomeProc proc ....
LOCAL localvar:DWORD

本文地址:http://com.8s8s.com/it/it29720.htm