Python+Pgzrun制作打飞机游戏(附源码)

目录

基本框架

 创建滚动背景

 创建飞机

 让plane移动

 发射子弹

创建敌机

敌机移动

金币制度

关卡制度 

设置

创建更高级飞机(SRplane和SSRplane )

开始

 炸弹

介绍

源码 


基本框架

import pgzrun
WIDTH, HEIGHT = 500, 700
TITLE = '打飞机'

pgzrun.go()

 创建滚动背景

bg1.png和bg2.png 

 

bg1 = Actor('bg1.png')# 保存在images文件中,下同
bg1.x = 250
bg1.y = 350

bg2 = Actor('bg2.png')
bg2.x = bg1.x
bg2.y = bg1.y - 700

def draw():
    bg1.draw()
    bg2.draw()

def update():

    bg1.y += 2               # 滚动起来
    bg2.y += 2
    if bg1.y > 700 + 350:
        bg1.y = bg2.y - 700
    if bg2.y > 700 + 350:
        bg2.y = bg1.y - 700

 创建飞机

plane = Actor('plane.png')
plane.x = 250
plane.y = 600

注:上边的代码写在框架中 

plane.png

 

 让plane移动

def update():
    #--省略-- 
    if keyboard.left:
        plane.x += 5

    elif keyboard.right:
        plane.x -= 5

    if plane.x < 0:
        plane.x += 10

    elif plane.x > 500:
        plane.x -= 10

 发射子弹

bullets = []

def on_key_down(key):
        if key == keys.SPACE:
            bullet = Actor('bullet1.png')
            bullet.x = plane.x
            bullet.y = plane.y - 30
            bullets.append(bullet)

 bullet1.png

 

def draw():
    --省略--
    for b in bullets:
        b.draw()
def update():
    --省略--
    for b in bullets:
        b.y -= 5
        if b.y < 0:
            bullets.remove(b)

创建敌机

enemys = []
for i in range(6):
    enemy = Actor('enemy.png')

    enemy.x = 70 * (i + 1)
    enemy.y = 20

    enemys.append(enemy)

enemy.png

敌机移动

def update():
    # --省略--
    speed = 2
    for e in enemys:
        e.y += speed
        if e.bottom >= 700:
            e.y = 0
            e.x = randint(50, WIDTH - 50)
        if e.colliderect(plane):
            plane.image = 'plane2.png'
            enemys.remove(e)


        for b in bullets:

            if e.colliderect(b):
                bullets.remove(b)
                e.y = 0
                e.x = randint(50, WIDTH - 50)
                

plane2.png

 

def draw():
    # --省略--
    if plane.image != 'plane2.png':  #重构

        for b in bullets:
            b.draw()
        for i in enemys:
            i.draw()

到此为止,《打飞机》游戏已经可以玩了,以下部分都是其他功能,让游戏更有可玩性 

金币制度 

在主文件夹中创建data文件夹,存放数据

在data文件夹创建金币.txt,写入0

with open('data/金币.txt', 'r') as f:  # 获取金币信息
    coin = int(f.read())
    f.close()
def draw():
    # --省略--
    text1 = 'coin:' + str(coin)
    screen.draw.text(text1, (50, 10), fontsize=50, color='black')
def update():
    # --省略--
    for e in enemys:
        --省略--
        for b in bullets:
            # --省略--
            if e.colliderect(b)
                # --省略--
                coin += 1

                f3 = open('data/金币.txt', 'w')
                f3.write(str(coin))
                f3.close()

关卡制度 

在data文件夹中创建level.txt

f = open('data/level.txt', 'r')  # 获取关卡数据
level = int(f.read())
f.close()
kill = 0 # 关卡中击杀敌机数量
def draw():
    # --省略--
    text = 'level' + str(level)
    screen.draw.text(text, (350, 10), fontsize=50, color='black')

    text2 = str(kill) + '/' + str((level + 1) * 10)
    screen.draw.text(text2, (230, 10), fontsize=50, color='black')
def update():
    --省略--
    standard = (level + 1) * 10
    if kill > standard:
        kill = 0
        level += 1
        f = open('data/level.txt', 'w')
        f.write(str(level))
        f.close()
def update():
    # --省略--
    speed = 2 + level*0.1 # 重构

设置

创建settings.py

# coding=gbk
import wx


