資源簡介
Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰Python項目實戰

代碼片段和文件信息
import?pygame
from?random?import?*
class?SmallEnemy(pygame.sprite.Sprite):
????def?__init__(self?bg_size):
????????pygame.sprite.Sprite.__init__(self)
????????self.image?=?pygame.image.load(“images/enemy1.png“).convert_alpha()
????????self.destroy_images?=?[]
????????self.destroy_images.extend([\
????????????pygame.image.load(“images/enemy1_down1.png“).convert_alpha()?\
????????????pygame.image.load(“images/enemy1_down2.png“).convert_alpha()?\
????????????pygame.image.load(“images/enemy1_down3.png“).convert_alpha()?\
????????????pygame.image.load(“images/enemy1_down4.png“).convert_alpha()?\
????????????])
????????self.rect?=?self.image.get_rect()
????????self.width?self.height?=?bg_size[0]?bg_size[1]
????????self.speed?=?2
????????self.active?=?True
????????self.rect.left?self.rect.top?=?\
????????????????????????randint(0?self.width?-?self.rect.width)?\
????????????????????????randint(-5?*?self.height?0)
????????self.mask?=?pygame.mask.from_surface(self.image)
????def?move(self):
????????if?self.rect.top?????????????self.rect.top?+=?self.speed
????????else:
????????????self.reset()
????def?reset(self):
????????self.active?=?True
????????self.rect.left?self.rect.top?=?\
????????????????????????randint(0?self.width?-?self.rect.width)?\
????????????????????????randint(-5?*?self.height?0)
class?MidEnemy(pygame.sprite.Sprite):
????energy?=?8
????
????def?__init__(self?bg_size):
????????pygame.sprite.Sprite.__init__(self)
????????self.image?=?pygame.image.load(“images/enemy2.png“).convert_alpha()
????????self.image_hit?=?pygame.image.load(“images/enemy2_hit.png“).convert_alpha()
????????self.destroy_images?=?[]
????????self.destroy_images.extend([\
????????????pygame.image.load(“images/enemy2_down1.png“).convert_alpha()?\
????????????pygame.image.load(“images/enemy2_down2.png“).convert_alpha()?\
????????????pygame.image.load(“images/enemy2_down3.png“).convert_alpha()?\
????????????pygame.image.load(“images/enemy2_down4.png“).convert_alpha()?\
????????????])
????????self.rect?=?self.image.get_rect()
????????self.width?self.height?=?bg_size[0]?bg_size[1]
????????self.speed?=?1
????????self.active?=?True
????????self.rect.left?self.rect.top?=?\
????????????????????????randint(0?self.width?-?self.rect.width)?\
????????????????????????randint(-10?*?self.height?-self.height)
????????self.mask?=?pygame.mask.from_surface(self.image)
????????self.energy?=?MidEnemy.energy
????????self.hit?=?False
????def?move(self):
????????if?self.rect.top?????????????self.rect.top?+=?self.speed
????????else:
????????????self.reset()
????def?reset(self):
????????self.active?=?True
????????self.energy?=?MidEnemy.energy
????????self.rect.left?self.rect.top?=?\
????????????????????????randint(0?self.width?-?self.rect.width)?\
????????????????????????randint(-10?*?self.height?-self.height)
class?BigEnemy(pygame.sprite.Sprite):
????energ
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????228??2018-04-20?21:19??Plane\.idea\inspectionProfiles\profiles_settings.xm
?????文件????????212??2018-04-20?21:19??Plane\.idea\misc.xm
?????文件????????262??2018-04-20?21:19??Plane\.idea\modules.xm
?????文件????????284??2018-04-20?21:19??Plane\.idea\Plane.iml
?????文件???????1361??2018-04-20?21:19??Plane\.idea\workspace.xm
?????文件???????4771??2018-04-20?21:19??Plane\enemy.py
?????文件??????78500??2018-04-20?21:19??Plane\font\font.ttf
?????文件???????6567??2018-04-20?21:19??Plane\images\again.png
?????文件??????32756??2018-04-20?21:19??Plane\images\background.png
?????文件???????8480??2018-04-20?21:19??Plane\images\bomb.png
?????文件???????9964??2018-04-20?21:19??Plane\images\bomb_supply.png
?????文件???????2989??2018-04-20?21:19??Plane\images\bullet1.png
?????文件???????2989??2018-04-20?21:19??Plane\images\bullet2.png
?????文件???????9706??2018-04-20?21:19??Plane\images\bullet_supply.png
?????文件???????5499??2018-04-20?21:19??Plane\images\enemy1.png
?????文件???????5797??2018-04-20?21:19??Plane\images\enemy1_down1.png
?????文件???????6181??2018-04-20?21:19??Plane\images\enemy1_down2.png
?????文件???????7361??2018-04-20?21:19??Plane\images\enemy1_down3.png
?????文件???????4199??2018-04-20?21:19??Plane\images\enemy1_down4.png
?????文件??????10918??2018-04-20?21:19??Plane\images\enemy2.png
?????文件??????12527??2018-04-20?21:19??Plane\images\enemy2_down1.png
?????文件??????13315??2018-04-20?21:19??Plane\images\enemy2_down2.png
?????文件??????14680??2018-04-20?21:19??Plane\images\enemy2_down3.png
?????文件???????5500??2018-04-20?21:19??Plane\images\enemy2_down4.png
?????文件??????11712??2018-04-20?21:19??Plane\images\enemy2_hit.png
?????文件??????47670??2018-04-20?21:19??Plane\images\enemy3_down1.png
?????文件??????50549??2018-04-20?21:19??Plane\images\enemy3_down2.png
?????文件??????56999??2018-04-20?21:19??Plane\images\enemy3_down3.png
?????文件??????60637??2018-04-20?21:19??Plane\images\enemy3_down4.png
?????文件??????67264??2018-04-20?21:19??Plane\images\enemy3_down5.png
............此處省略48個文件信息
- 上一篇:深度學習入門 基于python理論與實現
- 下一篇:python之外星人入侵
評論
共有 條評論