sairate c4d32e8092 feat(第7讲 字母卡牌): 实现记忆游戏并添加开始界面
- 新增 jiyi.py 文件,实现字母翻牌记忆游戏功能
- 添加 youxijiemian.py 文件,创建游戏开始界面
- 使用 turtle 和 tkinter 模块分别实现游戏和界面
- 支持选择不同难度的游戏模式
2025-06-28 14:27:31 +08:00

48 lines
851 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''小城漫步
要求如下:
1. ‘白日街景’、‘夜晚街景’两图滚动出现
2. 走1走2两图实现博克斯走路动效
3. 按下键盘右键,背景滚动'''
import pgzrun
from pgzhelper import *
WIDTH = 960
HEIGHT = 720
# 创建背景角色
bg1 = Actor('白日街景', topleft=(0, 0))
bg2 = Actor('夜晚街景', topleft=(960, 0))
# 创建博克斯角色
people = Actor('走1', (200, 500))
people.images = ['走1', '走2']
# 初始化速度
speed = 10
def draw():
bg1.draw()
bg2.draw()
people.draw()
def update():
if keyboard.right:
bg1.x -= speed
bg2.x -= speed
if bg1.right <= 0:
bg1.left = bg2.right
if bg2.right <= 0:
bg2.left = bg1.right
def change_image():
people.next_image()
clock.schedule_interval(change_image, 0.5)
pgzrun.go()