GithubHelp home page GithubHelp logo

alieninvasiongame's Introduction

AlienInvasionGame

《Python编程-入门到实践》书中的实例项目1

alien_invasion.py

包含AlienInvasion类,这个类创建一系列游戏中所需要的属性:赋给self.settings的设置,赋给screen中的主显示surface,以及飞船、子弹等实例。
此外还包含游戏的主循环,即while循环。while循环中调用_check_events()、ship.update()和_update_screen()。
方法_check_events()检测相关的事件(例如按下和松开按键),并通过调用方法_check_keydown_events()和_check_keyup_events()处理这些事件。这些方法主要负责飞船的移动。
玩游戏时只需运行文件alian_invasion.py

settings.py

文件setteings.py包含Settings类,这个类只包含方法__int__(),用于初始化控制游戏外观和飞船速度的属性。

ship.py

文件ship.py包含Ship类,这个类包含方法__int__()、管理飞船位置的方法update()和在屏幕上绘制飞船的方法blitme()。飞船图形位于images文件夹的ship.bmp。

alieninvasiongame's People

Contributors

liguangru avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.