当前位置:网站首页>Aircraft collision detection
Aircraft collision detection
2022-07-27 18:47:00 【Rise from the road】
collision detection
List of articles
The goal is
- Understand collision detection methods
- Collision implementation
One 、 Understand collision detection methods
pygame Provides Two are very convenient The method can realize collision detection :
pygame.sprite.groupcollide()
- Two elf groups in All the elves Collision detection based on
groupcollide(group1, group2, dokill1, dokill2, collided = None) -> Sprite_dict
- If you will dokill Set to True, be Colliding sprites will be automatically removed
- collided Parameters are used for Callback function to calculate collision
- If not specified , Then each elf must have one rect attribute
pygame.sprite.spritecollide()
- Judge Some elf and Specify the sprite group The collision of elves in
spritecollide(sprite, group, dokill, collided = None) -> Sprite_list
- If you will dokill Set to True, be Specify the sprite group in Colliding sprites will be automatically removed
- collided Parameters are used for Callback function to calculate collision
- If not specified , Then each elf must have one rect attribute
- return Spirit group Middle heel spirit There was a collision List of elves
Two 、 Collision implementation
def __check_collide(self):
# 1. The bullet destroyed the enemy plane
pygame.sprite.groupcollide(self.hero.bullets, self.enemy_group, True, True)
# 2. The enemy plane crashed the hero
enemies = pygame.sprite.spritecollide(self.hero, self.enemy_group, True)
# Judge whether there is content in the list
if len(enemies) > 0:
# Let the hero die
self.hero.kill()
# End the game
PlaneGame.__game_over()
summary
This chapter is the final chapter of the aircraft war , Combine the contents of previous chapters , Write here , The whole game is finished , Interested friends do it by themselves ! Tomorrow, all the implementation source codes of the aircraft war will be released , Don't miss your favorite friends !
Where are the deficiencies or better suggestions , Welcome to make complaints about Tucao , There is a little friend who doesn't understand can confide in me , I will answer them one by one , Thank you for your approval , Thank you for your support !
边栏推荐
- ValueError: Found input variables with inconsistent numbers of samples: [80019456, 26673152]【报错】
- mysql视图基本操作
- @Considerations for query of convert annotation in JPA
- MySQL 主从复制数据不一致,怎么办?
- JS to achieve smooth scrolling of pages or DOM elements
- org.apache.catalina.core.StandardContext. startInternal Context [] startup failed due to previous err
- 2021.7.19 notes DML
- 微信小程序获取手机号
- 微信小程序多文件上传
- Commonly used built-in methods of mybtis plus
猜你喜欢

uniapp H5跨域问题

2021.7.31笔记 视图

Complete set of machine learning classification task effect evaluation indicators (including ROC and AUC)

2021.7.30 note index

20000 words + 30 pictures | what's the use of chatting about MySQL undo log, redo log and binlog?

Login page tablelayout

V-bind and V-for

机器学习分类任务效果评估指标大全(包含ROC和AUC)

Quick access to website media resources

LED带风扇护眼学习台灯触摸芯片-DLT8S12A
随机推荐
Use mobaxtermto establish a two-tier springboard connection
全身多功能按摩仪芯片-DLTAP602SD
Uniapp has no effect on the page selector on the app side
pygame飞机大战游戏背景实现
2021.8.7笔记 servlet
JPA connection database password field blob
Random talk on GIS data (V) - geographic coordinate system
org.gradle.api. UncheckedIOException: Could not load properties for module ‘gradle-kotlin-dsl‘ from C
What if MySQL database forgets its password???
idea 2020.1社区版下载体验
How to realize the full-text content retrieval of word, PDF and txt files?
Knowledge map pyhanlp realizes named body recognition (with named body recognition code)
2021.7.30 note index
[yuntu said] 249 mobile application security service - app's physical examination center, comprehensive testing, safe on the road!
电动加热护颈枕芯片-DLTAP703SC
2021.7.12笔记 内外连接
ERROR 1366 (HY000): Incorrect string value: ‘\xE8\xB5\xB5\xE9\x9B\xB7‘ for column ‘s_ name‘ at row 1
阿里架构师耗时280个小时整理的1015页分布式全栈小册,轻松入手分布式系统
微信小程序多文件上传
was not registered for synchronization because synchronization is not active[已解决]