diff --git a/plane_fighting/buildozer.spec b/plane_fighting/buildozer.spec index 76108ec..24929e4 100644 --- a/plane_fighting/buildozer.spec +++ b/plane_fighting/buildozer.spec @@ -29,7 +29,7 @@ source.include_patterns = font/*,sound/*,images/*,record.dat #source.exclude_patterns = license,images/*/*.jpg # (str) Application versioning (method 1) -version = 0.1 +version = 0.4.0 # (str) Application versioning (method 2) # version.regex = __version__ = ['"](.*)['"] @@ -44,7 +44,7 @@ requirements = python3,pygame # requirements.source.kivy = ../../kivy # (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 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 -fullscreen = 0 +fullscreen = 1 # (string) Presplash background color (for android toolchain) # 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, # the default, you will be shown the license when first running # buildozer. -# android.accept_sdk_license = False +android.accept_sdk_license = True # (str) Android entry point, default is ok for Kivy-based app #android.entrypoint = org.kivy.android.PythonActivity diff --git a/plane_fighting/images/background.png b/plane_fighting/images/background.png index 2197c0f..3983e99 100644 Binary files a/plane_fighting/images/background.png and b/plane_fighting/images/background.png differ diff --git a/plane_fighting/images/bullet1.png b/plane_fighting/images/bullet1.png index 9b575e3..64746f8 100644 Binary files a/plane_fighting/images/bullet1.png and b/plane_fighting/images/bullet1.png differ diff --git a/plane_fighting/images/loading.png b/plane_fighting/images/loading.png index 9b6d9c5..49aada5 100644 Binary files a/plane_fighting/images/loading.png and b/plane_fighting/images/loading.png differ diff --git a/plane_fighting/main.py b/plane_fighting/main.py index a76d98f..e268b5f 100644 --- a/plane_fighting/main.py +++ b/plane_fighting/main.py @@ -17,23 +17,29 @@ from random import * pygame.init() pygame.mixer.init() -bg_size = width, height = 480, 680 -if platform.system().lower() == "Windows": +global width, height +if platform.system().lower() == "windows": + bg_size = width, height = 600, 900 screen = pygame.display.set_mode(bg_size) -elif platform.system().lower() == "Linux": +elif platform.system().lower() == "linux": if os.path.exists("/storage/emulated"): # Android screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) + width, height = pygame.display.get_surface().get_size() else: - screen = pygame.display.set_mode(bg_size) # Linux -elif platform.system().lower() == "Darwin": + bg_size = width, height = 600, 900 + screen = pygame.display.set_mode(bg_size) +elif platform.system().lower() == "darwin": # TODO: 判断 iOS 与 macOS + bg_size = width, height = 800, 900 screen = pygame.display.set_mode(bg_size) else: + bg_size = width, height = 800, 900 screen = pygame.display.set_mode(bg_size) +bg_size = (width, height) pygame.display.set_caption("Plane Fighting") key_pressed = pygame.key.get_pressed() 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.mixer.music.load(abspath + "sound/game_music.ogg") 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.set_volume(0.5) me_down_sound = pygame.mixer.Sound(abspath + "sound/me_down.wav") - +time.sleep(1) def add_small_enemies(group1, group2, num): for i in range(num): @@ -151,11 +157,11 @@ def main(): touch_down_rect = touch_down_image.get_rect() touch_bomb_rect = touch_bomb_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_left_rect.left, touch_left_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 + 17, 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_bomb_rect.left, touch_bomb_rect.top = width // 4 - touch_up_rect.width - 17, height - height // 4 + touch_up_rect.height + 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 - 64, 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 + 64 + touch_bomb_rect.left, touch_bomb_rect.top = width // 4 - touch_up_rect.width - 64, height - height // 4 + touch_up_rect.height # 标志是否暂停游戏 paused = False @@ -164,7 +170,7 @@ def main(): 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() 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 # 设置难度级别 @@ -176,7 +182,7 @@ def main(): # 全屏炸弹 bomb_image = pygame.image.load(abspath + "images/bomb.png").convert_alpha() 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 # 每30秒发放一个补给包 @@ -208,7 +214,6 @@ def main(): again_rect = again_image.get_rect() gameover_image = pygame.image.load(abspath + "images/gameover.png").convert_alpha() gameover_rect = gameover_image.get_rect() - # 用于切换图片 switch_image = True @@ -603,15 +608,15 @@ def main(): sys.exit() if pygame.mouse.get_pressed()[0]: 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() - 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() - 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() - 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() - 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: bomb_num -= 1 bomb_sound.play() diff --git a/plane_fighting/sound/game_music.ogg b/plane_fighting/sound/game_music.ogg index 97b59d2..b126f99 100644 Binary files a/plane_fighting/sound/game_music.ogg and b/plane_fighting/sound/game_music.ogg differ diff --git a/plane_fighting/sound/loading_game.ogg b/plane_fighting/sound/loading_game.ogg index 97b59d2..b126f99 100644 Binary files a/plane_fighting/sound/loading_game.ogg and b/plane_fighting/sound/loading_game.ogg differ