游戏制作入门指南
我经常被问及:一个具有很少甚至没有编程经验的人要如何开始游戏制作。直到目前为止,我总是尽我所能一个一个解答。然而,问题的数量已经增长到了一个难以处理的水平,于是,我便决定把所有的建议汇总在一篇文章里作为参考提供给人们。 I often get asked how someone with little or no programming experience can get started in game development. Up until now, I have always tried to help them along as much as I can on a one-to-one basis. However, because the number of questions has grown to an almost unmanageable level lately, I decided it is time for me to put all my advice in an article to serve as a general resource.
这篇文章主要面向那些想开发自己的游戏,但仅有一点点或没有半点编程经验的人们。实际上,我也假定读者根本没有任何的编程知识。我将把重点放在游戏开发的编程和设计方面,而不是艺术方面。我也不准备对游戏行业进行论述(因为这个话题的资料太多了),但是,我会带你浏览一下在制作游戏之前需要做的一些事情。该说明的一点是,不要将我这里所介绍的方法当作唯一的或最好的学习游戏制作的路径,但对于我和其他人来说,它是有效的。 This article is intended for people who want to make their own games, but who have little or no programming experience. In fact, I'm going to assume the reader has no programming knowledge at all. I will focus mainly on the programming and design aspects of game development, and not the artistic side. I am not going to cover actually getting into the industry (because there are already ample resources for that) but I will walk you through the things you need to do to get to the point that you can make your own games. Finally, the path I lay out here should not be looked at as the only ?or even the best ?route to learning how to make games, but it has worked well for me and for other people.
1、选择一门语言 Choosing a Language
第一件要做的事就是选择一门语言。你有一大堆的选择,包括 Basic、Pascal、C、C++、Java 等等,同样也有一大堆关于哪门语言最适合初学者的争论。欲了解各种语言的优缺点,请参阅 John Hattan 的绝妙文章《我该使用什么语言》。 The first thing you will need to do is to choose a language to program in. You have a lot of choices, including Basic, Pascal, C, C++, Java, etc., and there is a great deal of debate over which language is best for beginners. For a discussion of a number of popular languages, see John Hattan's excellent article, What Language Do I Use?
我这里建议使用 C 和 C++。有些人认为这些语言对于初学者来说太难了,但从我个人角度来说我是反对这个观点的,因为我自己就是从 C++ 起步的。另外,C/C++ 是目前最广泛应用的语言,因此,你能找到大量的资料和帮助。至于先学 C 还是先学 C++ 的问题不大,因为一旦你学习了其中一种,再学习另外一种就没太大问题了。不过,如果你一开始就选择 C++,请确信在学习面向对象编程之前,你已经了解并掌握了面向过程编程。(比如说,如果你在不使用类的前提下仍无法编好程序,先不要急于学习类) I'm going to recommend starting with C and C++. Some people will say that those languages are too advanced for beginners, but because I started with C++ myself, I tend to disagree. In addition, C/C++ is the most widely used language today, so you will be able to find a wealth of resources and help. It does not really matter whether you learn C or C++ first, because once you learn one, learning the other will be a trivial matter. However, if you choose to learn C++ first, make sure you understand and can use procedural programming before learning object-oriented programming (i.e. hold off on learning about classes until you can program well without them).
如果你发现学习 C/C++ 是一件很困难的事,不要紧,回过头选一门比较简单的语言来学,比如 Basic 或 Pascal。不过我认为,如果你坚持下去,并找一些好的资料,学习 C/C++ 的问题不大。 If you start with C/C++ and it turns out to be too difficult, there is nothing wrong with going back and learning a simpler language, such as Basic or Pascal. But I really think that if you stick with it and find the right resources, you should have no problem with C/C++.
你的下一个问题是:我如何学习 C/C++?我很高兴你问这个问题。最好的方法是去听课。有没有老师帮助解答问题,对于你的发展影响巨大,而且编程作业将确保你确实掌握了所学的东西。 Your next question should be, "How do I learn C/C++?" I'm glad you asked. The best way is to take a class. Having an instructor and TAs available to answer questions and help you along makes a huge difference, and the programming assignments will ensure that you actually apply what you are learning.
如果听课不在你的考虑范围内,下一个最好的办法就是找一些好书。不要把注意力放在那些“大全”书上,因为你终究会买几本。我建议你去一个本地书店,花点时间浏览一下介绍 C 和 C++ 的书,直到找到你能理解并能从中学到东西的一本。同时,你可能还想买几本进阶书或是一本参考书,但一旦你具有了这门语言的部分知识,你会对你需要什么有更好主意。可以在网站BOOKS频道中找到一些建议。 If taking a class is not an option for you, the next best thing is to get some good books. Don't stress too much about picking the "perfect book", because you are probably going to buy several eventually. I'd suggest going to a local bookstore and spending some time browsing the introductory C and C++ books until you find one that you understand and think you can learn from. In time, you will want to pick up some more advanced books, and probably a reference, but once you have some knowledge of the language, you will have a better idea of what you need. See our books section for some suggestions.
在此,我简要的说明一下我见过的很多入门程序员,尤其是年轻人关心的事情:没有钱买书或其他东西。首先,有许多资源是免费的,包括图书馆和 Macmillan Computer Publishing (他们的网站 www.mcp.com 上有数百本编程的书)。其次,如果你想成为一名优秀的程序员,你不得不考虑在这上面的投资。利用各种手段(合法的 ;<)去弄点钞票来。 At this point, I want to take a moment and address something that I have seen as a concern for a lot of beginning programmers, especially younger ones: not having money to buy books and other things. First, there are free resources available, including your local library, and Macmillan Computer Publishing, which has hundreds of programming books online at http://www.mcp.com/personal. But second, if you really want to become a good programmer, you have to plan on making an investment in it. Use whatever (legal ;<) means you have to come up with some cash.
网络上有大量的 C 和 C++ 的学习教程,但是我认为这些教程作为你学习书本的参考要比作为单独的材料好得多。 There are also a number of tutorials available on the web for learning C and C++, but I have found that tutorials are better for supplementing what you learn in books than for being a stand-alone resource.
2、选择合适的编译器 Picking the Right Compiler
你写的程序,或源码是以文本文件存储的,你甚至可以用记事本来写 C/C++ 程序。但是,必须有样东西能把这些源码转化成一个可执行文件。对于 C 和 C++ 来说,这样东西就是一个编译器。 The programs you write, or source code, is stored as a text file, and you can even use Notepad to write a C/C++ program. But something needs to take that source code and convert it into an executable file. In the case of C and C++, that something is a compiler.
现在有大量的编译器存在,其中有许多是免费的。选择一个合适的编译器是非常重要的,而免费编译器有个好处就是你能一个一个的试,看哪个你最喜欢。但是,免费编译器经常是比商业编译器功能少或缺少良好的技术支持。幸运的是,大多数商业编译器都有与完整版功能相同,但价格便宜许多的介绍版或学习版,唯一的限制是,你不能发布使用该编译器开发的程序(这点你肯定维持不久)。 There are a large number of compilers available, including many free ones. It is important to choose a compiler that you are comfortable with, and the free ones have the advantage that you can try them all out and see which one you like best. However, free compilers are often not as full-featured or well-supported as commercial ones. Fortunately, most commercial compilers come in introductory or academic versions, which cost much less and usually have the same features as the full version, with the only restriction being that you cannot distribute programs you create using it (which you are not going to be doing for a while anyway).
基本上,你选择什么样的编译器取决于你能花多少钱、你将在什么操作系统和平台上开发程序。如果你准备为 Windows 作贡献,我强烈建议使用微软的 Visual C++。它具有一个功能强大的开发环境,能让你倍感轻松,再也没有其他编译器能比它更适合开发 Windows 软件了。如果你是名学生,你可以以极低的价格获得一份拷贝。如果你准备在 DOS 下开发程序,你最好使用免费的 DJGPP。 Ultimately, the compiler you choose will depend on how much you can spend and which operating system and platform you will be developing for. If you are going to be developing for Windows, I strongly suggest using Microsoft Visual C++. It has a powerful development environment that will make a lot of things easier for you, and there is no question that no other compiler is more well-suited to developing Windows applications. If you are a student, you can obtain a copy for a significantly reduced price. If you are going to program in DOS, your best bet is probably DJGPP, which is free.