Add files via upload
This commit is contained in:
parent
2b3c138a5b
commit
2906abea34
@ -29,7 +29,7 @@ source.include_patterns = font/*,sound/*,images/*,record.dat
|
|||||||
#source.exclude_patterns = license,images/*/*.jpg
|
#source.exclude_patterns = license,images/*/*.jpg
|
||||||
|
|
||||||
# (str) Application versioning (method 1)
|
# (str) Application versioning (method 1)
|
||||||
version = 0.1
|
version = 0.4.0
|
||||||
|
|
||||||
# (str) Application versioning (method 2)
|
# (str) Application versioning (method 2)
|
||||||
# version.regex = __version__ = ['"](.*)['"]
|
# version.regex = __version__ = ['"](.*)['"]
|
||||||
@ -44,7 +44,7 @@ requirements = python3,pygame
|
|||||||
# requirements.source.kivy = ../../kivy
|
# requirements.source.kivy = ../../kivy
|
||||||
|
|
||||||
# (str) Presplash of the application
|
# (str) Presplash of the application
|
||||||
#presplash.filename = %(source.dir)s/data/presplash.png
|
presplash.filename = %(source.dir)s/images/loading.png
|
||||||
|
|
||||||
# (str) Icon of the application
|
# (str) Icon of the application
|
||||||
icon.filename = %(source.dir)s/images/icon.png
|
icon.filename = %(source.dir)s/images/icon.png
|
||||||
@ -73,7 +73,7 @@ osx.kivy_version = 1.9.1
|
|||||||
#
|
#
|
||||||
|
|
||||||
# (bool) Indicate if the application should be fullscreen or not
|
# (bool) Indicate if the application should be fullscreen or not
|
||||||
fullscreen = 0
|
fullscreen = 1
|
||||||
|
|
||||||
# (string) Presplash background color (for android toolchain)
|
# (string) Presplash background color (for android toolchain)
|
||||||
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
|
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
|
||||||
@ -134,7 +134,7 @@ fullscreen = 0
|
|||||||
# agreements. This is intended for automation only. If set to False,
|
# agreements. This is intended for automation only. If set to False,
|
||||||
# the default, you will be shown the license when first running
|
# the default, you will be shown the license when first running
|
||||||
# buildozer.
|
# buildozer.
|
||||||
# android.accept_sdk_license = False
|
android.accept_sdk_license = True
|
||||||
|
|
||||||
# (str) Android entry point, default is ok for Kivy-based app
|
# (str) Android entry point, default is ok for Kivy-based app
|
||||||
#android.entrypoint = org.kivy.android.PythonActivity
|
#android.entrypoint = org.kivy.android.PythonActivity
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 68 KiB |
Binary file not shown.
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 129 B |
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 20 KiB |
@ -17,23 +17,29 @@ from random import *
|
|||||||
pygame.init()
|
pygame.init()
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
|
|
||||||
bg_size = width, height = 480, 680
|
global width, height
|
||||||
if platform.system().lower() == "Windows":
|
if platform.system().lower() == "windows":
|
||||||
|
bg_size = width, height = 600, 900
|
||||||
screen = pygame.display.set_mode(bg_size)
|
screen = pygame.display.set_mode(bg_size)
|
||||||
elif platform.system().lower() == "Linux":
|
elif platform.system().lower() == "linux":
|
||||||
if os.path.exists("/storage/emulated"): # Android
|
if os.path.exists("/storage/emulated"): # Android
|
||||||
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
||||||
|
width, height = pygame.display.get_surface().get_size()
|
||||||
else:
|
else:
|
||||||
screen = pygame.display.set_mode(bg_size) # Linux
|
bg_size = width, height = 600, 900
|
||||||
elif platform.system().lower() == "Darwin":
|
screen = pygame.display.set_mode(bg_size)
|
||||||
|
elif platform.system().lower() == "darwin":
|
||||||
# TODO: 判断 iOS 与 macOS
|
# TODO: 判断 iOS 与 macOS
|
||||||
|
bg_size = width, height = 800, 900
|
||||||
screen = pygame.display.set_mode(bg_size)
|
screen = pygame.display.set_mode(bg_size)
|
||||||
else:
|
else:
|
||||||
|
bg_size = width, height = 800, 900
|
||||||
screen = pygame.display.set_mode(bg_size)
|
screen = pygame.display.set_mode(bg_size)
|
||||||
|
bg_size = (width, height)
|
||||||
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(abspath + "images/loading.png") # 图片位置
|
background = pygame.image.load(abspath + "images/loading.png") # 图片位置
|
||||||
screen.blit(background, (0, 0)) # 对齐的坐标
|
screen.blit(background, (width // 2 - 240,height // 2 - 350)) # 对齐的坐标
|
||||||
pygame.display.update() # 显示内容
|
pygame.display.update() # 显示内容
|
||||||
pygame.mixer.music.load(abspath + "sound/game_music.ogg")
|
pygame.mixer.music.load(abspath + "sound/game_music.ogg")
|
||||||
pygame.mixer.music.set_volume(0.1)
|
pygame.mixer.music.set_volume(0.1)
|
||||||
@ -66,7 +72,7 @@ enemy2_down_sound.set_volume(0.2)
|
|||||||
enemy3_down_sound = pygame.mixer.Sound(abspath + "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(abspath + "sound/me_down.wav")
|
me_down_sound = pygame.mixer.Sound(abspath + "sound/me_down.wav")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
def add_small_enemies(group1, group2, num):
|
def add_small_enemies(group1, group2, num):
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
@ -151,11 +157,11 @@ def main():
|
|||||||
touch_down_rect = touch_down_image.get_rect()
|
touch_down_rect = touch_down_image.get_rect()
|
||||||
touch_bomb_rect = touch_bomb_image.get_rect()
|
touch_bomb_rect = touch_bomb_image.get_rect()
|
||||||
touch_up_rect = touch_up_image.get_rect()
|
touch_up_rect = touch_up_image.get_rect()
|
||||||
touch_up_rect.left, touch_up_rect.top = width - width // 4 + touch_up_rect.width, height - height // 4 + touch_up_rect.height - 17
|
touch_up_rect.left, touch_up_rect.top = width - width // 4 + touch_up_rect.width, height - height // 4 + touch_up_rect.height - 64
|
||||||
touch_left_rect.left, touch_left_rect.top = width - width // 4 + touch_up_rect.width - 17, height - height // 4 + touch_up_rect.height
|
touch_left_rect.left, touch_left_rect.top = width - width // 4 + touch_up_rect.width - 64, height - height // 4 + touch_up_rect.height
|
||||||
touch_right_rect.left, touch_right_rect.top = width - width // 4 + touch_up_rect.width + 17, height - height // 4 + touch_up_rect.height
|
touch_right_rect.left, touch_right_rect.top = width - width // 4 + touch_up_rect.width + 64, height - height // 4 + touch_up_rect.height
|
||||||
touch_down_rect.left, touch_down_rect.top = width - width // 4 + touch_up_rect.width, height - height // 4 + touch_up_rect.height + 17
|
touch_down_rect.left, touch_down_rect.top = width - width // 4 + touch_up_rect.width, height - height // 4 + touch_up_rect.height + 64
|
||||||
touch_bomb_rect.left, touch_bomb_rect.top = width // 4 - touch_up_rect.width - 17, height - height // 4 + touch_up_rect.height
|
touch_bomb_rect.left, touch_bomb_rect.top = width // 4 - touch_up_rect.width - 64, height - height // 4 + touch_up_rect.height
|
||||||
|
|
||||||
# 标志是否暂停游戏
|
# 标志是否暂停游戏
|
||||||
paused = False
|
paused = False
|
||||||
@ -164,7 +170,7 @@ def main():
|
|||||||
resume_nor_image = pygame.image.load(abspath + "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(abspath + "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 - 20, 20
|
||||||
paused_image = pause_nor_image
|
paused_image = pause_nor_image
|
||||||
|
|
||||||
# 设置难度级别
|
# 设置难度级别
|
||||||
@ -176,7 +182,7 @@ def main():
|
|||||||
# 全屏炸弹
|
# 全屏炸弹
|
||||||
bomb_image = pygame.image.load(abspath + "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(abspath + "font/font.ttf", 48)
|
bomb_font = pygame.font.Font(abspath + "font/font.ttf", 64)
|
||||||
bomb_num = 3
|
bomb_num = 3
|
||||||
|
|
||||||
# 每30秒发放一个补给包
|
# 每30秒发放一个补给包
|
||||||
@ -208,7 +214,6 @@ def main():
|
|||||||
again_rect = again_image.get_rect()
|
again_rect = again_image.get_rect()
|
||||||
gameover_image = pygame.image.load(abspath + "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()
|
||||||
|
|
||||||
# 用于切换图片
|
# 用于切换图片
|
||||||
switch_image = True
|
switch_image = True
|
||||||
|
|
||||||
@ -603,15 +608,15 @@ def main():
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
if pygame.mouse.get_pressed()[0]:
|
if pygame.mouse.get_pressed()[0]:
|
||||||
pos = pygame.mouse.get_pos()
|
pos = pygame.mouse.get_pos()
|
||||||
if touch_up_rect.left < pos[0] < touch_up_rect.right and touch_up_rect.top < pos[1] < touch_up_rect.bottom:
|
if touch_up_rect.left - 128 < pos[0] < touch_up_rect.right + 128 and touch_up_rect.top - 128 < pos[1] < touch_up_rect.bottom + 70:
|
||||||
me.moveUp()
|
me.moveUp()
|
||||||
if touch_left_rect.left < pos[0] < touch_left_rect.right and touch_left_rect.top < pos[1] < touch_left_rect.bottom:
|
if touch_left_rect.left - 128 < pos[0] < touch_left_rect.right + 70 and touch_left_rect.top - 128 < pos[1] < touch_left_rect.bottom + 128:
|
||||||
me.moveLeft()
|
me.moveLeft()
|
||||||
if touch_right_rect.left < pos[0] < touch_right_rect.right and touch_right_rect.top < pos[1] < touch_right_rect.bottom:
|
if touch_right_rect.left - 70 < pos[0] < touch_right_rect.right + 128 and touch_right_rect.top - 128 < pos[1] < touch_right_rect.bottom + 128:
|
||||||
me.moveRight()
|
me.moveRight()
|
||||||
if touch_down_rect.left < pos[0] < touch_down_rect.right and touch_down_rect.top < pos[1] < touch_down_rect.bottom:
|
if touch_down_rect.left - 128 < pos[0] < touch_down_rect.right + 128 and touch_down_rect.top - 70 < pos[1] < touch_down_rect.bottom + 128:
|
||||||
me.moveDown()
|
me.moveDown()
|
||||||
if touch_bomb_rect.left < pos[0] < touch_bomb_rect.right and touch_bomb_rect.top < pos[1] < touch_bomb_rect.bottom:
|
if touch_bomb_rect.left - 128 < pos[0] < touch_bomb_rect.right + 128 and touch_bomb_rect.top - 128 < pos[1] < touch_bomb_rect.bottom + 128:
|
||||||
if bomb_num and last_bomb - time.time() <= -1:
|
if bomb_num and last_bomb - time.time() <= -1:
|
||||||
bomb_num -= 1
|
bomb_num -= 1
|
||||||
bomb_sound.play()
|
bomb_sound.play()
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user