From 2b3c138a5b701c8010228f10a380f908c0f043c4 Mon Sep 17 00:00:00 2001 From: Wang Zhiyu Date: Fri, 27 May 2022 18:53:13 +0800 Subject: [PATCH] Add files via upload --- plane_fighting/README.md | 25 +- plane_fighting/buildozer.spec | 854 +++++++++++++-------------- plane_fighting/images/touch/bomb.png | Bin 0 -> 2450 bytes plane_fighting/images/touch/d.png | Bin 0 -> 1755 bytes plane_fighting/images/touch/l.png | Bin 0 -> 1850 bytes plane_fighting/images/touch/r.png | Bin 0 -> 1868 bytes plane_fighting/images/touch/u.png | Bin 0 -> 1729 bytes plane_fighting/main.py | 190 +++--- plane_fighting/record.dat | 2 +- 9 files changed, 558 insertions(+), 513 deletions(-) create mode 100644 plane_fighting/images/touch/bomb.png create mode 100644 plane_fighting/images/touch/d.png create mode 100644 plane_fighting/images/touch/l.png create mode 100644 plane_fighting/images/touch/r.png create mode 100644 plane_fighting/images/touch/u.png diff --git a/plane_fighting/README.md b/plane_fighting/README.md index d5ef9cc..454aee4 100644 --- a/plane_fighting/README.md +++ b/plane_fighting/README.md @@ -1,12 +1,13 @@ -# Plane Fighting (plane_fighting) -## 简介 -一个跨平台的简易"飞机大战"小游戏 -## 支持 -基于Python & PyGame 运行 -可通过 Buildozer 打包为移动应用 -## 协议 -图标库(./images/)来自 IconFont -音效库(./sound/)来自网络 -字体库(./font)来自 Ubuntu -相应的版权归作者所有 -本目录中其他所有的源代码文件根据 GPL 3.0 协议开源 +# Plane Fighting (plane_fighting) + +## 简介 +一个跨平台的简易"飞机大战"小游戏 +## 支持 +基于 Python & PyGame 运行 +可通过 Buildozer 打包为移动应用 +## 协议 +图标库(./images/)来自 IconFont +音效库(./sound/)来自网络 +字体库(./font)来自 Ubuntu +相应的版权归作者所有 +本目录中其他所有的源代码文件根据 MIT 协议开源 diff --git a/plane_fighting/buildozer.spec b/plane_fighting/buildozer.spec index 665c3ea..76108ec 100644 --- a/plane_fighting/buildozer.spec +++ b/plane_fighting/buildozer.spec @@ -1,427 +1,427 @@ -[app] - -# (str) Title of your application -title = Plane Fighting - -# (str) Package name -package.name = plane_fighting - -# (str) Package domain (needed for android/ios packaging) -package.domain = ga.imwangzhiyu - -# (str) Source code where the main.py live -source.dir = . - -# (list) Source files to include (let empty to include all the files) -source.include_exts = py,png,ogg,wav,ttf,dat - -# (list) List of inclusions using pattern matching -source.include_patterns = font/*,sound/*,images/*,record.dat - -# (list) Source files to exclude (let empty to not exclude anything) -#source.exclude_exts = spec - -# (list) List of directory to exclude (let empty to not exclude anything) -#source.exclude_dirs = tests, bin, venv - -# (list) List of exclusions using pattern matching -# Do not prefix with './' -#source.exclude_patterns = license,images/*/*.jpg - -# (str) Application versioning (method 1) -version = 0.1 - -# (str) Application versioning (method 2) -# version.regex = __version__ = ['"](.*)['"] -# version.filename = %(source.dir)s/main.py - -# (list) Application requirements -# comma separated e.g. requirements = sqlite3,kivy -requirements = python3,pygame - -# (str) Custom source folders for requirements -# Sets custom source for any requirements with recipes -# requirements.source.kivy = ../../kivy - -# (str) Presplash of the application -#presplash.filename = %(source.dir)s/data/presplash.png - -# (str) Icon of the application -icon.filename = %(source.dir)s/images/icon.png - -# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) -orientation = portrait - -# (list) List of service to declare -#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY - -# -# OSX Specific -# - -# -# author = © Copyright Info - -# change the major version of python used by the app -osx.python_version = 3 - -# Kivy version to use -osx.kivy_version = 1.9.1 - -# -# Android specific -# - -# (bool) Indicate if the application should be fullscreen or not -fullscreen = 0 - -# (string) Presplash background color (for android toolchain) -# Supported formats are: #RRGGBB #AARRGGBB or one of the following names: -# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray, -# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy, -# olive, purple, silver, teal. -#android.presplash_color = #FFFFFF - -# (string) Presplash animation using Lottie format. -# see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/ -# for general documentation. -# Lottie files can be created using various tools, like Adobe After Effect or Synfig. -#android.presplash_lottie = "path/to/lottie/file.json" - -# (str) Adaptive icon of the application (used if Android API level is 26+ at runtime) -#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png -#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png - -# (list) Permissions -#android.permissions = INTERNET - -# (list) features (adds uses-feature -tags to manifest) -#android.features = android.hardware.usb.host - -# (int) Target Android API, should be as high as possible. -#android.api = 27 - -# (int) Minimum API your APK / AAB will support. -#android.minapi = 21 - -# (int) Android SDK version to use -#android.sdk = 20 - -# (str) Android NDK version to use -#android.ndk = 19b - -# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi. -#android.ndk_api = 21 - -# (bool) Use --private data storage (True) or --dir public storage (False) -#android.private_storage = True - -# (str) Android NDK directory (if empty, it will be automatically downloaded.) -#android.ndk_path = - -# (str) Android SDK directory (if empty, it will be automatically downloaded.) -#android.sdk_path = - -# (str) ANT directory (if empty, it will be automatically downloaded.) -#android.ant_path = - -# (bool) If True, then skip trying to update the Android sdk -# This can be useful to avoid excess Internet downloads or save time -# when an update is due and you just want to test/build your package -# android.skip_update = False - -# (bool) If True, then automatically accept SDK license -# 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 - -# (str) Android entry point, default is ok for Kivy-based app -#android.entrypoint = org.kivy.android.PythonActivity - -# (str) Full name including package path of the Java class that implements Android Activity -# use that parameter together with android.entrypoint to set custom Java class instead of PythonActivity -#android.activity_class_name = org.kivy.android.PythonActivity - -# (str) Extra xml to write directly inside the element of AndroidManifest.xml -# use that parameter to provide a filename from where to load your custom XML code -#android.extra_manifest_xml = ./src/android/extra_manifest.xml - -# (str) Extra xml to write directly inside the tag of AndroidManifest.xml -# use that parameter to provide a filename from where to load your custom XML arguments: -#android.extra_manifest_application_arguments = ./src/android/extra_manifest_application_arguments.xml - -# (str) Full name including package path of the Java class that implements Python Service -# use that parameter to set custom Java class instead of PythonService -#android.service_class_name = org.kivy.android.PythonService - -# (str) Android app theme, default is ok for Kivy-based app -# android.apptheme = "@android:style/Theme.NoTitleBar" - -# (list) Pattern to whitelist for the whole project -#android.whitelist = - -# (str) Path to a custom whitelist file -#android.whitelist_src = - -# (str) Path to a custom blacklist file -#android.blacklist_src = - -# (list) List of Java .jar files to add to the libs so that pyjnius can access -# their classes. Don't add jars that you do not need, since extra jars can slow -# down the build process. Allows wildcards matching, for example: -# OUYA-ODK/libs/*.jar -#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar - -# (list) List of Java files to add to the android project (can be java or a -# directory containing the files) -#android.add_src = - -# (list) Android AAR archives to add -#android.add_aars = - -# (list) Put these files or directories in the apk assets directory. -# Either form may be used, and assets need not be in 'source.include_exts'. -# 1) android.add_assets = source_asset_relative_path -# 2) android.add_assets = source_asset_path:destination_asset_relative_path -#android.add_assets = - -# (list) Gradle dependencies to add -#android.gradle_dependencies = - -# (bool) Enable AndroidX support. Enable when 'android.gradle_dependencies' -# contains an 'androidx' package, or any package from Kotlin source. -# android.enable_androidx requires android.api >= 28 -#android.enable_androidx = False - -# (list) add java compile options -# this can for example be necessary when importing certain java libraries using the 'android.gradle_dependencies' option -# see https://developer.android.com/studio/write/java8-support for further information -# android.add_compile_options = "sourceCompatibility = 1.8", "targetCompatibility = 1.8" - -# (list) Gradle repositories to add {can be necessary for some android.gradle_dependencies} -# please enclose in double quotes -# e.g. android.gradle_repositories = "maven { url 'https://kotlin.bintray.com/ktor' }" -#android.add_gradle_repositories = - -# (list) packaging options to add -# see https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html -# can be necessary to solve conflicts in gradle_dependencies -# please enclose in double quotes -# e.g. android.add_packaging_options = "exclude 'META-INF/common.kotlin_module'", "exclude 'META-INF/*.kotlin_module'" -#android.add_packaging_options = - -# (list) Java classes to add as activities to the manifest. -#android.add_activities = com.example.ExampleActivity - -# (str) OUYA Console category. Should be one of GAME or APP -# If you leave this blank, OUYA support will not be enabled -#android.ouya.category = GAME - -# (str) Filename of OUYA Console icon. It must be a 732x412 png image. -#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png - -# (str) XML file to include as an intent filters in tag -#android.manifest.intent_filters = - -# (str) launchMode to set for the main activity -#android.manifest.launch_mode = standard - -# (list) Android additional libraries to copy into libs/armeabi -#android.add_libs_armeabi = libs/android/*.so -#android.add_libs_armeabi_v7a = libs/android-v7/*.so -#android.add_libs_arm64_v8a = libs/android-v8/*.so -#android.add_libs_x86 = libs/android-x86/*.so -#android.add_libs_mips = libs/android-mips/*.so - -# (bool) Indicate whether the screen should stay on -# Don't forget to add the WAKE_LOCK permission if you set this to True -#android.wakelock = False - -# (list) Android application meta-data to set (key=value format) -#android.meta_data = - -# (list) Android library project to add (will be added in the -# project.properties automatically.) -#android.library_references = - -# (list) Android shared libraries which will be added to AndroidManifest.xml using tag -#android.uses_library = - -# (str) Android logcat filters to use -#android.logcat_filters = *:S python:D - -# (bool) Android logcat only display log for activity's pid -#android.logcat_pid_only = False - -# (str) Android additional adb arguments -#android.adb_args = -H host.docker.internal - -# (bool) Copy library instead of making a libpymodules.so -#android.copy_libs = 1 - -# (list) The Android archs to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64 -# In past, was `android.arch` as we weren't supporting builds for multiple archs at the same time. -android.archs = arm64-v8a, armeabi-v7a - -# (int) overrides automatic versionCode computation (used in build.gradle) -# this is not the same as app version and should only be edited if you know what you're doing -# android.numeric_version = 1 - -# (bool) enables Android auto backup feature (Android API >=23) -android.allow_backup = True - -# (str) XML file for custom backup rules (see official auto backup documentation) -# android.backup_rules = - -# (str) If you need to insert variables into your AndroidManifest.xml file, -# you can do so with the manifestPlaceholders property. -# This property takes a map of key-value pairs. (via a string) -# Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"] -# android.manifest_placeholders = [:] - -# (bool) disables the compilation of py to pyc/pyo files when packaging -# android.no-compile-pyo = True - -# (str) The format used to package the app for release mode (aab or apk). -# android.release_artifact = aab - -# -# Python for android (p4a) specific -# - -# (str) python-for-android URL to use for checkout -#p4a.url = - -# (str) python-for-android fork to use in case if p4a.url is not specified, defaults to upstream (kivy) -#p4a.fork = kivy - -# (str) python-for-android branch to use, defaults to master -#p4a.branch = master - -# (str) python-for-android specific commit to use, defaults to HEAD, must be within p4a.branch -#p4a.commit = HEAD - -# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) -#p4a.source_dir = - -# (str) The directory in which python-for-android should look for your own build recipes (if any) -#p4a.local_recipes = - -# (str) Filename to the hook for p4a -#p4a.hook = - -# (str) Bootstrap to use for android builds -# p4a.bootstrap = sdl2 - -# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask) -#p4a.port = - -# Control passing the --use-setup-py vs --ignore-setup-py to p4a -# "in the future" --use-setup-py is going to be the default behaviour in p4a, right now it is not -# Setting this to false will pass --ignore-setup-py, true will pass --use-setup-py -# NOTE: this is general setuptools integration, having pyproject.toml is enough, no need to generate -# setup.py if you're using Poetry, but you need to add "toml" to source.include_exts. -#p4a.setup_py = false - -# (str) extra command line arguments to pass when invoking pythonforandroid.toolchain -#p4a.extra_args = - - -# -# iOS specific -# - -# (str) Path to a custom kivy-ios folder -#ios.kivy_ios_dir = ../kivy-ios -# Alternately, specify the URL and branch of a git checkout: -ios.kivy_ios_url = https://github.com/kivy/kivy-ios -ios.kivy_ios_branch = master - -# Another platform dependency: ios-deploy -# Uncomment to use a custom checkout -#ios.ios_deploy_dir = ../ios_deploy -# Or specify URL and branch -ios.ios_deploy_url = https://github.com/phonegap/ios-deploy -ios.ios_deploy_branch = 1.10.0 - -# (bool) Whether or not to sign the code -ios.codesign.allowed = false - -# (str) Name of the certificate to use for signing the debug version -# Get a list of available identities: buildozer ios list_identities -#ios.codesign.debug = "iPhone Developer: ()" - -# (str) The development team to use for signing the debug version -#ios.codesign.development_team.debug = - -# (str) Name of the certificate to use for signing the release version -#ios.codesign.release = %(ios.codesign.debug)s - -# (str) The development team to use for signing the release version -#ios.codesign.development_team.release = - -# (str) URL pointing to .ipa file to be installed -# This option should be defined along with `display_image_url` and `full_size_image_url` options. -#ios.manifest.app_url = - -# (str) URL pointing to an icon (57x57px) to be displayed during download -# This option should be defined along with `app_url` and `full_size_image_url` options. -#ios.manifest.display_image_url = - -# (str) URL pointing to a large icon (512x512px) to be used by iTunes -# This option should be defined along with `app_url` and `display_image_url` options. -#ios.manifest.full_size_image_url = - - -[buildozer] - -# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) -log_level = 2 - -# (int) Display warning if buildozer is run as root (0 = False, 1 = True) -warn_on_root = 1 - -# (str) Path to build artifact storage, absolute or relative to spec file -# build_dir = ./.buildozer - -# (str) Path to build output (i.e. .apk, .aab, .ipa) storage -# bin_dir = ./bin - -# ----------------------------------------------------------------------------- -# List as sections -# -# You can define all the "list" as [section:key]. -# Each line will be considered as a option to the list. -# Let's take [app] / source.exclude_patterns. -# Instead of doing: -# -#[app] -#source.exclude_patterns = license,data/audio/*.wav,data/images/original/* -# -# This can be translated into: -# -#[app:source.exclude_patterns] -#license -#data/audio/*.wav -#data/images/original/* -# - - -# ----------------------------------------------------------------------------- -# Profiles -# -# You can extend section / key with a profile -# For example, you want to deploy a demo version of your application without -# HD content. You could first change the title to add "(demo)" in the name -# and extend the excluded directories to remove the HD content. -# -#[app@demo] -#title = My Application (demo) -# -#[app:source.exclude_patterns@demo] -#images/hd/* -# -# Then, invoke the command line with the "demo" profile: -# -#buildozer --profile demo android debug +[app] + +# (str) Title of your application +title = Plane Fighting + +# (str) Package name +package.name = plane_fighting + +# (str) Package domain (needed for android/ios packaging) +package.domain = ga.imwangzhiyu + +# (str) Source code where the main.py live +source.dir = . + +# (list) Source files to include (let empty to include all the files) +source.include_exts = py,png,ogg,wav,ttf,dat + +# (list) List of inclusions using pattern matching +source.include_patterns = font/*,sound/*,images/*,record.dat + +# (list) Source files to exclude (let empty to not exclude anything) +#source.exclude_exts = spec + +# (list) List of directory to exclude (let empty to not exclude anything) +#source.exclude_dirs = tests, bin, venv + +# (list) List of exclusions using pattern matching +# Do not prefix with './' +#source.exclude_patterns = license,images/*/*.jpg + +# (str) Application versioning (method 1) +version = 0.1 + +# (str) Application versioning (method 2) +# version.regex = __version__ = ['"](.*)['"] +# version.filename = %(source.dir)s/main.py + +# (list) Application requirements +# comma separated e.g. requirements = sqlite3,kivy +requirements = python3,pygame + +# (str) Custom source folders for requirements +# Sets custom source for any requirements with recipes +# requirements.source.kivy = ../../kivy + +# (str) Presplash of the application +#presplash.filename = %(source.dir)s/data/presplash.png + +# (str) Icon of the application +icon.filename = %(source.dir)s/images/icon.png + +# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) +orientation = portrait + +# (list) List of service to declare +#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY + +# +# OSX Specific +# + +# +# author = © Copyright Info + +# change the major version of python used by the app +osx.python_version = 3 + +# Kivy version to use +osx.kivy_version = 1.9.1 + +# +# Android specific +# + +# (bool) Indicate if the application should be fullscreen or not +fullscreen = 0 + +# (string) Presplash background color (for android toolchain) +# Supported formats are: #RRGGBB #AARRGGBB or one of the following names: +# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray, +# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy, +# olive, purple, silver, teal. +#android.presplash_color = #FFFFFF + +# (string) Presplash animation using Lottie format. +# see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/ +# for general documentation. +# Lottie files can be created using various tools, like Adobe After Effect or Synfig. +#android.presplash_lottie = "path/to/lottie/file.json" + +# (str) Adaptive icon of the application (used if Android API level is 26+ at runtime) +#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png +#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png + +# (list) Permissions +#android.permissions = INTERNET + +# (list) features (adds uses-feature -tags to manifest) +#android.features = android.hardware.usb.host + +# (int) Target Android API, should be as high as possible. +#android.api = 27 + +# (int) Minimum API your APK / AAB will support. +#android.minapi = 21 + +# (int) Android SDK version to use +#android.sdk = 20 + +# (str) Android NDK version to use +#android.ndk = 19b + +# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi. +#android.ndk_api = 21 + +# (bool) Use --private data storage (True) or --dir public storage (False) +#android.private_storage = True + +# (str) Android NDK directory (if empty, it will be automatically downloaded.) +#android.ndk_path = + +# (str) Android SDK directory (if empty, it will be automatically downloaded.) +#android.sdk_path = + +# (str) ANT directory (if empty, it will be automatically downloaded.) +#android.ant_path = + +# (bool) If True, then skip trying to update the Android sdk +# This can be useful to avoid excess Internet downloads or save time +# when an update is due and you just want to test/build your package +# android.skip_update = False + +# (bool) If True, then automatically accept SDK license +# 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 + +# (str) Android entry point, default is ok for Kivy-based app +#android.entrypoint = org.kivy.android.PythonActivity + +# (str) Full name including package path of the Java class that implements Android Activity +# use that parameter together with android.entrypoint to set custom Java class instead of PythonActivity +#android.activity_class_name = org.kivy.android.PythonActivity + +# (str) Extra xml to write directly inside the element of AndroidManifest.xml +# use that parameter to provide a filename from where to load your custom XML code +#android.extra_manifest_xml = ./src/android/extra_manifest.xml + +# (str) Extra xml to write directly inside the tag of AndroidManifest.xml +# use that parameter to provide a filename from where to load your custom XML arguments: +#android.extra_manifest_application_arguments = ./src/android/extra_manifest_application_arguments.xml + +# (str) Full name including package path of the Java class that implements Python Service +# use that parameter to set custom Java class instead of PythonService +#android.service_class_name = org.kivy.android.PythonService + +# (str) Android app theme, default is ok for Kivy-based app +# android.apptheme = "@android:style/Theme.NoTitleBar" + +# (list) Pattern to whitelist for the whole project +#android.whitelist = + +# (str) Path to a custom whitelist file +#android.whitelist_src = + +# (str) Path to a custom blacklist file +#android.blacklist_src = + +# (list) List of Java .jar files to add to the libs so that pyjnius can access +# their classes. Don't add jars that you do not need, since extra jars can slow +# down the build process. Allows wildcards matching, for example: +# OUYA-ODK/libs/*.jar +#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar + +# (list) List of Java files to add to the android project (can be java or a +# directory containing the files) +#android.add_src = + +# (list) Android AAR archives to add +#android.add_aars = + +# (list) Put these files or directories in the apk assets directory. +# Either form may be used, and assets need not be in 'source.include_exts'. +# 1) android.add_assets = source_asset_relative_path +# 2) android.add_assets = source_asset_path:destination_asset_relative_path +#android.add_assets = + +# (list) Gradle dependencies to add +#android.gradle_dependencies = + +# (bool) Enable AndroidX support. Enable when 'android.gradle_dependencies' +# contains an 'androidx' package, or any package from Kotlin source. +# android.enable_androidx requires android.api >= 28 +#android.enable_androidx = False + +# (list) add java compile options +# this can for example be necessary when importing certain java libraries using the 'android.gradle_dependencies' option +# see https://developer.android.com/studio/write/java8-support for further information +# android.add_compile_options = "sourceCompatibility = 1.8", "targetCompatibility = 1.8" + +# (list) Gradle repositories to add {can be necessary for some android.gradle_dependencies} +# please enclose in double quotes +# e.g. android.gradle_repositories = "maven { url 'https://kotlin.bintray.com/ktor' }" +#android.add_gradle_repositories = + +# (list) packaging options to add +# see https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html +# can be necessary to solve conflicts in gradle_dependencies +# please enclose in double quotes +# e.g. android.add_packaging_options = "exclude 'META-INF/common.kotlin_module'", "exclude 'META-INF/*.kotlin_module'" +#android.add_packaging_options = + +# (list) Java classes to add as activities to the manifest. +#android.add_activities = com.example.ExampleActivity + +# (str) OUYA Console category. Should be one of GAME or APP +# If you leave this blank, OUYA support will not be enabled +#android.ouya.category = GAME + +# (str) Filename of OUYA Console icon. It must be a 732x412 png image. +#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png + +# (str) XML file to include as an intent filters in tag +#android.manifest.intent_filters = + +# (str) launchMode to set for the main activity +#android.manifest.launch_mode = standard + +# (list) Android additional libraries to copy into libs/armeabi +#android.add_libs_armeabi = libs/android/*.so +#android.add_libs_armeabi_v7a = libs/android-v7/*.so +#android.add_libs_arm64_v8a = libs/android-v8/*.so +#android.add_libs_x86 = libs/android-x86/*.so +#android.add_libs_mips = libs/android-mips/*.so + +# (bool) Indicate whether the screen should stay on +# Don't forget to add the WAKE_LOCK permission if you set this to True +#android.wakelock = False + +# (list) Android application meta-data to set (key=value format) +#android.meta_data = + +# (list) Android library project to add (will be added in the +# project.properties automatically.) +#android.library_references = + +# (list) Android shared libraries which will be added to AndroidManifest.xml using tag +#android.uses_library = + +# (str) Android logcat filters to use +#android.logcat_filters = *:S python:D + +# (bool) Android logcat only display log for activity's pid +#android.logcat_pid_only = False + +# (str) Android additional adb arguments +#android.adb_args = -H host.docker.internal + +# (bool) Copy library instead of making a libpymodules.so +#android.copy_libs = 1 + +# (list) The Android archs to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64 +# In past, was `android.arch` as we weren't supporting builds for multiple archs at the same time. +android.archs = arm64-v8a, armeabi-v7a + +# (int) overrides automatic versionCode computation (used in build.gradle) +# this is not the same as app version and should only be edited if you know what you're doing +# android.numeric_version = 1 + +# (bool) enables Android auto backup feature (Android API >=23) +android.allow_backup = True + +# (str) XML file for custom backup rules (see official auto backup documentation) +# android.backup_rules = + +# (str) If you need to insert variables into your AndroidManifest.xml file, +# you can do so with the manifestPlaceholders property. +# This property takes a map of key-value pairs. (via a string) +# Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"] +# android.manifest_placeholders = [:] + +# (bool) disables the compilation of py to pyc/pyo files when packaging +# android.no-compile-pyo = True + +# (str) The format used to package the app for release mode (aab or apk). +# android.release_artifact = aab + +# +# Python for android (p4a) specific +# + +# (str) python-for-android URL to use for checkout +#p4a.url = + +# (str) python-for-android fork to use in case if p4a.url is not specified, defaults to upstream (kivy) +#p4a.fork = kivy + +# (str) python-for-android branch to use, defaults to master +#p4a.branch = master + +# (str) python-for-android specific commit to use, defaults to HEAD, must be within p4a.branch +#p4a.commit = HEAD + +# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) +#p4a.source_dir = + +# (str) The directory in which python-for-android should look for your own build recipes (if any) +#p4a.local_recipes = + +# (str) Filename to the hook for p4a +#p4a.hook = + +# (str) Bootstrap to use for android builds +# p4a.bootstrap = sdl2 + +# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask) +#p4a.port = + +# Control passing the --use-setup-py vs --ignore-setup-py to p4a +# "in the future" --use-setup-py is going to be the default behaviour in p4a, right now it is not +# Setting this to false will pass --ignore-setup-py, true will pass --use-setup-py +# NOTE: this is general setuptools integration, having pyproject.toml is enough, no need to generate +# setup.py if you're using Poetry, but you need to add "toml" to source.include_exts. +#p4a.setup_py = false + +# (str) extra command line arguments to pass when invoking pythonforandroid.toolchain +#p4a.extra_args = + + +# +# iOS specific +# + +# (str) Path to a custom kivy-ios folder +#ios.kivy_ios_dir = ../kivy-ios +# Alternately, specify the URL and branch of a git checkout: +ios.kivy_ios_url = https://github.com/kivy/kivy-ios +ios.kivy_ios_branch = master + +# Another platform dependency: ios-deploy +# Uncomment to use a custom checkout +#ios.ios_deploy_dir = ../ios_deploy +# Or specify URL and branch +ios.ios_deploy_url = https://github.com/phonegap/ios-deploy +ios.ios_deploy_branch = 1.10.0 + +# (bool) Whether or not to sign the code +ios.codesign.allowed = false + +# (str) Name of the certificate to use for signing the debug version +# Get a list of available identities: buildozer ios list_identities +#ios.codesign.debug = "iPhone Developer: ()" + +# (str) The development team to use for signing the debug version +#ios.codesign.development_team.debug = + +# (str) Name of the certificate to use for signing the release version +#ios.codesign.release = %(ios.codesign.debug)s + +# (str) The development team to use for signing the release version +#ios.codesign.development_team.release = + +# (str) URL pointing to .ipa file to be installed +# This option should be defined along with `display_image_url` and `full_size_image_url` options. +#ios.manifest.app_url = + +# (str) URL pointing to an icon (57x57px) to be displayed during download +# This option should be defined along with `app_url` and `full_size_image_url` options. +#ios.manifest.display_image_url = + +# (str) URL pointing to a large icon (512x512px) to be used by iTunes +# This option should be defined along with `app_url` and `display_image_url` options. +#ios.manifest.full_size_image_url = + + +[buildozer] + +# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) +log_level = 2 + +# (int) Display warning if buildozer is run as root (0 = False, 1 = True) +warn_on_root = 1 + +# (str) Path to build artifact storage, absolute or relative to spec file +# build_dir = ./.buildozer + +# (str) Path to build output (i.e. .apk, .aab, .ipa) storage +# bin_dir = ./bin + +# ----------------------------------------------------------------------------- +# List as sections +# +# You can define all the "list" as [section:key]. +# Each line will be considered as a option to the list. +# Let's take [app] / source.exclude_patterns. +# Instead of doing: +# +#[app] +#source.exclude_patterns = license,data/audio/*.wav,data/images/original/* +# +# This can be translated into: +# +#[app:source.exclude_patterns] +#license +#data/audio/*.wav +#data/images/original/* +# + + +# ----------------------------------------------------------------------------- +# Profiles +# +# You can extend section / key with a profile +# For example, you want to deploy a demo version of your application without +# HD content. You could first change the title to add "(demo)" in the name +# and extend the excluded directories to remove the HD content. +# +#[app@demo] +#title = My Application (demo) +# +#[app:source.exclude_patterns@demo] +#images/hd/* +# +# Then, invoke the command line with the "demo" profile: +# +#buildozer --profile demo android debug diff --git a/plane_fighting/images/touch/bomb.png b/plane_fighting/images/touch/bomb.png new file mode 100644 index 0000000000000000000000000000000000000000..3a9baca3eb0ff1eb0b5487bf1b1dab357c15306b GIT binary patch literal 2450 zcmbVO3se(l7LLgK;Y!eoR3s;ety_}J1d@=!AP~YkKzRwSsKaD{NRo-kKp<5FMa0s| zimgyYKrQqXDX>bF$Q#A8l+uD#K(IiIk5bD+K(s|=C%lgBakpnX=giDM|Ns5pz4!a? zy=RUE1$dbmTN#r`Br_jxk6_|W(cXso#8atOPZKXAxp$(<9Sp!twBnJ zFo?p(6exv7XVVbSkxAij=^z{6G9B$HOaSCC01g9mpaCERuptL7W$~gC))b-`DA>bu z(H8N=qsHO59AYq3DivMjK*toZ43Nv^G5{un$)phonlf32!$~xm(sqf#163jlu^bm; zGK!WFj>Zyj9+mKPAq1&>nO3G;l!*|Gkp#;bARW+#G!GOZ%Q$(0LNae$gfLJEDn(_u zlE8w?Sa}?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>JWLsUHvF1WulG5Lr|D7Jgc&g1@j#37G)m`!xemNIlv`O(LA)D5xFWY0fzST|8xIbS%3w|dY_m_D@!eN=sZDz zXIdRCocZ9*=*TOekz}D+PAdW{#%ZSycq}?CJh1|Uw1El$N&h1+24RZmRs*aIvdW=a zkI6b5x{hnbIv551&j2H94;1zg9CizB7;97TBi87EA9gnxwy{5!4AUWq?wFm)a+a*@ zJF_=*a`wchuim#9r)=1NV@3PQy5XlQ_rAU0<0ia&(#~rmQr{Y#oV9aa!LEJvTN+xs z22PchOh4;uJCfRHIrI&ano1>KXgjQqI52R3qw&ZKABE2T+TFBmZEfP!OvKw_-*6-z zi%T4+n#*hnmAMI}bmGCLJ>jYNhu^-KKvX0+Cxu4#oS)!c`X2c4?#ZMTy6Wc4&eqGh z?b-NzPk-gtEp<8Zpmdge>_TDDr)MthNU1Mg_|*HLx_5K?6pnf4+WOGGl&!xku-Arr za^`(`xb^auF)g9rT^l5n9e3y1dq)>6K7R8~>uT?FWBXrQZkXBm=l0X*y813=Bz%50 z!;*k>mo)dR>ezS*`?=^wTy3ZA!1882y48x&KfDn}mi(3c(_S5R{nX-Rv+A#Y(0FT2 z?~KHzb4j%WJ*F#n4^F;V*SI$Bc6@jLs|a$uuYXT?JK13|wv_!gj#1^q<*%REvCHNx zN*k4Ow1GVIS=-cA==#pO@bf!PRh~9|=i!d-Yr8orvFSqmy3xJwmSNdNMa7%8HBR_G zvFH2@Pv7okV|&Ll@kJ|dE!`Hn(m*cm*x0^Mr>7`UJmMI$Ha?*>m!laCTYU-_5O+z5oCK literal 0 HcmV?d00001 diff --git a/plane_fighting/images/touch/r.png b/plane_fighting/images/touch/r.png new file mode 100644 index 0000000000000000000000000000000000000000..f58c94c870d7a34a4519a025907e0f851b694032 GIT binary patch literal 1868 zcmbVNeQXnD7{9_gU@&EaKgfvTc3>Dndmr7p-mx-9uWn5&lx|~N6ybXJc01PI9e202 zn;%RBEL+rIA_@b8m0*O3x+#d8LUcyaF+hT%L_$C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644 --- a/plane_fighting/main.py +++ b/plane_fighting/main.py @@ -8,25 +8,36 @@ import bullet import supply import time import os +import platform abspath = os.getcwd() + "/" from pygame.locals import * from random import * -jj = 0 + pygame.init() pygame.mixer.init() -bg_size = width, height = 480, 700 -screen = pygame.display.set_mode(bg_size) +bg_size = width, height = 480, 680 +if platform.system().lower() == "Windows": + screen = pygame.display.set_mode(bg_size) +elif platform.system().lower() == "Linux": + if os.path.exists("/storage/emulated"): # Android + screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) + else: + screen = pygame.display.set_mode(bg_size) # Linux +elif platform.system().lower() == "Darwin": + # TODO: 判断 iOS 与 macOS + screen = pygame.display.set_mode(bg_size) +else: + screen = pygame.display.set_mode(bg_size) 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)) #对齐的坐标 -pygame.display.update() #显示内容 +background = pygame.image.load(abspath + "images/loading.png") # 图片位置 +screen.blit(background, (0, 0)) # 对齐的坐标 +pygame.display.update() # 显示内容 pygame.mixer.music.load(abspath + "sound/game_music.ogg") pygame.mixer.music.set_volume(0.1) -pygame.mixer.music.play(-1) -time.sleep(7.5) +# time.sleep(7.5) background = pygame.image.load(abspath + "images/background.png").convert() BLACK = (0, 0, 0) WHITE = (255, 255, 255) @@ -57,36 +68,38 @@ enemy3_down_sound.set_volume(0.5) me_down_sound = pygame.mixer.Sound(abspath + "sound/me_down.wav") - def add_small_enemies(group1, group2, num): for i in range(num): e1 = enemy.SmallEnemy(bg_size) group1.add(e1) group2.add(e1) + def add_mid_enemies(group1, group2, num): for i in range(num): e2 = enemy.MidEnemy(bg_size) group1.add(e2) group2.add(e2) + def add_big_enemies(group1, group2, num): for i in range(num): e3 = enemy.BigEnemy(bg_size) group1.add(e3) group2.add(e3) + def inc_speed(target, inc): for each in target: each.speed += inc + def main(): + pygame.mixer.music.play(-1) # Me me = myplane.MyPlane(bg_size) - enemies = pygame.sprite.Group() - # Enemy Level 1 small_enemies = pygame.sprite.Group() add_small_enemies(small_enemies, enemies, 15) @@ -104,15 +117,15 @@ def main(): bullet1_index = 0 BULLET1_NUM = 4 for i in range(BULLET1_NUM): - bullet1.append(bullet.Bullet1((me.rect.centerx-3, me.rect.centery))) + bullet1.append(bullet.Bullet1((me.rect.centerx - 3, me.rect.centery))) # Super Bull bullet2 = [] bullet2_index = 0 BULLET2_NUM = 8 - for i in range(BULLET2_NUM//2): - bullet2.append(bullet.Bullet2((me.rect.centerx-33, me.rect.centery))) - bullet2.append(bullet.Bullet2((me.rect.centerx+30, me.rect.centery))) + for i in range(BULLET2_NUM // 2): + bullet2.append(bullet.Bullet2((me.rect.centerx - 33, me.rect.centery))) + bullet2.append(bullet.Bullet2((me.rect.centerx + 30, me.rect.centery))) clock = pygame.time.Clock() @@ -126,6 +139,24 @@ def main(): score = 0 score_font = pygame.font.Font(abspath + "font/font.ttf", 36) + # 移动设备触摸支持 + touch_support = True + touch_up_image = pygame.image.load(abspath + "images/touch/u.png").convert_alpha() + touch_left_image = pygame.image.load(abspath + "images/touch/l.png").convert_alpha() + touch_right_image = pygame.image.load(abspath + "images/touch/r.png").convert_alpha() + touch_down_image = pygame.image.load(abspath + "images/touch/d.png").convert_alpha() + touch_bomb_image = pygame.image.load(abspath + "images/touch/bomb.png").convert_alpha() + touch_left_rect = touch_left_image.get_rect() + touch_right_rect = touch_right_image.get_rect() + 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 + # 标志是否暂停游戏 paused = False pause_nor_image = pygame.image.load(abspath + "images/pause_nor.png").convert_alpha() @@ -138,6 +169,9 @@ def main(): # 设置难度级别 level = 1 + + # 初始化炸弹时间锁 + last_bomb = time.time() # 全屏炸弹 bomb_image = pygame.image.load(abspath + "images/bomb.png").convert_alpha() @@ -160,7 +194,6 @@ def main(): # 解除我方无敌状态定时器 INVINCIBLE_TIME = USEREVENT + 3 - # 生命数量 life_num = 3 life_image = pygame.image.load(abspath + "images/life.png").convert_alpha() @@ -212,16 +245,17 @@ def main(): if paused: paused_image = resume_nor_image else: - paused_image = pause_nor_image + paused_image = pause_nor_image elif event.type == KEYDOWN: if event.key == K_SPACE: - if bomb_num: + if bomb_num and last_bomb - time.time() <= -1: bomb_num -= 1 bomb_sound.play() for each in enemies: if each.rect.bottom > 0: each.active = False + last_bomb = time.time() elif event.type == SUPPLY_TIME: supply_sound.play() @@ -237,7 +271,6 @@ def main(): elif event.type == INVINCIBLE_TIME: me.invincible = False pygame.time.set_timer(INVINCIBLE_TIME, 0) - # 根据用户的得分增加难度 if level == 1 and score > 50000: @@ -274,14 +307,13 @@ def main(): upgrade_sound.play() # 增加5架小型敌机、3架中型敌机和2架大型敌机 add_small_enemies(small_enemies, enemies, 300) - + # 提升小型敌机的速度 inc_speed(small_enemies, 1) inc_speed(mid_enemies, 1) - screen.blit(background, (0, 0)) - + if life_num and not paused: # 检测用户的键盘操作 key_pressed = pygame.key.get_pressed() @@ -294,26 +326,23 @@ def main(): me.moveLeft() elif key_pressed[K_d] or key_pressed[K_RIGHT]: me.moveRight() - elif key_pressed[K_F1]:#100核弹 - bomb_num = 100 - elif key_pressed[K_F2]:#不使用双子弹 + elif key_pressed[K_F1]: # +100核弹 + bomb_num += 100 + elif key_pressed[K_F2]: # 不使用双子弹 is_double_bullet = True - elif key_pressed[K_F3]:#使用双子弹 + elif key_pressed[K_F3]: # 使用双子弹 is_double_bullet = False - elif key_pressed[K_F4]:#生命+1 + elif key_pressed[K_F4]: # 生命+1 life_num += 1 - elif key_pressed[K_F5]:#小+1 + elif key_pressed[K_F5]: # 小+1 add_small_enemies(small_enemies, enemies, 100) - elif key_pressed[K_F6]:#中+1 + elif key_pressed[K_F6]: # 中+1 add_mid_enemies(mid_enemies, enemies, 100) - elif key_pressed[K_F7]:#大+1 + elif key_pressed[K_F7]: # 大+1 add_big_enemies(big_enemies, enemies, 100) elif key_pressed[K_F8]: level = 4 score = 1000000 - - - # 绘制全屏炸弹补给并检测是否获得 if bomb_supply.active: @@ -336,19 +365,18 @@ def main(): bullet_supply.active = False # 发射子弹 - if not(delay % 10): + if not (delay % 10): bullet_sound.play() if is_double_bullet: bullets = bullet2 - bullets[bullet2_index].reset((me.rect.centerx-33, me.rect.centery)) - bullets[bullet2_index+1].reset((me.rect.centerx+30, me.rect.centery)) + bullets[bullet2_index].reset((me.rect.centerx - 33, me.rect.centery)) + bullets[bullet2_index + 1].reset((me.rect.centerx + 30, me.rect.centery)) bullet2_index = (bullet2_index + 2) % BULLET2_NUM else: bullets = bullet1 bullets[bullet1_index].reset(me.rect.midtop) bullet1_index = (bullet1_index + 1) % BULLET1_NUM - # 检测子弹是否击中敌机 for b in bullets: if b.active: @@ -365,7 +393,7 @@ def main(): e.active = False else: e.active = False - + # 绘制大型敌机 for each in big_enemies: if each.active: @@ -394,13 +422,13 @@ def main(): (each.rect.left, each.rect.top - 5), \ (each.rect.left + each.rect.width * energy_remain, \ each.rect.top - 5), 2) - + # 即将出现在画面中,播放音效 if each.rect.bottom == -50: enemy3_fly_sound.play(-1) else: # 毁灭 - if not(delay % 3): + if not (delay % 3): if e3_destroy_index == 0: enemy3_down_sound.play() screen.blit(each.destroy_images[e3_destroy_index], each.rect) @@ -446,7 +474,7 @@ def main(): each.rect.top - 5), 2) else: # 毁灭 - if not(delay % 3): + if not (delay % 3): if e2_destroy_index == 0: enemy2_down_sound.play() screen.blit(each.destroy_images[e2_destroy_index], each.rect) @@ -462,7 +490,7 @@ def main(): screen.blit(each.image, each.rect) else: # 毁灭 - if not(delay % 3): + if not (delay % 3): if e1_destroy_index == 0: enemy1_down_sound.play() score += 1000 @@ -476,7 +504,7 @@ def main(): me.active = False for e in enemies_down: e.active = False - + # 绘制我方飞机 if me.active: if switch_image: @@ -485,7 +513,7 @@ def main(): screen.blit(me.image2, me.rect) else: # 毁灭 - if not(delay % 3): + if not (delay % 3): if me_destroy_index == 0: me_down_sound.play() screen.blit(me.destroy_images[me_destroy_index], me.rect) @@ -496,7 +524,7 @@ def main(): pygame.time.set_timer(INVINCIBLE_TIME, 3 * 1000) # 绘制全屏炸弹数量 - bomb_text = bomb_font.render("× %d" % bomb_num, True, WHITE) + bomb_text = bomb_font.render("%d" % bomb_num, True, WHITE) text_rect = bomb_text.get_rect() screen.blit(bomb_image, (10, height - 10 - bomb_rect.height)) screen.blit(bomb_text, (20 + bomb_rect.width, height - 5 - text_rect.height)) @@ -505,11 +533,11 @@ def main(): if life_num: for i in range(life_num): screen.blit(life_image, \ - (width-10-(i+1)*life_rect.width, \ - height-10-life_rect.height)) + (width - 10 - (i + 1) * life_rect.width, \ + height - 10 - life_rect.height)) # 绘制得分 - score_text = score_font.render("Score : %s" % str(score), True, WHITE) + score_text = score_font.render("Score: %s" % str(score), True, WHITE) screen.blit(score_text, (10, 5)) # 绘制游戏结束画面 @@ -535,30 +563,30 @@ def main(): f.write(str(score)) # 绘制结束画面 - record_score_text = score_font.render("Best : %d" % record_score, True, (255, 255, 255)) + record_score_text = score_font.render("Best: %d" % record_score, True, (255, 255, 255)) screen.blit(record_score_text, (50, 50)) - + gameover_text1 = gameover_font.render("Your Score", True, (255, 255, 255)) gameover_text1_rect = gameover_text1.get_rect() gameover_text1_rect.left, gameover_text1_rect.top = \ - (width - gameover_text1_rect.width) // 2, height // 3 + (width - gameover_text1_rect.width) // 2, height // 3 screen.blit(gameover_text1, gameover_text1_rect) - + gameover_text2 = gameover_font.render(str(score), True, (255, 255, 255)) gameover_text2_rect = gameover_text2.get_rect() gameover_text2_rect.left, gameover_text2_rect.top = \ - (width - gameover_text2_rect.width) // 2, \ - gameover_text1_rect.bottom + 10 + (width - gameover_text2_rect.width) // 2, \ + gameover_text1_rect.bottom + 10 screen.blit(gameover_text2, gameover_text2_rect) again_rect.left, again_rect.top = \ - (width - again_rect.width) // 2, \ - gameover_text2_rect.bottom + 50 + (width - again_rect.width) // 2, \ + gameover_text2_rect.bottom + 50 screen.blit(again_image, again_rect) gameover_rect.left, gameover_rect.top = \ - (width - again_rect.width) // 2, \ - again_rect.bottom + 10 + (width - again_rect.width) // 2, \ + again_rect.bottom + 10 screen.blit(gameover_image, gameover_rect) # 检测用户的鼠标操作 @@ -567,31 +595,47 @@ def main(): # 获取鼠标坐标 pos = pygame.mouse.get_pos() # 如果用户点击“重新开始” - if again_rect.left < pos[0] < again_rect.right and \ - again_rect.top < pos[1] < again_rect.bottom: - # 调用main函数,重新开始游戏 + if again_rect.left < pos[0] < again_rect.right and again_rect.top < pos[1] < again_rect.bottom: main() - # 如果用户点击“结束游戏” - elif gameover_rect.left < pos[0] < gameover_rect.right and \ - gameover_rect.top < pos[1] < gameover_rect.bottom: - # 退出游戏 + # 如果用户点击“结束游戏” + if gameover_rect.left < pos[0] < gameover_rect.right and gameover_rect.top < pos[1] < gameover_rect.bottom: pygame.quit() - sys.exit() - - # 绘制暂停按钮 + 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: + me.moveUp() + if touch_left_rect.left < pos[0] < touch_left_rect.right and touch_left_rect.top < pos[1] < touch_left_rect.bottom: + me.moveLeft() + if touch_right_rect.left < pos[0] < touch_right_rect.right and touch_right_rect.top < pos[1] < touch_right_rect.bottom: + me.moveRight() + if touch_down_rect.left < pos[0] < touch_down_rect.right and touch_down_rect.top < pos[1] < touch_down_rect.bottom: + 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 bomb_num and last_bomb - time.time() <= -1: + bomb_num -= 1 + bomb_sound.play() + for each in enemies: + if each.rect.bottom > 0: + each.active = False + last_bomb = time.time() + # 绘制按钮 screen.blit(paused_image, paused_rect) - + screen.blit(touch_up_image, touch_up_rect) + screen.blit(touch_left_image, touch_left_rect) + screen.blit(touch_right_image, touch_right_rect) + screen.blit(touch_down_image, touch_down_rect) + screen.blit(touch_bomb_image, touch_bomb_rect) # 切换图片 - if not(delay % 5): + if not (delay % 5): switch_image = not switch_image - delay -= 1 if not delay: delay = 100 - pygame.display.flip() clock.tick(60) - + + if __name__ == "__main__": try: main() diff --git a/plane_fighting/record.dat b/plane_fighting/record.dat index 573541a..a3e09b1 100644 --- a/plane_fighting/record.dat +++ b/plane_fighting/record.dat @@ -1 +1 @@ -0 +7000 \ No newline at end of file