def set():
    class MyFrame(wx.Frame):
        def __init__(self):
            global beijing
            super().__init__(None, title='设置', size=(500, 250), pos=(400, 400))
            panel = wx.Panel(parent=self)
            statictext = wx.StaticBox(parent=panel, label="这里是《打飞机》游戏设置", pos=(10, 10))

    app = wx.App()

    frm = MyFrame()
    frm.Show()
    app.MainLoop()

set(1).jpg 

set = Actor('set(1).jpg')
set.x = 20
set.y = 20

def draw():
    # --省略--
    set.draw()

创建更高级飞机(SRplane和SSRplane )

                               

srplane.png    srplane2.png             ssrplane.png               ssrplane2.png

创建shop.py

在data文件夹中创建sr.txt和ssr.txt,写入0

创建plane.txt 写入plane.png

shop.py

import wx


def shopping():
    class MyFrame(wx.Frame):
        def __init__(self):
            super().__init__(None, title='商店', size=(500, 300), pos=(400, 400))
            panel = wx.Panel(parent=self)
            statictext = wx.StaticBox(parent=panel, label="这里是《打飞机》游戏商店", pos=(10, 10))

            statictext = wx.StaticBox(parent=panel, label="你可以在这购买英雄皮肤", pos=(10, 50))

            with open('data/sr.txt', 'r') as f:
                c = f.read()
                f.close()
            if c != '0':
                self.srtext = '已拥有SR级飞机'
            else:
                self.srtext = '购买SR级飞机(1000金币,两条命)'
            self.button = wx.Button(panel, -1, self.srtext, pos=(30, 150))
            self.Bind(wx.EVT_BUTTON, self.srshopping, self.button)
            self.button.SetDefault()

            with open('data/ssr.txt', 'r') as f:
                c2 = f.read()
                f.close()
            if c2 != '0':
                self.ssrtext = '已拥有SSR级飞机'
            else:
                self.ssrtext = '购买SSR级飞机(3000金币,两条命,一次发射两枚子弹)'
            self.button = wx.Button(panel, -1, self.ssrtext, pos=(30, 210))
            self.Bind(wx.EVT_BUTTON, self.ssrshopping, self.button)
            self.button.SetDefault()

        def srshopping(self, event):
            with open('data/金币.txt') as f:
                c = int(f.read())
                f.close()
            if self.srtext == '购买SR级飞机(两条命)' and c >= 1000:
                self.srtext = '已获得'
                self.button.SetLabel(self.srtext)
                with open('data/金币.txt', 'w') as f:
                    f.write(str(c - 1000))
                    f.close()
                with open('data/sr.txt', 'w') as f:
                    f.write('1')
                    f.close()

        def ssrshopping(self, event):
            with open('data/金币.txt') as f:
                c = int(f.read())
                f.close()
            if self.ssrtext == '购买SSR级飞机(3000金币,两条命,一次发射两枚子弹)' and c >= 3000:
                self.ssrtext = '已获得'
                self.button.SetLabel(self.ssrtext)

                with open('data/金币.txt', 'w') as f:
                    f.write(str(c - 3000))
                    f.close()
                with open('data/ssr.txt', 'w') as f:
                    f.write('1')
                    f.close()

    app = wx.App()

    frm = MyFrame()
    frm.Show()
    app.MainLoop()

settings.py

def set():
    # --省略--
    with open('data/sr.txt', 'r') as f:
        c = f.read()
        f.close()
    if c != '0':
        self.sr_go_out = '让SR飞机上场'
    else:
        self.sr_go_out = '未获得SR飞机'

    self.button = wx.Button(panel, -1, self.sr_go_out, pos=(60, 100))
    self.Bind(wx.EVT_BUTTON, self.srgoout, self.button)
    self.button.SetDefault()

    with open('data/ssr.txt', 'r') as f:
        c1 = f.read()
        f.close()
    if c1 != '0':
        self.ssr_go_out = '让SSR飞机上场'
    else:
        self.ssr_go_out = '未获得SSR飞机'

    self.button = wx.Button(panel, -1, self.ssr_go_out, pos=(60, 150))
    self.Bind(wx.EVT_BUTTON, self.ssrgoout, self.button)
    self.button.SetDefault()
    def srgoout(self, event):
        global planemodel
        if self.sr_go_out == '让SR飞机上场':
            with open('data/plane.txt', 'w') as f:
                f.write('srplane.png')
                planemodel = 'srplane'

    def ssrgoout(self, event):
        global planemodel
        if self.ssr_go_out == '让SSR飞机上场':
            with open('data/plane.txt', 'w') as f:
                f.write('ssrplane.png')
                planemodel = 'ssrplane'

