当前位置:网站首页>PyGame realizes the airplane war game
PyGame realizes the airplane war game
2022-07-23 11:11:00 【weixin_ forty-five million nine hundred and eighty-six thousand】
title :pygame Realize the airplane war game
Source link : Add link description
One 、 Concrete demonstration
1. Monsters are divided into small monsters , And big monster ; Monsters can fire bullets
2. Hero planes share 10 Life value
3. The hero plane can move up, down, left and right
4. It shows the hero's HP , Kill the number of monsters ,
5. Supply package is provided , It can change the bullets fired by the hero plane


Two 、 Description of project
hm_01_pygame_base05.py
hm_01_pygame_base06.py, Aircraft battle 【 Non object oriented aircraft war , As a familiar , Warm up 】
message.py ,message2.py, Is in pygame Output a sentence on the screen 【 As a familiar , Warm up 】
plane_main2.py,plane_sprites.py, yes 【 formal 】 The aircraft war project
Use python Realize the airplane war game , fit python Basic introduction , At the same time, on the basis of general aircraft war , Many new features
3、 ... and 、 Project details
1. background , The plane 【 complete 】
2. Enemy planes flying in and out , Multiple — Timer + Event monitoring , The destruction 【 complete 】
3. Aircraft bullets 【 complete 】
【 Specific implementation operations 】
【 analysis :】 The plane , Enemy aircraft, etc , They are all drawn at last , So the key is when to add it ,
The bullet - - every other 0.5s Listening for events , Add bullets to the sprite Group ==》 Draw the bullet ,
【 operation 】 stay init Create a sprite group in , Monitoring , Add in .
every other Xs, According to the position of the aircraft , Launch once ,
however , There is no bound plane :
eg: When several monsters appear , Each monster needs a different elf Group
solution: stay hero Class , Create bullet sprite group ,main Draw it in ,fire Be responsible for adding bullets to the spirit Group
4. Aircraft movement – Set boundaries 【 complete 】
5. The plane spewed fire 【 complete 】
6. Collision effect
The bullet – Enemy planes flying in and out 【 complete 】
hero– Enemy planes flying in and out
6.1 The bullet – Enemy planes flying in and out :
The enemy plane exploded : Draw the explosion wizard Group , Listen to the explosion , Add the explosive class to the wizard Group
6.2hero– Enemy planes flying in and out :
So it should be , Clear the screen first , And then print “ Game over “, Wait for the key — Call this method
self.__game_over()
【solution】 Set a sign of the end of the game , In order to achieve the end of the key
Enemy planes flying in and out , The bullet , It's all in event monitoring 【 every other Xs】 The emergence of , therefore , After setting this flag , There won't be
self.gameover_flag = False
7. How to print a sentence on the screen find font C:\WINDOWS\Fonts\ARIALN.TTF
== Achieve HP , Kill the number of monsters
8. Big monster 2 3
Big monster – bullets ,
【 Pay attention to the relative speed : Big monster , The bullet 、 The background is moving 】
If the speed is not selected — There may be a situation of retreat
You can set the time when each bullet appears
9. Monster explosion
hero , Touch a bullet —true, The bullet disappeared ;
hero + effect
10 Bomb supply
The original bullet , Supply bullets — All are event In the listening
Set up a flag, The judgment is original , Or supply ,【supply The collision , Set as supplied 】
In the game cycle — Time , Using variables , Estimate the end time of supply ,
If it ends , Recovery flag
11. Big monster 3 【 To be continued 】
边栏推荐
- [Social Media Marketing] new idea of going to sea: WhatsApp business replaces Facebook
- Mysql事务回滚机制与原理
- 视、音频分开的网站内容如何合并?批量下载代码又该如何编写?
- Heidelberg CP2000 circuit board maintenance printer host controller operation and maintenance precautions
- RPC与thrift入门
- An accident caused by MySQL misoperation, and "high availability" is not working well
- 3.Flask 中的线程
- vim常用命令总结
- 【无标题】
- 8、曲面几何
猜你喜欢

RPC与thrift入门

C1 -- vivado configuration vs code text editor environment 2022-07-21

Single sign on - how to unify the expiration time of session between authentication server and client

pyspark学习笔记

Powerbi Getting Started Guide

Dictionary creation and copying

【系统问题】.NET Framework 3.5 安装错误

Markdown common syntax records

【Pyradiomics】提取的影像组学特征值不正常(很多0和1)

安装企业版pycharm以及anaconda
随机推荐
Markdown common syntax records
LearnOpenGL - Introduction
Hyperlink de underlined code
Epidemic period plus midlife crisis - three months wandering at the crossroads
好玩的代码雨,在线分享给大家~-
支付宝DTS架构
【6.28】
Federated primary keys and indexes
Why does MySQL index use b+ tree?
【无标题】
图片模糊处理批量生产模糊数据集
Compare the advantages and disadvantages of RDB and AOF modes of redis
Fundamentals of software testing - design method of test cases
JDBC数据库连接池
web调用接口上传图片到七牛云
Briefly describe the features and application scenarios of redis
Activiti工作流使用之流程结构介绍
主从同步步骤读写分离+自遇错误分享
Keras保存训练过程中的最好模型
视图集及路由