APP下载

基于Python的小恐龙游戏设计与分析

2019-10-21董彧先

现代信息科技 2019年12期

摘  要:Python是一种跨平台的、开源的、免费的、解释型的高级编程语言。它具有丰富的、强大的库,能够把其他语言制作的各种模块很轻松地联结在一起,所以Python常被称为“胶水”语言。Python语言近几年发展势头迅猛,应用领域也非常广泛,在Web编程、图形处理、黑客编程、大数据处理、网络爬虫、科学计算和游戏编程等领域都能找到Python的应用。Python语言的研究和发明主要是为了便于学习和应用,因此Python语言是开源的,并且语法非常简单、容易编写和理解。本文通过对小恐龙游戏的设计与分析,掌握Python语言在游戏开发领域的优势。

关键词:Python;游戏开发;计算机语言;程序设计

中图分类号:TP311.1       文献标识码:A 文章编号:2096-4706(2019)12-0081-03

Abstract:Python is a cross-platform,open source,free,explanatory high-level programming language. It has rich and powerful libraries,which can easily connect various modules made by other languages. So Python is often called “glue” language. Python language has developed rapidly in recent years,and its application fields are also very wide. It is used in Web programming,graphics processing,hacker programming,big data processing,network crawler,scientific computing and game programming. Python language research and invention is mainly for easy learning and application,so Python language is open source,and the grammar is very simple,easy to write and understand. Through the design and analysis of small dinosaur game,we can grasp the advantages of Python language in the field of game development.

Keywords:Python;game development;computer language;programming

0  引  言

Python是一種计算机程序设计语言,是一种面向对象的动态类型语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,Python越来越多被用于独立的大型项目的开发。Python语言在游戏开发领域有着自己的优势,可以通过相对于其他编程语言更加人性化的语法和更加少的代码量来完成相同的任务。

在本文设计的基于Python的游戏中会看见一只小恐龙,按下键盘中的空格键就能激活该恐龙,然后可以通过空格键来控制小恐龙的跳跃进行障碍物的躲避,并且躲避障碍物的数量进行分数的统计。

1  Python小恐龙游戏的设计流程

在游戏主窗体下完成显示小恐龙、显示滚动地图、随机显示障碍物。在显示小恐龙的同时编写小恐龙的跳跃功能和音效。同时判断游戏中移动的障碍物是否与小恐龙发生碰撞。……

登录APP查看全文