打飞机.py

with open('data/plane.txt') as f5:
    p = f5.read()
    f5.close()
live = 0
if p == 'plane.png':
    live = 1
elif p == 'srplane.png' or p == 'ssrplane.png':
    live = 2
def update():
    # --省略--
    if e.colliderect(plane):            
        live -= 1

​def on_key_down(key):
    # --省略--
    if key == keys.SPACE:
        if plane.image == 'ssrplane.png' and len(bullets) < 12: # 重构

            bullet = Actor('bullet1.png')
            bullet1 = Actor('bullet1.png')
            bullet.x = plane.x + 40
            bullet.y = plane.y - 50
            bullet1.x = plane.x - 40
            bullet1.y = plane.y - 50
            bullets.append(bullet)
            bullets.append(bullet1)
        else:
            if plane.image == 'srplane.png' and len(bullets) < 10:
                bullet = Actor('bullet1.png')
                bullet.x = plane.x
                bullet.y = plane.y - 30
                bullets.append(bullet)
            if plane.image == 'plane.png' and len(bullets) < 6:
                bullet = Actor('bullet1.png')
                bullet.x = plane.x
                bullet.y = plane.y - 30
                bullets.append(bullet)
​
def on_mouse_down(pos):
    global live
    if set.collidepoint(pos):
        settings.set()
        plane.image = settings.planemodel
        if settings.planemodel == 'plane.png':
            live = 1
        elif settings.planemodel == 'srplane.png' or settings.planemodel == 'ssrplane.png':
            live = 2

开始

begin = False
def draw():
    # --省略--
    if begin:               #重构
        plane.image = settings.planemodel
        plane.draw()
        if plane.image != 'plane2.png':
            for b in bullets:
                b.draw()

            for i in enemys:
                i.draw()
    else:
        set.draw() # 重构

        screen.draw.text('Press [b] to begin', (100, 350), fontsize=50, color='black')

def on_key_down(key):
    
    if begin:# 重构
        # --省略--
    else:
        if key == keys.B:
            begin = True
def update():    
    if begin:
        # --省略--
        if live == 0:
            begin = False

 炸弹

创建bombs.txt,写入5

with open('data/bombs.txt') as f4:  # 获取炸弹数量信息
    b = int(f4.read())
    f4.close()

bomb = Actor('bomb.png')
bomb.x = 32
bomb.y = 550
bombs = b

def draw():
    # --省略--
    if begin:
        # --省略--
        screen.draw.text(str(bombs), (32, 582), fontsize=30, color='black')
        bomb.draw()

def on_key_down(key):
    if begin:
        # --省略--
        if key == keys.Z:
            if bombs > 0:
                for e in enemys:
                    e.y = 0
                    e.x = randint(50, WIDTH - 50)
                    kill += 1
            bombs -= 1
            with open('data/bombs.txt', 'w') as f:
                f.write(str(bombs))
                f.close()
import wx


def shopping():
    class MyFrame(wx.Frame):
        def __init__(self):
            # --省略--
            self.button1 = wx.Button(panel, 1, '购买炸弹(100金币)', pos=(50, 100))
            self.Bind(wx.EVT_BUTTON, self.bombshopping, self.button1)
            self.button1.SetDefault()
          
            # --省略--
        def bombshopping(self, event):
            with open('data/金币.txt') as f:
                c = int(f.read())
                f.close()
            if c>=100:
                self.button1.SetLabel('购买成功')

                with open('data/bombs.txt') as f:
                    b = int(f.read())
                    f.close()
                with open('data/bombs.txt', 'w') as f:
                    f.write((str(b + 1)))
                    f.close()
                with open('data/金币.txt') as f:
                    c = int(f.read())
                    f.close()
                with open('data/金币.txt', 'w') as f:
                    f.write(str(c - 100))
                    f.close()
# --省略--

打飞机.py

def draw():
    # --省略--
    if begin:
        # --省略--
    else:
        # --省略--
        screen.draw.text('Press [s] to go shopping', (50, 460), fontsize=50, color='black')
def on_key_down():
    if begin:
        # --省略--
    else:
        # --省略--
        if key == keys.S:
            shopping()

介绍

创建information.py 

import wx


