Python中的游戏脚本.doc

上传人:新** 文档编号:543153186 上传时间:2022-09-21 格式:DOC 页数:14 大小:76.51KB
返回 下载 相关 举报
Python中的游戏脚本.doc_第1页
第1页 / 共14页
Python中的游戏脚本.doc_第2页
第2页 / 共14页
Python中的游戏脚本.doc_第3页
第3页 / 共14页
Python中的游戏脚本.doc_第4页
第4页 / 共14页
Python中的游戏脚本.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《Python中的游戏脚本.doc》由会员分享,可在线阅读,更多相关《Python中的游戏脚本.doc(14页珍藏版)》请在金锄头文库上搜索。

1、Game Scripting in PythonBruce DawsonHumongous Ehttp:/www.cygnus- languages allow rapid development of game behaviour without the pitfalls that await the unwary C+ programmer. Using an existing scripting language saves the time and cost of developing a custom language, and typically gives you a far m

2、ore powerful language than you could create on your own.Python is an excellent choice for a game scripting language because it is powerful, easily embedded, can seamlessly be extended with C/C+ code, has most of the advanced features that make scripting languages worthwhile, and can also be used for

3、 automating production. Additionally, the books, development tools and libraries available for Python provide great opportunities for benefiting from the work of others.This session describes our experiences at Humongous Entertainment with integrating Python into our new game engine. It explains why

4、 we chose Python, the benefits weve seen, the problems weve encountered, and how we solved them.Why use a scripting language?C+ is a powerful language and an enormous improvement over C. However it is not the best choice for all tasks. The emphasis in C+ is run-time performance Stroustrup94 and no f

5、eature will make it into the language if it makes programs run slower. Thus, C+ programmers are burdened with many restrictions and inconveniences.A few of the restrictions that C+ programmers are so used to they usually dont notice include: Manual memory management: a huge amount of C+ programmer t

6、ime is spent making sure that delete gets called at the appropriate time. Link phase: C+ modules are linked together so that function addresses dont need to be resolved at run-time. This improves run-time performance, but slows down the edit/test cycle. Lack of introspection: C+ code has way of know

7、ing what members are in a class. This makes writing code to load and save objects an enormous task that in some scripting languages is a single call to a built-in function.C+ is static, scripting languages are dynamic. Grossly oversimplified this means that C+ runs fast, but scripting languages let

8、you code faster.Thus, C+ should only be used when you need to optimize for run-time performance. On todays fast computers there are huge blocks of code where performance is not an issue. If you develop these in C+ when a scripting language would do then you are optimizing for the wrong thing.Whats w

9、rong with SCUMM?Humongous has used SCUMM (Script Creation Utility for Maniac Mansion) to create over 50 different games. SCUMM is a powerful adventure game creation language, but it has some limitations. SCUMM was written more than a decade ago and it is missing some of the features found in more mo

10、dern languages.Despite continual patching and maintenance, SCUMM will never be as full featured and robust as the many other languages available.Why Python?We explored the idea of creating a new, more modern proprietary language, but wisely discarded the idea. We are in the business of making games,

11、 not languages.After spending millions of dollars over the years maintaining a suite of proprietary tools we, really wanted to go with an existing scripting language rather than creating one. Existing languages let us get started faster, have lower maintenance costs, are generally better than a lang

12、uage we would create, and tend to get better over the years, even if we dont work on them.Once we decided that we wanted to use an existing scripting language we had to choose one. We needed something clean that would support object oriented programming and could be embedded in our games, without te

13、chnical or licensing problems.We considered Lua Lua01 and Python Python02, both of which had been used in several games.Lua is smaller and probably easier to embed in an application, and has some nice language constructs. However, at the time we were choosing a language the documentation was a bit s

14、ketchy. This is probably because Lua is a newer language than Python.Python has more extension modules than Lua, more books written about it, and stackless Python Tismer01, which was a promising way of creating micro-threads for object AI. We ended up not using the stackless version of Python, but w

15、e did start using Python for writing automated build scripts and this gave us momentum. We knew the syntax, we liked it, and so we chose Python.Both languages have been improved since we made our decision Lua has become stackless and Python has acquired generators, which allow some similar functionality. Either language is a safe choice.Who is using Python in gamesPython has been used in a number of games, including: ToonTown - http:/ EveOnline - http:/www.eve- Blade of Darkness - http:/ numerous other sightings that are

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号