Changes
This commit is contained in:
parent
4924ce9496
commit
9cfd26e75f
BIN
Plane_Fighting/__pycache__/bullet.cpython-310.pyc
Executable file → Normal file
BIN
Plane_Fighting/__pycache__/bullet.cpython-310.pyc
Executable file → Normal file
Binary file not shown.
BIN
Plane_Fighting/__pycache__/enemy.cpython-310.pyc
Executable file → Normal file
BIN
Plane_Fighting/__pycache__/enemy.cpython-310.pyc
Executable file → Normal file
Binary file not shown.
BIN
Plane_Fighting/__pycache__/myplane.cpython-310.pyc
Executable file → Normal file
BIN
Plane_Fighting/__pycache__/myplane.cpython-310.pyc
Executable file → Normal file
Binary file not shown.
BIN
Plane_Fighting/__pycache__/supply.cpython-310.pyc
Executable file → Normal file
BIN
Plane_Fighting/__pycache__/supply.cpython-310.pyc
Executable file → Normal file
Binary file not shown.
@ -16,7 +16,7 @@ source.dir = .
|
|||||||
source.include_exts = py,png,ogg,wav,ttf,dat
|
source.include_exts = py,png,ogg,wav,ttf,dat
|
||||||
|
|
||||||
# (list) List of inclusions using pattern matching
|
# (list) List of inclusions using pattern matching
|
||||||
#source.include_patterns = assets/*,images/*.png
|
source.include_patterns = font/*,sound/*,images/*,record.dat
|
||||||
|
|
||||||
# (list) Source files to exclude (let empty to not exclude anything)
|
# (list) Source files to exclude (let empty to not exclude anything)
|
||||||
#source.exclude_exts = spec
|
#source.exclude_exts = spec
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import pygame
|
import pygame,os
|
||||||
|
abspath = os.getcwd() + "/"
|
||||||
class Bullet1(pygame.sprite.Sprite):
|
class Bullet1(pygame.sprite.Sprite):
|
||||||
def __init__(self, position):
|
def __init__(self, position):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.image = pygame.image.load("images/bullet1.png").convert_alpha()
|
self.image = pygame.image.load(abspath + "images/bullet1.png").convert_alpha()
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.rect.left, self.rect.top = position
|
self.rect.left, self.rect.top = position
|
||||||
self.speed = 11
|
self.speed = 11
|
||||||
@ -25,7 +25,7 @@ class Bullet2(pygame.sprite.Sprite):
|
|||||||
def __init__(self, position):
|
def __init__(self, position):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.image = pygame.image.load("images/bullet2.png").convert_alpha()
|
self.image = pygame.image.load(abspath + "images/bullet2.png").convert_alpha()
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.rect.left, self.rect.top = position
|
self.rect.left, self.rect.top = position
|
||||||
self.speed = 14#14
|
self.speed = 14#14
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import pygame
|
import pygame,os
|
||||||
from random import *
|
from random import *
|
||||||
|
abspath = os.getcwd() + "/"
|
||||||
class SmallEnemy(pygame.sprite.Sprite):
|
class SmallEnemy(pygame.sprite.Sprite):
|
||||||
def __init__(self, bg_size):
|
def __init__(self, bg_size):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.image = pygame.image.load("images/enemy1.png").convert_alpha()
|
self.image = pygame.image.load(abspath + "images/enemy1.png").convert_alpha()
|
||||||
self.destroy_images = []
|
self.destroy_images = []
|
||||||
self.destroy_images.extend([\
|
self.destroy_images.extend([\
|
||||||
pygame.image.load("images/enemy1_down1.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy1_down1.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy1_down2.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy1_down2.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy1_down3.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy1_down3.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy1_down4.png").convert_alpha() \
|
pygame.image.load(abspath + "images/enemy1_down4.png").convert_alpha() \
|
||||||
])
|
])
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.width, self.height = bg_size[0], bg_size[1]
|
self.width, self.height = bg_size[0], bg_size[1]
|
||||||
@ -41,14 +41,14 @@ class MidEnemy(pygame.sprite.Sprite):
|
|||||||
def __init__(self, bg_size):
|
def __init__(self, bg_size):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.image = pygame.image.load("images/enemy2.png").convert_alpha()
|
self.image = pygame.image.load(abspath + "images/enemy2.png").convert_alpha()
|
||||||
self.image_hit = pygame.image.load("images/enemy2_hit.png").convert_alpha()
|
self.image_hit = pygame.image.load(abspath + "images/enemy2_hit.png").convert_alpha()
|
||||||
self.destroy_images = []
|
self.destroy_images = []
|
||||||
self.destroy_images.extend([\
|
self.destroy_images.extend([\
|
||||||
pygame.image.load("images/enemy2_down1.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy2_down1.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy2_down2.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy2_down2.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy2_down3.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy2_down3.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy2_down4.png").convert_alpha() \
|
pygame.image.load(abspath + "images/enemy2_down4.png").convert_alpha() \
|
||||||
])
|
])
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.width, self.height = bg_size[0], bg_size[1]
|
self.width, self.height = bg_size[0], bg_size[1]
|
||||||
@ -81,17 +81,17 @@ class BigEnemy(pygame.sprite.Sprite):
|
|||||||
def __init__(self, bg_size):
|
def __init__(self, bg_size):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.image1 = pygame.image.load("images/enemy3_n1.png").convert_alpha()
|
self.image1 = pygame.image.load(abspath + "images/enemy3_n1.png").convert_alpha()
|
||||||
self.image2 = pygame.image.load("images/enemy3_n2.png").convert_alpha()
|
self.image2 = pygame.image.load(abspath + "images/enemy3_n2.png").convert_alpha()
|
||||||
self.image_hit = pygame.image.load("images/enemy3_hit.png").convert_alpha()
|
self.image_hit = pygame.image.load(abspath + "images/enemy3_hit.png").convert_alpha()
|
||||||
self.destroy_images = []
|
self.destroy_images = []
|
||||||
self.destroy_images.extend([\
|
self.destroy_images.extend([\
|
||||||
pygame.image.load("images/enemy3_down1.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy3_down1.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy3_down2.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy3_down2.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy3_down3.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy3_down3.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy3_down4.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy3_down4.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy3_down5.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/enemy3_down5.png").convert_alpha(), \
|
||||||
pygame.image.load("images/enemy3_down6.png").convert_alpha() \
|
pygame.image.load(abspath + "images/enemy3_down6.png").convert_alpha() \
|
||||||
])
|
])
|
||||||
self.rect = self.image1.get_rect()
|
self.rect = self.image1.get_rect()
|
||||||
self.width, self.height = bg_size[0], bg_size[1]
|
self.width, self.height = bg_size[0], bg_size[1]
|
||||||
|
@ -7,7 +7,9 @@ import enemy
|
|||||||
import bullet
|
import bullet
|
||||||
import supply
|
import supply
|
||||||
import time
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
|
abspath = os.getcwd() + "/"
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
from random import *
|
from random import *
|
||||||
jj = 0
|
jj = 0
|
||||||
@ -18,40 +20,41 @@ bg_size = width, height = 480, 700
|
|||||||
screen = pygame.display.set_mode(bg_size)
|
screen = pygame.display.set_mode(bg_size)
|
||||||
pygame.display.set_caption("Plane Fighting")
|
pygame.display.set_caption("Plane Fighting")
|
||||||
key_pressed = pygame.key.get_pressed()
|
key_pressed = pygame.key.get_pressed()
|
||||||
background=pygame.image.load("images/loading.png") #图片位置
|
background=pygame.image.load(abspath + "images/loading.png") #图片位置
|
||||||
screen.blit(background,(0,0)) #对齐的坐标
|
screen.blit(background,(0,0)) #对齐的坐标
|
||||||
pygame.display.update() #显示内容
|
pygame.display.update() #显示内容
|
||||||
time.sleep(1)
|
pygame.mixer.music.load(abspath + "sound/game_music.ogg")
|
||||||
background = pygame.image.load("images/background.png").convert()
|
pygame.mixer.music.set_volume(0.1)
|
||||||
|
pygame.mixer.music.play(-1)
|
||||||
|
time.sleep(7.5)
|
||||||
|
background = pygame.image.load(abspath + "images/background.png").convert()
|
||||||
BLACK = (0, 0, 0)
|
BLACK = (0, 0, 0)
|
||||||
WHITE = (255, 255, 255)
|
WHITE = (255, 255, 255)
|
||||||
GREEN = (0, 255, 0)
|
GREEN = (0, 255, 0)
|
||||||
RED = (255, 0, 0)
|
RED = (255, 0, 0)
|
||||||
|
|
||||||
# 载入游戏音乐
|
# 载入游戏音乐
|
||||||
pygame.mixer.music.load("sound/game_music.ogg")
|
bullet_sound = pygame.mixer.Sound(abspath + "sound/bullet.wav")
|
||||||
pygame.mixer.music.set_volume(0.1)
|
|
||||||
bullet_sound = pygame.mixer.Sound("sound/bullet.wav")
|
|
||||||
bullet_sound.set_volume(0.2)
|
bullet_sound.set_volume(0.2)
|
||||||
bomb_sound = pygame.mixer.Sound("sound/use_bomb.wav")
|
bomb_sound = pygame.mixer.Sound(abspath + "sound/use_bomb.wav")
|
||||||
bomb_sound.set_volume(0.2)
|
bomb_sound.set_volume(0.2)
|
||||||
supply_sound = pygame.mixer.Sound("sound/supply.wav")
|
supply_sound = pygame.mixer.Sound(abspath + "sound/supply.wav")
|
||||||
supply_sound.set_volume(0.2)
|
supply_sound.set_volume(0.2)
|
||||||
get_bomb_sound = pygame.mixer.Sound("sound/get_bomb.wav")
|
get_bomb_sound = pygame.mixer.Sound(abspath + "sound/get_bomb.wav")
|
||||||
get_bomb_sound.set_volume(0.2)
|
get_bomb_sound.set_volume(0.2)
|
||||||
get_bullet_sound = pygame.mixer.Sound("sound/get_bullet.wav")
|
get_bullet_sound = pygame.mixer.Sound(abspath + "sound/get_bullet.wav")
|
||||||
get_bullet_sound.set_volume(0.2)
|
get_bullet_sound.set_volume(0.2)
|
||||||
upgrade_sound = pygame.mixer.Sound("sound/upgrade.wav")
|
upgrade_sound = pygame.mixer.Sound(abspath + "sound/upgrade.wav")
|
||||||
upgrade_sound.set_volume(0.2)
|
upgrade_sound.set_volume(0.2)
|
||||||
enemy3_fly_sound = pygame.mixer.Sound("sound/enemy3_flying.wav")
|
enemy3_fly_sound = pygame.mixer.Sound(abspath + "sound/enemy3_flying.wav")
|
||||||
enemy3_fly_sound.set_volume(0.2)
|
enemy3_fly_sound.set_volume(0.2)
|
||||||
enemy1_down_sound = pygame.mixer.Sound("sound/enemy1_down.wav")
|
enemy1_down_sound = pygame.mixer.Sound(abspath + "sound/enemy1_down.wav")
|
||||||
enemy1_down_sound.set_volume(0.2)
|
enemy1_down_sound.set_volume(0.2)
|
||||||
enemy2_down_sound = pygame.mixer.Sound("sound/enemy2_down.wav")
|
enemy2_down_sound = pygame.mixer.Sound(abspath + "sound/enemy2_down.wav")
|
||||||
enemy2_down_sound.set_volume(0.2)
|
enemy2_down_sound.set_volume(0.2)
|
||||||
enemy3_down_sound = pygame.mixer.Sound("sound/enemy3_down.wav")
|
enemy3_down_sound = pygame.mixer.Sound(abspath + "sound/enemy3_down.wav")
|
||||||
enemy3_down_sound.set_volume(0.5)
|
enemy3_down_sound.set_volume(0.5)
|
||||||
me_down_sound = pygame.mixer.Sound("sound/me_down.wav")
|
me_down_sound = pygame.mixer.Sound(abspath + "sound/me_down.wav")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +85,6 @@ def main():
|
|||||||
me = myplane.MyPlane(bg_size)
|
me = myplane.MyPlane(bg_size)
|
||||||
|
|
||||||
enemies = pygame.sprite.Group()
|
enemies = pygame.sprite.Group()
|
||||||
pygame.mixer.music.play(-1)
|
|
||||||
|
|
||||||
|
|
||||||
# Enemy Level 1
|
# Enemy Level 1
|
||||||
@ -122,14 +124,14 @@ def main():
|
|||||||
|
|
||||||
# 统计得分
|
# 统计得分
|
||||||
score = 0
|
score = 0
|
||||||
score_font = pygame.font.Font("font/font.ttf", 36)
|
score_font = pygame.font.Font(abspath + "font/font.ttf", 36)
|
||||||
|
|
||||||
# 标志是否暂停游戏
|
# 标志是否暂停游戏
|
||||||
paused = False
|
paused = False
|
||||||
pause_nor_image = pygame.image.load("images/pause_nor.png").convert_alpha()
|
pause_nor_image = pygame.image.load(abspath + "images/pause_nor.png").convert_alpha()
|
||||||
pause_pressed_image = pygame.image.load("images/pause_pressed.png").convert_alpha()
|
pause_pressed_image = pygame.image.load(abspath + "images/pause_pressed.png").convert_alpha()
|
||||||
resume_nor_image = pygame.image.load("images/resume_nor.png").convert_alpha()
|
resume_nor_image = pygame.image.load(abspath + "images/resume_nor.png").convert_alpha()
|
||||||
resume_pressed_image = pygame.image.load("images/resume_pressed.png").convert_alpha()
|
resume_pressed_image = pygame.image.load(abspath + "images/resume_pressed.png").convert_alpha()
|
||||||
paused_rect = pause_nor_image.get_rect()
|
paused_rect = pause_nor_image.get_rect()
|
||||||
paused_rect.left, paused_rect.top = width - paused_rect.width - 10, 10
|
paused_rect.left, paused_rect.top = width - paused_rect.width - 10, 10
|
||||||
paused_image = pause_nor_image
|
paused_image = pause_nor_image
|
||||||
@ -138,9 +140,9 @@ def main():
|
|||||||
level = 1
|
level = 1
|
||||||
|
|
||||||
# 全屏炸弹
|
# 全屏炸弹
|
||||||
bomb_image = pygame.image.load("images/bomb.png").convert_alpha()
|
bomb_image = pygame.image.load(abspath + "images/bomb.png").convert_alpha()
|
||||||
bomb_rect = bomb_image.get_rect()
|
bomb_rect = bomb_image.get_rect()
|
||||||
bomb_font = pygame.font.Font("font/font.ttf", 48)
|
bomb_font = pygame.font.Font(abspath + "font/font.ttf", 48)
|
||||||
bomb_num = 3
|
bomb_num = 3
|
||||||
|
|
||||||
# 每30秒发放一个补给包
|
# 每30秒发放一个补给包
|
||||||
@ -161,17 +163,17 @@ def main():
|
|||||||
|
|
||||||
# 生命数量
|
# 生命数量
|
||||||
life_num = 3
|
life_num = 3
|
||||||
life_image = pygame.image.load("images/life.png").convert_alpha()
|
life_image = pygame.image.load(abspath + "images/life.png").convert_alpha()
|
||||||
life_rect = life_image.get_rect()
|
life_rect = life_image.get_rect()
|
||||||
|
|
||||||
# 用于阻止重复打开记录文件
|
# 用于阻止重复打开记录文件
|
||||||
recorded = False
|
recorded = False
|
||||||
|
|
||||||
# 游戏结束画面
|
# 游戏结束画面
|
||||||
gameover_font = pygame.font.Font("font/font.ttf", 48)
|
gameover_font = pygame.font.Font(abspath + "font/font.ttf", 48)
|
||||||
again_image = pygame.image.load("images/again.png").convert_alpha()
|
again_image = pygame.image.load(abspath + "images/again.png").convert_alpha()
|
||||||
again_rect = again_image.get_rect()
|
again_rect = again_image.get_rect()
|
||||||
gameover_image = pygame.image.load("images/gameover.png").convert_alpha()
|
gameover_image = pygame.image.load(abspath + "images/gameover.png").convert_alpha()
|
||||||
gameover_rect = gameover_image.get_rect()
|
gameover_rect = gameover_image.get_rect()
|
||||||
|
|
||||||
# 用于切换图片
|
# 用于切换图片
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import pygame
|
import pygame,os
|
||||||
|
abspath = os.getcwd() + "/"
|
||||||
class MyPlane(pygame.sprite.Sprite):
|
class MyPlane(pygame.sprite.Sprite):
|
||||||
def __init__(self, bg_size):
|
def __init__(self, bg_size):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.image1 = pygame.image.load("images/me1.png").convert_alpha()
|
self.image1 = pygame.image.load(abspath + "images/me1.png").convert_alpha()
|
||||||
self.image2 = pygame.image.load("images/me2.png").convert_alpha()
|
self.image2 = pygame.image.load(abspath + "images/me2.png").convert_alpha()
|
||||||
self.destroy_images = []
|
self.destroy_images = []
|
||||||
self.destroy_images.extend([\
|
self.destroy_images.extend([\
|
||||||
pygame.image.load("images/me_destroy_1.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/me_destroy_1.png").convert_alpha(), \
|
||||||
pygame.image.load("images/me_destroy_2.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/me_destroy_2.png").convert_alpha(), \
|
||||||
pygame.image.load("images/me_destroy_3.png").convert_alpha(), \
|
pygame.image.load(abspath + "images/me_destroy_3.png").convert_alpha(), \
|
||||||
pygame.image.load("images/me_destroy_4.png").convert_alpha() \
|
pygame.image.load(abspath + "images/me_destroy_4.png").convert_alpha() \
|
||||||
])
|
])
|
||||||
self.rect = self.image1.get_rect()
|
self.rect = self.image1.get_rect()
|
||||||
self.width, self.height = bg_size[0], bg_size[1]
|
self.width, self.height = bg_size[0], bg_size[1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user