def check_information():
    class MyFrame(wx.Frame):
        def __init__(self):
            super().__init__(None, title='信息简介', size=(500, 200), pos=(400, 400))
            panel = wx.Panel(parent=self)
            statictext = wx.StaticBox(parent=panel, label="欢迎进入《打飞机》游戏", pos=(10, 10))
            statictext = wx.StaticBox(parent=panel, label="你可以按下左右方向键控制英雄移动", pos=(10, 50))
            statictext = wx.StaticBox(parent=panel, label="按空格键发射子弹,并击杀敌人", pos=(10, 90))
            statictext = wx.StaticBox(parent=panel, label="你拥有5个炸弹,按【z】试一试!", pos=(10, 120))

    app = wx.App()

    frm = MyFrame()
    frm.Show()
    app.MainLoop()
def draw():
    if begin:
        # --省略--
    else:
        # --省略--
        screen.draw.text('Press [i] to get information', (30, 410), fontsize=50, color='black')
def draw():
    if begin:
        # --省略--
    else:
        # --省略--
        if key == keys.S:
            shopping()
            f2 = open('data/金币.txt', 'r')  # 获取金币信息
            coin = int(f2.read())
            f2.close()

到此为止,游戏正式编写结束了!

源码 

打飞机.py

# coding=gbk

from random import randint

from pgzrun import go

import settings
from information import check_information
from shop import shopping

# 打开文件,获取数据
f = open('data/level.txt', 'r')  # 获取关卡数据
level = int(f.read())
f.close()

f2 = open('data/金币.txt', 'r')  # 获取金币信息
coin = int(f2.read())
f2.close()

with open('data/bombs.txt') as f4:  # 获取炸弹数量信息
    b = int(f4.read())
    f4.close()

with open('data/plane.txt') as f5:
    p = f5.read()
    f5.close()
live = 0
if p == 'plane.png':
    live = 1
elif p == 'srplane.png' or p == 'ssrplane.png':
    live = 2

with open('data/log.txt') as f:
    logged = f.read()
    f.close()

# 窗口数据
WIDTH, HEIGHT = 500, 700
TITLE = '打飞机'
# 创建角色
bg1 = Actor('bg2.png')
bg1.x = 250
bg1.y = 350

bg2 = Actor('bg1.png')
bg2.x = bg1.x
bg2.y = bg1.y - 700

plane = Actor(settings.planemodel)
plane.x = 250
plane.y = 600

set = Actor('set(1).jpg')
set.x = 20
set.y = 20
bullets = []

bomb = Actor('bomb.png')
bomb.x = 32
bomb.y = 550
bombs = b
enemys = []
kill = 0
begin = False

for i in range(6):
    enemy = Actor('enemy.png')

    enemy.x = 70 * (i + 1)
    enemy.y = 20

    enemys.append(enemy)


def draw():
    global bombs
    bg1.draw()
    bg2.draw()

    text = 'level' + str(level)
    text2 = str(kill) + '/' + str((level + 1) * 10)
    text3 = 'coin:' + str(coin)
    screen.draw.text(text2, (230, 10), fontsize=50, color='black')
    screen.draw.text(text, (350, 10), fontsize=50, color='black')
    screen.draw.text(text3, (50, 10), fontsize=50, color='black')
    if begin:
        screen.draw.text(str(bombs), (32, 582), fontsize=30, color='black')
        bomb.draw()
        plane.image = settings.planemodel
        plane.draw()
        if plane.image != 'plane2.png':
            for b in bullets:
                b.draw()

            for i in enemys:
                i.draw()
    else:
        set.draw()

        screen.draw.text('Press [b] to begin', (100, 350), fontsize=50, color='black')
        screen.draw.text('Press [i] to get information', (30, 410), fontsize=50, color='black')
        screen.draw.text('Press [s] to go shopping', (50, 460), fontsize=50, color='black')


def on_key_down(key):
    global begin, bombs, kill, coin, p, live
    if begin:
        if key == keys.SPACE:
            if plane.image == 'ssrplane.png' and len(bullets) < 6:

                bullet = Actor('bullet1.png')
                bullet1 = Actor('bullet1.png')
                bullet.x = plane.x + 40
                bullet.y = plane.y - 50
                bullet1.x = plane.x - 40
                bullet1.y = plane.y - 50
                bullets.append(bullet)
                bullets.append(bullet1)
            else:
                if plane.image == 'srplane.png' and len(bullets) < 6:
                    bullet = Actor('bullet1.png')
                    bullet.x = plane.x
                    bullet.y = plane.y - 30
                    bullets.append(bullet)
                if plane.image == 'plane.png' and len(bullets) < 6:
                    bullet = Actor('bullet1.png')
                    bullet.x = plane.x
                    bullet.y = plane.y - 30
                    bullets.append(bullet)

        if key == keys.Z:
            if bombs > 0:
                for e in enemys:
                    if bombs > 0:
                        e.y = 0
                        e.x = randint(50, WIDTH - 50)
                        kill += 1
            bombs -= 1
            with open('data/bombs.txt', 'w') as f:
                f.write(str(bombs))
                f.close()

    else:
        if key == keys.B:
            begin = True
        if key == keys.I:
            check_information()
        if key == keys.S:
            shopping()
            f2 = open('data/金币.txt', 'r')  # 获取金币信息
            coin = int(f2.read())
            f2.close()


