摘要:文章目錄前言前言一創(chuàng)建數(shù)據(jù)庫一創(chuàng)建數(shù)據(jù)庫二項目二項目運行結(jié)果運行結(jié)果新建新建總結(jié)總結(jié)前言一個基于和的飛機大戰(zhàn)小游戲,包含了管理員和用戶的操作。
?
一個基于python和MySQL的飛機大戰(zhàn)小游戲,包含了管理員和用戶的操作。
用Navicat創(chuàng)建如圖所示數(shù)據(jù)庫
?
1.用戶注冊
2.用戶查詢
?3.管理員登陸
4. 完整操作
Login.py
# -*- coding: UTF-8 -*-"""@author:林楓@file:3.py@time:2021/06/07"""import pymysqlfrom tkinter import *from tkinter import messageboxfrom tkinter import ttkfrom tkinter.messagebox import *from game import *import pygameclass My_Gui(): def __init__(self, main_screen): self.main_screen = main_screen def set_init_window(self): self.main_screen.geometry("1442x700") self.main_screen.title("登陸界面") self.bg = PhotoImage(file="background.png") Label(image=self.bg).place(x=0, y=0) Label(text="歡迎登錄飛機大戰(zhàn)游戲", font=("宋體", 20)).place(x=580, y=100) Label(text="賬號", font=("宋體", 15)).place(x=450, y=250) Label(text="密碼", font=("宋體", 15)).place(x=450, y=350) self.username_verify = StringVar() self.password_verify = StringVar() self.username_login_entry = Entry(self.main_screen, textvariable=self.username_verify, width=45, font=("宋體", 15)) self.username_login_entry.place(x=500, y=250) self.password_login_entry = Entry(self.main_screen, textvariable=self.password_verify, show="*", width=45, font=("宋體", 15)) self.password_login_entry.place(x=500, y=350) Button(text="用戶登錄", width="10", font=("宋體", 15), command=self.login_verify).place(x=650, y=400) Button(text="管理員登錄", width="10", font=("宋體", 15), command=self.Admin_login_verify).place(x=450, y=400) Button(text="用戶注冊", width="10", font=("宋體", 15), command=self.register).place(x=840, y=400) self.main_screen.mainloop() def login_verify(self): self.username1 = self.username_verify.get() self.password1 = self.password_verify.get() conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="testdb", port=3306, charset="utf8") cur = conn.cursor() select_sql = "select pw from user WHERE un=%s" cur.execute(select_sql, [self.username1]) result = cur.fetchone() if len(self.username1) == 0: messagebox.showinfo("錯誤", "請輸入賬號!") cur.close() conn.close() elif result is None: cur.close() conn.close() messagebox.showinfo("失敗", "該賬號未注冊!") self.password_login_entry.delete(0, END) self.username_login_entry.delete(0, END) else: if result[0] == self.password1: cur.close() conn.close() messagebox.showinfo("成功", "登錄成功") self.username_login_entry.delete(0, END) self.password_login_entry.delete(0, END) self.login_sucess() elif result[0] != self.password1: cur.close() conn.close() messagebox.showinfo("失敗", "密碼錯誤!") self.password_login_entry.delete(0, END) def login_sucess(self): self.main_screen.destroy() conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="testdb", port=3306, charset="utf8") cur = conn.cursor() select_sql = "select id from user WHERE un=%s" cur.execute(select_sql, [self.username1]) i = cur.fetchone()[0] select_sql = "select code, time from code_lable WHERE userid=%s" cur.execute(select_sql, [i]) data = cur.fetchall() data = list(data) data = list(reversed(data)) print(data) max_list = [] data_list = [] for x in data: max_list.append(int(x[0])) self.user_screen1 = Tk() self.user_screen1.geometry("1442x700") self.user_screen1.title("用戶界面") self.bg = PhotoImage(file="background.png") Label(self.user_screen1, image=self.bg).place(x=0, y=0) Label(self.user_screen1, text="親愛的玩家:" + self.username1 + " 你好", font=("宋體", 20)).place(x=565, y=30) self.columns = ("序號", "得分", "時間", "序號1", "得分1", "時間1", "序號2", "得分2", "時間2") self.tree = ttk.Treeview(self.user_screen1, height=20, show="headings", columns=self.columns) # 隱藏首列 self.tree.column("序號", width=60) # 表示列,不顯示 self.tree.column("得分", width=170) # 表示列,不顯示 self.tree.column("時間", width=170) # 表示列,不顯示 self.tree.column("序號1", width=60) # 表示列,不顯示 self.tree.column("得分1", width=170) # 表示列,不顯示 self.tree.column("時間1", width=170) # 表示列,不顯示 self.tree.column("序號2", width=60) # 表示列,不顯示 self.tree.column("得分2", width=170) # 表示列,不顯示 self.tree.column("時間2", width=170) # 表示列,不顯示 self.tree.place(x=130, y=150) self.tree.heading("序號", text="序號", anchor=CENTER) self.tree.heading("得分", text="得分", anchor=CENTER) self.tree.heading("時間", text="時間", anchor=CENTER) self.tree.heading("序號1", text="序號", anchor=CENTER) self.tree.heading("得分1", text="得分", anchor=CENTER) self.tree.heading("時間1", text="時間", anchor=CENTER) self.tree.heading("序號2", text="序號", anchor=CENTER) self.tree.heading("得分2", text="得分", anchor=CENTER) self.tree.heading("時間2", text="時間", anchor=CENTER) if len(max_list) == 0: Label(self.user_screen1, font=("宋體", 15), text="您暫無游戲數(shù)據(jù),快開始游戲吧!").place(x=560, y=100) elif len(max_list) > 0 and len(max_list) <= 20: Label(self.user_screen1, font=("宋體", 15), text="您的最高分為:" + str(max(max_list)) + "分").place(x=580, y=100) for i in range(0, len(max_list)): self.tree.insert("", i, values=(i + 1, data[i][0], data[i][1])) elif len(max_list) > 20 and len(max_list) <= 40: Label(self.user_screen1, font=("宋體", 15), text="您的最高分為:" + str(max(max_list)) + "分").place(x=580, y=100) for i in range(0, len(max_list) - 20): self.tree.insert("", i, values=(i + 1, data[i][0], data[i][1], i + 21, data[i + 20][0], data[i + 20][1])) for x in range(i + 1, 21): self.tree.insert("", x, values=(x + 1, data[x][0], data[x][1])) elif len(max_list) > 40 and len(max_list) <= 60: Label(self.user_screen1, font=("宋體", 15), text="您的最高分為:" + str(max(max_list)) + "分").place(x=580, y=100) for i in range(0, len(max_list) - 40): self.tree.insert("", i, values=( i + 1, data[i][0], data[i][1], i + 21, data[i + 20][0], data[i + 20][1], i + 41, data[i + 40][0], data[i + 40][1])) for x in range(i + 1, 21): self.tree.insert("", x, values=(x + 1, data[x][0], data[x][1], x + 21, data[x + 20][0], data[x + 20][1])) else: Label(self.user_screen1, font=("宋體", 15), text="您的最高分為:" + str(max(max_list)) + "分").place(x=580, y=100) for i in range(20): self.tree.insert("", i, values=( i + 1, data[i][0], data[i][1], i + 21, data[i + 20][0], data[i + 20][1], i + 41, data[i + 40][0], data[i + 40][1])) cur.close() conn.close() Button(self.user_screen1, text="開始游戲", width=10, font=("宋體", 15), command=self.Destroy3).place(x=200, y=600) Button(self.user_screen1, text="返回首頁", width=10, font=("宋體", 15), command=self.Destroy2).place(x=1120, y=600) self.user_screen1.mainloop() def register_user(self): self.username_info = self.username_entry.get() self.password_info = self.password_entry.get() conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="testdb", port=3306, charset="utf8") cur = conn.cursor() select_sql = "select un from user WHERE un=%s" cur.execute(select_sql, [self.username_info]) result = cur.fetchone() if len(self.username_info) == 0: messagebox.showinfo("錯誤", "請輸入賬號!") cur.close() conn.close() elif len(self.password_info) == 0: messagebox.showinfo("錯誤", "請輸入密碼!") cur.close() conn.close() elif result is None: sql = "insert into user(un,pw)" / "values("%s","%s")" % / (self.username_info, self.password_info) try: cur.execute(sql) conn.commit() cur.close() conn.close() except: conn.rollback() self.username_entry.delete(0, END) self.password_entry.delete(0, END) messagebox.showinfo("成功", "注冊成功!") else: cur.close() conn.close() messagebox.showinfo("失敗", "該賬號已被注冊!") self.password_entry.delete(0, END) self.username_entry.delete(0, END) def register(self): self.username = StringVar() self.password = StringVar() self.main_screen.destroy() self.register_screen = Tk() self.register_screen.geometry("1442x700") self.register_screen.title("注冊界面") self.bg = PhotoImage(file="background.png") Label(self.register_screen, image=self.bg).place(x=0, y=0) Label(self.register_screen, text="歡迎來到注冊界面", font=("宋體", 20)).place(x=580, y=100) self.username_lable = Label(self.register_screen, font=("宋體", 15), text="賬號") self.username_lable.place(x=450, y=250) self.username_entry = Entry(self.register_screen, textvariable=self.username, width=45, font=("宋體", 15)) self.username_entry.place(x=500, y=250) self.password_lable = Label(self.register_screen, font=("宋體", 15), text="密碼") self.password_lable.place(x=450, y=350) self.password_entry = Entry(self.register_screen, textvariable=self.password, show="*", width=45, font=("宋體", 15)) self.password_entry.place(x=500, y=350) Button(self.register_screen, text="注冊", width=10, font=("宋體", 15), command=self.register_user).place(x=550, y=400) Button(self.register_screen, text="返回首頁", width=10, font=("宋體", 15), command=self.Destroy).place(x=750, y=400) self.register_screen.mainloop() def AdLogin(self): self.cheek_username = StringVar() self.main_screen.destroy() self.admin_screen = Tk() self.admin_screen.geometry("1442x700") self.admin_screen.title("查詢界面") self.bg = PhotoImage(file="background.png") Label(self.admin_screen, image=self.bg).place(x=0, y=0) Label(self.admin_screen, text="歡迎來到查詢界面", font=("宋體", 20)).place(x=600, y=30) Label(self.admin_screen, font=("宋體", 15), text="賬號").place(x=500, y=100) self.username3 = Entry(self.admin_screen, textvariable=self.cheek_username, width=40, font=("宋體", 15)) self.username3.place(x=550, y=100) self.columns = ("序號", "得分", "時間", "序號1", "得分1", "時間1", "序號2", "得分2", "時間2") self.tree = ttk.Treeview(self.admin_screen, height=20, show="headings", columns=self.columns) # 隱藏首列 self.tree.column("序號", width=60) # 表示列,不顯示 self.tree.column("得分", width=170) # 表示列,不顯示 self.tree.column("時間", width=170) # 表示列,不顯示 self.tree.column("序號1", width=60) # 表示列,不顯示 self.tree.column("得分1", width=170) # 表示列,不顯示 self.tree.column("時間1", width=170) # 表示列,不顯示 self.tree.column("序號2", width=60) # 表示列,不顯示 self.tree.column("得分2", width=170) # 表示列,不顯示 self.tree.column("時間2", width=170) # 表示列,不顯示 self.tree.place(x=130, y=150) Button(self.admin_screen, text="查詢", width=10, font=("宋體", 15), command=self.serach).place(x=200, y=600) Button(self.admin_screen, text="查詢所有玩家最高分", width=20, font=("宋體", 15), command=self.serach_best).place(x=620, y=600) Button(self.admin_screen, text="返回首頁", width=10, font=("宋體", 15), command=self.Destroy1).place(x=1120, y=600) self.admin_screen.mainloop() def serach(self): x = self.tree.get_children() for item in x: self.tree.delete(item) conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="testdb", port=3306, charset="utf8") cur = conn.cursor() select_sql = "select un from user WHERE un=%s" cur.execute(select_sql, [self.username3.get()]) result = cur.fetchone() if len(self.username3.get()) == 0: messagebox.showinfo("錯誤", "請輸入賬號!") cur.close() conn.close() elif result is None: messagebox.showinfo("錯誤", "該賬號不存在!") cur.close() conn.close() else: self.tree.heading("序號", text="序號", anchor=CENTER) self.tree.heading("得分", text="得分", anchor=CENTER) self.tree.heading("時間", text="時間", anchor=CENTER) self.tree.heading("序號1", text="序號", anchor=CENTER) self.tree.heading("得分1", text="得分", anchor=CENTER) self.tree.heading("時間1", text="時間", anchor=CENTER) self.tree.heading("序號2", text="序號", anchor=CENTER) self.tree.heading("得分2", text="得分", anchor=CENTER) self.tree.heading("時間2", text="時間", anchor=CENTER) select_sql = "select id from user WHERE un=%s" cur.execute(select_sql, [self.username3.get()]) select_sql = "select code, time from code_lable WHERE userid=%s" cur.execute(select_sql, [cur.fetchone()[0]]) lists = cur.fetchall() lists = list(lists) lists = list(reversed(lists)) print(len(lists)) if len(lists) == 0: self.tree.insert("", 0, values=(1, "暫無數(shù)據(jù)")) elif len(lists) > 0 and len(lists) <= 20: for i in range(0, len(lists)): self.tree.insert("", i, values=(i + 1, lists[i][0], lists[i][1])) elif len(lists) > 20 and len(lists) <= 40: for i in range(0, len(lists) - 20): self.tree.insert("", i, values=( i + 1, lists[i][0], lists[i][1], i + 21, lists[i + 20][0], lists[i + 20][1])) for x in range(i + 1, 21): self.tree.insert("", x, values=(x + 1, lists[x][0], lists[x][1])) elif len(lists) > 40 and len(lists) <= 60: for i in range(0, len(lists) - 40): self.tree.insert("", i, values=( i + 1, lists[i][0], lists[i][1], i + 21, lists[i + 20][0], lists[i + 20][1], i + 41, lists[i + 40][0], lists[i + 40][1])) for x in range(i + 1, 21): self.tree.insert("", x, values=( x + 1, lists[x][0], lists[x][1], x + 21, lists[x + 20][0], lists[x + 20][1])) else: for i in range(20): self.tree.insert("", i, values=( i + 1, lists[i][0], lists[i][1], i + 21, lists[i + 20][0], lists[i + 20][1], i + 41, lists[i + 40][0], lists[i + 40][1])) cur.close() conn.close() def serach_best(self): self.tree.heading("序號", text="玩家ID", anchor=CENTER) self.tree.heading("得分", text="最高得分", anchor=CENTER) self.tree.heading("時間", text="時間", anchor=CENTER) self.tree.heading("序號1", text="玩家ID", anchor=CENTER) self.tree.heading("得分1", text="最高得分", anchor=CENTER) self.tree.heading("時間1", text="時間", anchor=CENTER) self.tree.heading("序號2", text="玩家ID", anchor=CENTER) self.tree.heading("得分2", text="最高得分", anchor=CENTER) self.tree.heading("時間2", text="時間", anchor=CENTER) x = self.tree.get_children() for item in x: self.tree.delete(item) self.username3.delete(0, END) conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="testdb", port=3306, charset="utf8") cur = conn.cursor() select_sql = "select un from user" cur.execute(select_sql) result = cur.fetchall() datas = [] for i in range(0, len(result)): ID = result[i] select_sql = "select id from user WHERE un=%s" cur.execute(select_sql, [ID[0]]) id = cur.fetchone() select_sql = "select code, time from code_lable WHERE userid=%s" cur.execute(select_sql, [id[0]]) data = cur.fetchall() max_list = [] data_list = [] for x in data: max_list.append(int(x[0])) print(max_list) if len(max_list) > 0: data_list.append(ID[0]) data_list.append(max(max_list)) data_list.append(data[max_list.index(max(max_list))][1]) else: data_list.append(ID[0]) data_list.append("暫無數(shù)據(jù)") datas.append(data_list) # print(datas) if len(datas) == 0: messagebox.showinfo("錯誤", "暫無注冊用戶!") cur.close() conn.close() elif len(datas) > 0 and len(datas) <= 20: for i in range(len(datas)): if len(datas[i]) == 2: self.tree.insert("", i, values=(datas[i][0], datas[i][1])) else: self.tree.insert("", i, values=(datas[i][0], datas[i][1], datas[i][2])) elif len(datas) > 20 and len(datas) <= 40: for i in range(len(datas) - 20): if len(datas[i]) == 2 and len(datas[i + 20]) == 2: self.tree.insert("", i, values=(datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], datas[i + 20][2])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], datas[i + 20][2])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 2: self.tree.insert("", i, values=(datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1])) for x in range(i + 1, 21): if len(datas[x]) == 2: self.tree.insert("", x, values=(datas[x][0], datas[x][1])) else: self.tree.insert("", x, values=(datas[x][0], datas[x][1], datas[x][2])) elif len(datas) > 40 and len(datas) <= 60: for i in range(len(datas) - 40): if len(datas[i]) == 2 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) for x in range(i + 1, 21): if len(datas[x]) == 2 and len(datas[x + 20]) == 2: self.tree.insert("", x, values=(datas[x][0], datas[x][1], "", datas[x + 20][0], datas[x + 20][1])) elif len(datas[x]) == 2 and len(datas[x + 20]) == 3: self.tree.insert("", x, values=( datas[x][0], datas[x][1], "", datas[x + 20][0], datas[x + 20][1], datas[x + 20][2])) elif len(datas[x]) == 3 and len(datas[x + 20]) == 3: self.tree.insert("", x, values=( datas[x][0], datas[x][1], datas[x][2], datas[x + 20][0], datas[x + 20][1], datas[x + 20][2])) elif len(datas[x]) == 3 and len(datas[x + 20]) == 2: self.tree.insert("", x, values=(datas[x][0], datas[x][1], datas[x][2], datas[x + 20][0], datas[x + 20][1])) else: for i in range(20): if len(datas[i]) == 2 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 2: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 2 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], "", datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) elif len(datas[i]) == 2 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], "", datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) elif len(datas[i]) == 3 and len(datas[i + 20]) == 3 and len(datas[i + 40]) == 3: self.tree.insert("", i, values=( datas[i][0], datas[i][1], datas[i][2], datas[i + 20][0], datas[i + 20][1], datas[i + 20][2], datas[i + 40][0], datas[i + 40][1], datas[i + 40][2])) cur.close() conn.close() def Admin_login_verify(self): self.username2 = self.username_verify.get() self.password2 = self.password_verify.get() conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="testdb", port=3306, charset="utf8") cur = conn.cursor() select_sql = "select passward from admin WHERE username=%s" cur.execute(select_sql, [self.username2]) result = cur.fetchone() if len(self.username2) == 0: messagebox.showinfo("錯誤", "請輸入賬號!") cur.close() conn.close() elif result is None: cur.close() conn.close() messagebox.showinfo("失敗", "該賬號未注冊!") self.password_login_entry.delete(0, END) self.username_login_entry.delete(0, END) else: if result[0] == self.password2: cur.close() conn.close() messagebox.showinfo("成功", "登錄成功") self.username_login_entry.delete(0, END) self.password_login_entry.delete(0, END) self.AdLogin() elif result[0] != self.password2: cur.close() conn.close() messagebox.showinfo("失敗", "密碼錯誤!") self.password_login_entry.delete(0, END) def Destroy(self): self.register_screen.destroy() gui_start().set_init_window() def Destroy1(self): self.admin_screen.destroy() gui_start().set_init_window() def Destroy2(self): self.user_screen1.destroy() gui_start().set_init_window() def Destroy3(self): self.user_screen1.destroy() go(self.username1)def gui_start(): init_window = Tk() # 實例化出一個父窗口 return My_Gui(init_window) # 設(shè)置根窗口默認屬性 # ZMJ_PORTAL.set_init_window() # init_window.mainloop() # 父窗口進入事件循環(huán),可以理解為保持窗口運行,否則界面不展示# if __name__ == "__main__":# gui_start().set_init_window()
這就是我自己寫的基于python和mysql的飛機大戰(zhàn)小游戲,由于代碼太長,篇幅有限,如果有需要源碼的小伙伴們可以來qq加我:3090677003.(第一次寫博客還希望大家點贊,謝謝!!(●"?"●))
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/123742.html
摘要:今天杭州又是大雨,被淋了個落湯雞,都怪我家大狼狗非要騎電動車,我昨天吐槽要買的帥氣的雨衣還沒有買不過大雨和飛機大戰(zhàn)小游戲更配哦。微信早已正式發(fā)布微信內(nèi)置飛機大戰(zhàn)游戲,目前該游戲已經(jīng)下線。此時,界面中會顯示此次玩家的飛機大戰(zhàn)分數(shù)。showImg(https://user-gold-cdn.xitu.io/2019/5/15/16ab9377884b99f7); 今天杭州又是大雨,被淋了個落湯雞...
摘要:今天杭州又是大雨,被淋了個落湯雞,都怪我家大狼狗非要騎電動車,我昨天吐槽要買的帥氣的雨衣還沒有買不過大雨和飛機大戰(zhàn)小游戲更配哦。微信早已正式發(fā)布微信內(nèi)置飛機大戰(zhàn)游戲,目前該游戲已經(jīng)下線。此時,界面中會顯示此次玩家的飛機大戰(zhàn)分數(shù)。 今天杭州又是大雨,被淋了個落湯雞,都怪我家大狼狗非要騎電動車,我昨天吐槽要買的帥氣的雨衣還沒有買,不過大雨和飛機大戰(zhàn)小游戲更配哦。 這篇文章來自我司的王老吉同...
摘要:飛機大戰(zhàn)這是一款經(jīng)典飛行射擊類游戲,為玩家呈現(xiàn)一場不一樣射擊體驗。簡單的觸屏操作,觸屏按住隨意一個地方,左右移動,便可自動攻擊敵人,上下移動亦可躲避強敵。玩家在游戲中要做的就是駕駛著最新戰(zhàn)機,向敵人發(fā)起沖擊。 ? ? ? 《飛機大戰(zhàn)》這是一款經(jīng)典飛行射擊類游戲,為玩家呈現(xiàn)一場不一樣射擊體驗。...
閱讀 2655·2021-11-23 09:51
閱讀 1644·2021-11-22 13:54
閱讀 2782·2021-11-18 10:02
閱讀 936·2021-08-16 10:57
閱讀 3554·2021-08-03 14:03
閱讀 1873·2019-08-30 15:54
閱讀 3527·2019-08-23 14:39
閱讀 598·2019-08-23 14:26