91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.05MB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2023-11-30
  • 語言: Python
  • 標(biāo)簽: python??pygame??

資源簡介

基于Python、pygame的微信打飛機(jī)小游戲,由于這個是我自己寫的,象征性地要1個資源分。另外還上傳了網(wǎng)友貢獻(xiàn)的微信打飛機(jī)小游戲源碼,如果不想花積分的話可以去下那個。

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-

import?pygame
from?myGameRole?import?*
#?導(dǎo)入按鍵的檢測
from?pygame.locals?import?*
import?time
import?random


if?__name__?==?‘__main__‘:
#?pygame初始化
pygame.init()

#?載入效果音樂
bullet_sound?=?pygame.mixer.Sound(‘resources/sound/bullet.wav‘)
enemy_down_sound?=?pygame.mixer.Sound(‘resources/sound/enemy1_down.wav‘)
game_over_sound?=?pygame.mixer.Sound(‘resources/sound/game_over.wav‘)
bullet_sound.set_volume(0.3)
enemy_down_sound.set_volume(0.3)
game_over_sound.set_volume(0.3)

#?載入游戲音樂并循環(huán)播放
pygame.mixer.music.load(‘resources/sound/game_music.wav‘)
pygame.mixer.music.play(-1?0)
pygame.mixer.music.set_volume(0.25)

#?創(chuàng)建窗口
screen?=?pygame.display.set_mode((SCREEN_WIDTH?SCREEN_HEIGHT))
#?讀出背景圖片
background?=?pygame.image.load(‘resources/image/background.png‘).convert()

#?創(chuàng)建對象
playerPlane?=?Player(screen)

#?敵機(jī)列表
enemyList?=?[]
#?敵機(jī)產(chǎn)生頻率
enemy_frequency?=?0

running_control?=?True
gameOverFlag?=?False

#?1.顯示背景
while?running_control:
screen.blit(background(0?0))

#?產(chǎn)生敵方飛機(jī)
if?enemy_frequency?%?50?==?0:
num?=?random.randint(0?SCREEN_WIDTH?-?51)
enemy?=?Enemy(screen?num)
enemyList.append(enemy)
enemy_frequency?+=?1
if?enemy_frequency?>=?100:
enemy_frequency?=?0

#?判斷按鍵
for?event?in?pygame.event.get():
if?event.type?==?QUIT:
print(‘exit‘)
exit()
elif?event.type?==?KEYDOWN:
if?event.key?==?K_a?or?event.key?==?K_LEFT:
#?print(‘left‘)
playerPlane.keyHandle(‘left‘)
elif?event.key?==?K_d?or?event.key?==?K_RIGHT:
#?print(‘right‘)
playerPlane.keyHandle(‘right‘)
elif?event.key?==?K_w?or?event.key?==?K_UP:
#?print(‘up‘)
playerPlane.keyHandle(‘up‘)
elif?event.key?==?K_s?or?event.key?==?K_DOWN:
#?print(‘down‘)
playerPlane.keyHandle(‘down‘)
elif?event.key?==?K_SPACE:
#?print(‘space‘)
playerPlane.keyHandle(‘space‘)
bullet_sound.play()
#?print(len(playerPlane.bulletList))

#?這里只是用于檢測敵機(jī)的狀態(tài),如果出界就直接移除,如果被子彈打中就執(zhí)行爆炸效果隨后與子彈一起移除
#?還有一點(diǎn),圖片刷新不能與此同時進(jìn)行,會有一頓一頓的感覺,所以只在執(zhí)行爆炸效果時進(jìn)行刷新,最后統(tǒng)一刷新
for?enemy?in?enemyList:
enemy.move()

if?enemy.checkOut():
enemyList.remove(enemy)
continue

x1y1w1h1?=?enemy.getPos()

for?bullet?in?playerPlane.bulletList:
x2y2w2h2?=?bullet.getPos()

if?(x2?+?w2?//?2)?>=?x1?and?(x2?+?w2?//?2)?<=?(x1?+?w1):
if?y2?<=?(y1?+?h1):
enemy.crash()
playerPlane.bulletList.remove(bullet)
enemyList.remove(enemy)
enemy.draw()
enemy_down_sound.play()
break

x3y3w3h3?=??playerPlane.getPos()
if?(x1?+?w1?//?2)?>=?x3?and?(x1?+?w1?//?2)?<=?(x3?+?w3):
if?y3?<=?(y1?+?h1):
#?playerPlane.crash()
#?#?更新飛機(jī)圖片
#?playerPlane.draw()
#?running_control?=?False
#?break
gameOverFlag?=?True

for?enemy?in?enemyList:
enemy.draw()

#?子彈移動,更新圖片
for?bullet?in?playerPlane.bulletList:
bullet.move()
bullet.draw()

#?清楚發(fā)射到頂部的子彈
playerPlane.bulletClear()

if?gameOverFlag?==?True:
playerPlane.cra

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-06-19?22:28??MyPythonGame\
?????文件????????3879??2017-06-19?07:10??MyPythonGame\myGame.py
?????文件????????3583??2017-06-19?05:59??MyPythonGame\myGameRole.py
?????文件????????6346??2017-06-19?06:05??MyPythonGame\myGameRole.pyc
?????目錄???????????0??2017-06-19?22:28??MyPythonGame\resources\
?????目錄???????????0??2017-06-19?22:28??MyPythonGame\resources\image\
?????文件???????36620??2017-06-18?21:54??MyPythonGame\resources\image\background.png
?????文件????????5570??2017-06-18?21:54??MyPythonGame\resources\image\bomb.png
?????文件????????8944??2017-06-18?21:54??MyPythonGame\resources\image\btn_finish.png
?????文件?????????486??2017-06-18?21:54??MyPythonGame\resources\image\bullet1.png
?????文件?????????485??2017-06-18?21:54??MyPythonGame\resources\image\bullet2.png
?????文件????????2968??2017-06-18?21:54??MyPythonGame\resources\image\enemy1.png
?????文件????????3365??2017-06-18?21:54??MyPythonGame\resources\image\enemy1_down1.png
?????文件????????3815??2017-06-18?21:54??MyPythonGame\resources\image\enemy1_down2.png
?????文件????????5239??2017-06-18?21:54??MyPythonGame\resources\image\enemy1_down3.png
?????文件????????1723??2017-06-18?21:54??MyPythonGame\resources\image\enemy1_down4.png
?????文件????????8112??2017-06-18?21:54??MyPythonGame\resources\image\enemy2.png
?????文件???????10408??2017-06-18?21:54??MyPythonGame\resources\image\enemy2_down1.png
?????文件???????11562??2017-06-18?21:54??MyPythonGame\resources\image\enemy2_down2.png
?????文件???????13310??2017-06-18?21:54??MyPythonGame\resources\image\enemy2_down3.png
?????文件????????3356??2017-06-18?21:54??MyPythonGame\resources\image\enemy2_down4.png
?????文件????????9126??2017-06-18?21:54??MyPythonGame\resources\image\enemy2_hit.png
?????文件???????47800??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_down1.png
?????文件???????53349??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_down2.png
?????文件???????60269??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_down3.png
?????文件???????66517??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_down4.png
?????文件???????75014??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_down5.png
?????文件????????8722??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_down6.png
?????文件???????45497??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_hit.png
?????文件???????42482??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_n1.png
?????文件???????42572??2017-06-18?21:54??MyPythonGame\resources\image\enemy3_n2.png
............此處省略47個文件信息

評論

共有 條評論