def on_mouse_down(pos):
    global beijing, live
    if set.collidepoint(pos):
        settings.set()
        beijing = settings.beijing
        plane.image = settings.planemodel
        if settings.planemodel == 'plane.png':
            live = 1
        elif settings.planemodel == 'srplane.png' or settings.planemodel == 'ssrplane.png':
            live = 2


def update():
    global kill, level, begin, coin, beijing, p, live

    standard = (level + 1) * 10
    bg1.y += 2
    bg2.y += 2
    if bg1.y > 700 + 350:
        bg1.y = bg2.y - 700
    if bg2.y > 700 + 350:
        bg2.y = bg1.y - 700
    if begin:
        if kill > standard:
            kill = 0
            level += 1
            f = open('data/level.txt', 'w')
            f.write(str(level))
            f.close()

        speed = 2 + level * 0.1

        if keyboard.left:
            plane.x -= 5
        elif keyboard.right:
            plane.x += 5

        if plane.x < 0:
            plane.x += 10
        elif plane.x > 500:
            plane.x -= 10

        for b in bullets:
            b.y -= 5
            if b.y < 0:
                bullets.remove(b)

        for e in enemys:
            e.y += speed
            if e.bottom >= 700:
                e.y = 0
                e.x = randint(50, WIDTH - 50)
            if e.colliderect(plane):
                live -= 1
                if live == 0:

                    plane.image = 'plane2.png'
                    enemys.remove(e)
                    kill = 0
                    live = 2
                    begin = False
                    enemys.clear()
                    bullets.clear()
                    for i in range(6):
                        enemy = Actor('enemy.png')
                        enemy.x = 70 * (i + 1)
                        enemy.y = 20

                        enemys.append(enemy)
                else:

                    e.y = 0
                    e.x = randint(50, WIDTH - 50)
            for b in bullets:

                if e.colliderect(b):
                    bullets.remove(b)
                    e.y = 0
                    e.x = randint(50, WIDTH - 50)
                    kill += 1
                    coin += 1

                    f3 = open('data/金币.txt', 'w')
                    f3.write(str(coin))
                    f3.close()


go()

 shop.py

import wx


def shopping():
    class MyFrame(wx.Frame):
        def __init__(self):
            super().__init__(None, title='商店', size=(500, 300), pos=(400, 400))
            panel = wx.Panel(parent=self)
            statictext = wx.StaticBox(parent=panel, label="这里是《打飞机》游戏商店", pos=(10, 10))

            statictext = wx.StaticBox(parent=panel, label="你可以在这购买英雄皮肤", pos=(10, 50))

            self.button1 = wx.Button(panel, 1, '购买炸弹(100金币)', pos=(50, 100))
            self.Bind(wx.EVT_BUTTON, self.bombshopping, self.button1)
            self.button1.SetDefault()
            with open('data/sr.txt', 'r') as f:
                c = f.read()
                f.close()
            if c != '0':
                self.srtext = '已拥有SR级飞机'
            else:
                self.srtext = '购买SR级飞机(1000金币,两条命)'
            self.button = wx.Button(panel, -1, self.srtext, pos=(30, 150))
            self.Bind(wx.EVT_BUTTON, self.srshopping, self.button)
            self.button.SetDefault()

            with open('data/ssr.txt', 'r') as f:
                c2 = f.read()
                f.close()
            if c2 != '0':
                self.ssrtext = '已拥有SSR级飞机'
            else:
                self.ssrtext = '购买SSR级飞机(3000金币,两条命,一次发射两枚子弹)'
            self.button = wx.Button(panel, -1, self.ssrtext, pos=(30, 210))
            self.Bind(wx.EVT_BUTTON, self.ssrshopping, self.button)
            self.button.SetDefault()

        def bombshopping(self, event):
            with open('data/金币.txt') as f:
                c = int(f.read())
                f.close()
            if c>=100:
                self.button1.SetLabel('购买成功')

                with open('data/bombs.txt') as f:
                    b = int(f.read())
                    f.close()
                with open('data/bombs.txt', 'w') as f:
                    f.write((str(b + 1)))
                    f.close()
                with open('data/金币.txt') as f:
                    c = int(f.read())
                    f.close()
                with open('data/金币.txt', 'w') as f:
                    f.write(str(c - 100))
                    f.close()

        def srshopping(self, event):
            with open('data/金币.txt') as f:
                c = int(f.read())
                f.close()
            if self.srtext == '购买SR级飞机(两条命)' and c >= 1000:
                self.srtext = '已获得'
                self.button.SetLabel(self.srtext)
                with open('data/金币.txt', 'w') as f:
                    f.write(str(c - 1000))
                    f.close()
                with open('data/sr.txt', 'w') as f:
                    f.write('1')
                    f.close()

        def ssrshopping(self, event):
            with open('data/金币.txt') as f:
                c = int(f.read())
                f.close()
            if self.ssrtext == '购买SSR级飞机(3000金币,两条命,一次发射两枚子弹)' and c >= 3000:
                self.ssrtext = '已获得'
                self.button.SetLabel(self.ssrtext)

                with open('data/金币.txt', 'w') as f:
                    f.write(str(c - 3000))
                    f.close()
                with open('data/ssr.txt', 'w') as f:
                    f.write('1')
                    f.close()

    app = wx.App()

    frm = MyFrame()
    frm.Show()
    app.MainLoop()

