Python 飞机大战脚本

import pygame
import os

# 屏幕尺寸
SCREEN_WIDTH = 480
SCREEN_HEIGHT = 800

# 创建游戏窗口
game_window = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

# 设置游戏标题
pygame.display.set_caption('飞机大战')

# 载入飞机图片
airplane_image = pygame.image.load(os.path.join('images', 'airplane.png')).convert_alpha()

# 设置飞机初始位置
airplane_x = SCREEN_WIDTH // 2 - airplane_image.get_width() // 2
airplane_y = SCREEN_HEIGHT - airplane_image.get_height()

# 游戏主循环
running = True
while running:
    # 事件处理
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # 绘制背景
game_window.fill((255, 255, 255))

    # 绘制飞机
game_window.blit(airplane_image, (airplane_x, airplane_y))

    # 更新显示
pygame.display.update()

# 退出游戏
pygame.quit()
zip
飞机大战python.zip 预估大小:65个文件
folder
飞机大战python 文件夹
folder
__init__.py 文件夹
folder
font 文件夹
file
font.ttf 77KB
file
main.py 21KB
file
bullet.py 1KB
folder
新建文件夹 文件夹
file
myplane.py 2KB
file
record.txt 5B
file
enemy.py 5KB
folder
images 文件夹
file
pause_pressed.png 5KB
file
enemy1_down4.png 4KB
file
enemy1.png 5KB
file
again.png 6KB
file
enemy2.png 11KB
file
bomb.png 8KB
file
me_destroy_2.png 18KB
file
enemy2_hit.png 11KB
file
enemy1_down2.png 6KB
file
enemy3_n1.png 42KB
file
enemy3_hit.png 45KB
file
gameover.png 7KB
file
resume_nor.png 5KB
file
bullet2.png 3KB
file
life.png 5KB
file
bomb_supply.png 10KB
file
enemy3_n2.png 42KB
file
enemy3_down2.png 49KB
file
enemy2_down4.png 5KB
file
me_destroy_4.png 5KB
file
me1.png 15KB
file
me_destroy_3.png 19KB
file
enemy1_down1.png 6KB
file
enemy3_down1.png 47KB
file
enemy3_down5.png 66KB
file
background.png 32KB
file
resume_pressed.png 5KB
file
me2.png 14KB
file
enemy2_down1.png 12KB
folder
new.txt 文件夹
file
bullet_supply.png 9KB
file
me_destroy_1.png 17KB
file
enemy3_down4.png 59KB
file
bullet1.png 3KB
file
enemy1_down3.png 7KB
file
enemy3_down6.png 10KB
file
enemy3_down3.png 56KB
file
pause_nor.png 5KB
file
enemy2_down3.png 14KB
file
enemy2_down2.png 13KB
folder
__pycache__ 文件夹
file
bullet.cpython-37.pyc 2KB
file
supply.cpython-37.pyc 2KB
file
enemy.cpython-37.pyc 4KB
file
myplane.cpython-37.pyc 2KB
file
supply.py 2KB
folder
sound 文件夹
file
button.wav 11KB
file
get_bomb.wav 23KB
file
upgrade.wav 38KB
file
get_bullet.wav 104KB
file
enemy1_down.wav 72KB
file
bullet.wav 36KB
file
supply.wav 34KB
file
enemy3_flying.wav 104KB
file
me_down.wav 90KB
file
use_bomb.wav 83KB
file
enemy3_down.wav 142KB
file
enemy2_down.wav 59KB
file
game_music.ogg 339KB
...
zip 文件大小:1.65MB