資源簡介
Python版的飛機大戰源碼和素材。素材包括有圖片和聲音

代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
“““
Created?on?Wed?Sep?11?16:36:03?2013
@author:?Leo
“““
import?pygame
SCREEN_WIDTH?=?480
SCREEN_HEIGHT?=?800
TYPE_SMALL?=?1
TYPE_MIDDLE?=?2
TYPE_BIG?=?3
#?子彈類
class?Bullet(pygame.sprite.Sprite):
????def?__init__(self?bullet_img?init_pos):
????????pygame.sprite.Sprite.__init__(self)
????????self.image?=?bullet_img
????????self.rect?=?self.image.get_rect()
????????self.rect.midbottom?=?init_pos
????????self.speed?=?10
????def?move(self):
????????self.rect.top?-=?self.speed
#?玩家類
class?Player(pygame.sprite.Sprite):
????def?__init__(self?plane_img?player_rect?init_pos):
????????pygame.sprite.Sprite.__init__(self)
????????self.image?=?[]?????????????????????????????????#?用來存儲玩家對象精靈圖片的列表
????????for?i?in?range(len(player_rect)):
????????????self.image.append(plane_img.subsurface(player_rect[i]).convert_alpha())
????????self.rect?=?player_rect[0]??????????????????????#?初始化圖片所在的矩形
????????self.rect.topleft?=?init_pos????????????????????#?初始化矩形的左上角坐標
????????self.speed?=?8??????????????????????????????????#?初始化玩家速度,這里是一個確定的值
????????self.bullets?=?pygame.sprite.Group()????????????#?玩家飛機所發射的子彈的集合
????????self.img_index?=?0??????????????????????????????#?玩家精靈圖片索引
????????self.is_hit?=?False?????????????????????????????#?玩家是否被擊中
????def?shoot(self?bullet_img):
????????bullet?=?Bullet(bullet_img?self.rect.midtop)
????????self.bullets.add(bullet)
????def?moveUp(self):
????????if?self.rect.top?<=?0:
????????????self.rect.top?=?0
????????else:
????????????self.rect.top?-=?self.speed
????def?moveDown(self):
????????if?self.rect.top?>=?SCREEN_HEIGHT?-?self.rect.height:
????????????self.rect.top?=?SCREEN_HEIGHT?-?self.rect.height
????????else:
????????????self.rect.top?+=?self.speed
????def?moveLeft(self):
????????if?self.rect.left?<=?0:
????????????self.rect.left?=?0
????????else:
????????????self.rect.left?-=?self.speed
????def?moveRight(self):
????????if?self.rect.left?>=?SCREEN_WIDTH?-?self.rect.width:
????????????self.rect.left?=?SCREEN_WIDTH?-?self.rect.width
????????else:
????????????self.rect.left?+=?self.speed
#?敵人類
class?Enemy(pygame.sprite.Sprite):
????def?__init__(self?enemy_img?enemy_down_imgs?init_pos):
???????pygame.sprite.Sprite.__init__(self)
???????self.image?=?enemy_img
???????self.rect?=?self.image.get_rect()
???????self.rect.topleft?=?init_pos
???????self.down_imgs?=?enemy_down_imgs
???????self.speed?=?2
???????self.down_index?=?0
????def?move(self):
????????self.rect.top?+=?self.speed
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-09-22?19:19??Python飛機大戰\
?????目錄???????????0??2018-09-22?19:19??Python飛機大戰\PythonShootGame-master\
?????文件????????2741??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\gameRole.py
?????文件????????6403??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\mainGame.py
?????目錄???????????0??2018-09-22?19:19??Python飛機大戰\PythonShootGame-master\resources\
?????目錄???????????0??2018-09-22?19:19??Python飛機大戰\PythonShootGame-master\resources\font\
?????文件????????1662??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\font\font.fnt
?????文件????????5193??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\font\font.png
?????目錄???????????0??2018-09-22?19:19??Python飛機大戰\PythonShootGame-master\resources\image\
?????文件???????33518??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\image\background.png
?????文件???????20682??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\image\gameover.png
?????文件????????3388??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\image\shoot.pack
?????文件??????463797??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\image\shoot.png
?????文件?????????793??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\image\shoot_background.pack
?????文件???????92377??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\image\shoot_background.png
?????目錄???????????0??2018-09-22?19:19??Python飛機大戰\PythonShootGame-master\resources\sound\
?????文件????????8831??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\achievement.mp3
?????文件???????12327??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\big_spaceship_flying.mp3
?????文件????????7751??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\bullet.mp3
?????文件????????8108??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\bullet.wav
?????文件????????6815??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\button.mp3
?????文件???????11287??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\enemy1_down.mp3
?????文件???????17900??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\enemy1_down.wav
?????文件???????12847??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\enemy2_down.mp3
?????文件???????14444??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\enemy2_down.wav
?????文件????????9415??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\enemy3_down.mp3
?????文件???????71468??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\enemy3_down.wav
?????文件??????117728??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\game_music.mp3
?????文件?????1087532??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\game_music.wav
?????文件???????14615??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\game_over.mp3
?????文件???????44972??2016-06-29?01:29??Python飛機大戰\PythonShootGame-master\resources\sound\game_over.wav
............此處省略4個文件信息
評論
共有 條評論