import tkinter as tk
import dui
import taiji
import cai
mw = tk.Tk()
mw.title('azhu99')
mw.geometry('500x500')
def duidraw():
dui.draw()
btn1 = tk.Button(
mw,
text="对称图形",
font=(None, 20),
bg="#43CD80",
fg='black',
command=duidraw
)
btn1.place(x=10, y=10, width=200, height=50)
def duistar():
dui.star()
btn2 = tk.Button(
mw,
text='满天星',
font=(None, 20),
bg='#43CD80',
fg='black',
command=duistar
)
btn2.place(x=230, y=10, width=200, height=50)
def jie():
import pygame
import random
import time
# 2.初始化
pygame.init()
# 3.设置窗口
screen = pygame.display.set_mode((1080, 652))
pygame.display.set_caption('接住三级头') # 设置游戏名字
# 4,导入图片
ball = pygame.image.load('ball.png') # 加载图片
bg = pygame.image.load('bg1.jpg') # 加载图片
ban = pygame.image.load('ban.png')
ban_x = 100
ban_y = 592
ball_x = 100
ball_y = 0
score = 0
hp = 3
font = pygame.font.Font('ziti.ttf', 24)
# 事件
while True:
for event in pygame.event.get():
print(event)
if event.type == pygame.QUIT:
pygame.quit() # 退出
elif event.type == pygame.MOUSEMOTION:
ban_x, _ = event.pos
screen.fill((230, 230, 230))
# 判断生命值是否小于0,小于就退出
if hp <= 0:
pygame.quit()
if ban_x < ball_x < ban_x + 418 and ban_y < ball_y < ban_y + 60:
score = score + 1
ball_y = 0
ball_x = random.randint(0, 700)
# 判断没接到小球
if ball_y > 652:
hp = hp - 1
ball_y = 0
ball_x = random.randint(0, 700)
# ball_x = ball_x+1 # 修改横轴
ball_y = ball_y + score + 1
# pygame.draw.circle(screen,(100, 210, 250),(300,350),70) # 三原色 red green blue 0-255
screen.blit(bg, (0, 0))
screen.blit(ban, (ban_x, ban_y))
screen.blit(ball, (ball_x, ball_y))
# 在屏幕显示分数
imgtext = font.render('分数:%d' % score, True, (255, 255, 0))
screen.blit(imgtext, (0, 0))
# 在屏幕上显示生命值
hptext = font.render("生命值:%d" % hp, True, (255, 255, 0))
screen.blit(hptext, (900, 0))
pygame.display.update() # 4刷新
# time.sleep(0.1)
pygame.quit() # 退出游戏
btn3 = tk.Button(
mw,
text='接小球游戏',
font=(None, 20),
bg='#43CD80',
fg='black',
command=jie
)
btn3.place(x=10, y=70, width=200, height=50)
btn4 = tk.Button(
mw,
text='小鸟管道游戏',
font=(None, 20),
bg='#43CD80',
fg='black',
command=duistar
)
btn4.place(x=230, y=70, width=200, height=50)
def taiji():
dui.taiji()
btn5 = tk.Button(
mw,
text='太极',
font=(None, 20),
bg='#43CD80',
fg='black',
command= taiji
)
btn5.place(x=230, y=130, width=200, height=50)
def gameCai():
cai.main()
btn6 = tk.Button(
mw,
text='猜数字',
font=(None, 20),
bg='#43CD80',
fg='black',
command= gameCai
)
btn6.place(x=10, y=130, width=200, height=50)
btn7 = tk.Button(
mw,
text='猜拳',
font=(None, 20),
bg='#43CD80',
fg='black',
command= gameCai
)
btn7.place(x=10, y=190, width=200, height=50)
btn8 = tk.Button(
mw,
text='机器人对话',
font=(None, 20),
bg='#43CD80',
fg='black',
command= gameCai
)
btn8.place(x=230, y=190, width=200, height=50)
btn9 = tk.Button(
mw,
text='飞机大战',
font=(None, 20),
bg='#43CD80',
fg='black',
command= gameCai
)
btn9.place(x=230, y=260, width=200, height=50)
btn10 = tk.Button(
mw,
text='植物大战僵尸',
font=(None, 20),
bg='#43CD80',
fg='black',
command= gameCai
)
btn10.place(x=10, y=260, width=200, height=50)
btn11 = tk.Button(
mw,
text='连连看,五子棋,俄罗斯方块,贪吃蛇,迷宫,是男人就下一百层',
font=(None, 20),
bg='#43CD80',
fg='black',
command= gameCai
)
btn11.place(x=10, y=310, width=800, height=50)
mw.mainloop()
来源:CSDN
作者:少儿编程侯老师
链接:https://blog.csdn.net/houlaos/article/details/103796529