settings.py

# coding=gbk
import wx


f = open('data/plane.txt')
planemodel = f.read()
f.close()


def set():
    class MyFrame(wx.Frame):
        def __init__(self):
            global beijing
            super().__init__(None, title='设置', size=(500, 250), pos=(400, 400))
            panel = wx.Panel(parent=self)
            statictext = wx.StaticBox(parent=panel, label="这里是《打飞机》游戏设置", pos=(10, 10))

            with open('data/sr.txt', 'r') as f:
                c = f.read()
                f.close()
            if c != '0':
                self.sr_go_out = '让SR飞机上场'
            else:
                self.sr_go_out = '未获得SR飞机'

            self.button = wx.Button(panel, -1, self.sr_go_out, pos=(60, 100))
            self.Bind(wx.EVT_BUTTON, self.srgoout, self.button)
            self.button.SetDefault()

            with open('data/ssr.txt', 'r') as f:
                c1 = f.read()
                f.close()
            if c1 != '0':
                self.ssr_go_out = '让SSR飞机上场'
            else:
                self.ssr_go_out = '未获得SSR飞机'

            self.button = wx.Button(panel, -1, self.ssr_go_out, pos=(60, 150))
            self.Bind(wx.EVT_BUTTON, self.ssrgoout, self.button)
            self.button.SetDefault()

        def srgoout(self, event):
            global planemodel
            if self.sr_go_out == '让SR飞机上场':
                with open('data/plane.txt', 'w') as f:
                    f.write('srplane.png')
                    planemodel = 'srplane'

        def ssrgoout(self, event):
            global planemodel
            if self.ssr_go_out == '让SSR飞机上场':
                with open('data/plane.txt', 'w') as f:
                    f.write('ssrplane.png')
                    planemodel = 'ssrplane'

    app = wx.App()

    frm = MyFrame()
    frm.Show()
    app.MainLoop()

information.py

import wx


def check_information():
    class MyFrame(wx.Frame):
        def __init__(self):
            super().__init__(None, title='信息简介', size=(500, 200), pos=(400, 400))
            panel = wx.Panel(parent=self)
            statictext = wx.StaticBox(parent=panel, label="欢迎进入《打飞机》游戏", pos=(10, 10))
            statictext = wx.StaticBox(parent=panel, label="你可以按下左右方向键控制英雄移动", pos=(10, 50))
            statictext = wx.StaticBox(parent=panel, label="按空格键发射子弹,并击杀敌人", pos=(10, 90))
            statictext = wx.StaticBox(parent=panel, label="你拥有一些炸弹,按【z】试一试!", pos=(10, 120))

    app = wx.App()

    frm = MyFrame()
    frm.Show()
    app.MainLoop()

bombs.txt

5

level.txt

1

plane.txt

plane.png

sr.txt

0

ssr.txt

0

金币.txt

0

猜你喜欢

转载自blog.csdn.net/m0_67210503/article/details/128073673