pythonV3V4/第18讲火眼金睛(一)/课堂成果/课后作业-五阶橙色矩阵.py
sairate 2cd753d3d9 feat(第7讲 字母卡牌): 实现记忆游戏并添加开始界面
- 新增 jiyi.py 文件,实现字母翻牌记忆游戏功能
- 添加 youxijiemian.py 文件,创建游戏开始界面
- 使用 turtle 和 tkinter 模块分别实现游戏和界面
- 支持选择不同难度的游戏模式
2025-06-29 09:06:19 +08:00

39 lines
731 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. 方块边长为40间距为5
2. 绘制五阶矩阵方块
3. 方块为橙色orange'''
# 导入pgzero库
import pgzrun
# 设置窗口
WIDTH = 725 # 窗口的宽度
HEIGHT = 725 # 窗口的高度
def draw():
for grid in grids:
screen.draw.filled_rect(Rect(grid['pos'], (side, side)), 'orange')
# 五阶矩阵
n = 5
# 提供边长和间距
side = 40
space = 5
# 创建列表grids后面存储每个方格信息
grids = []
for row in range(n): # 遍历行
for col in range(n): # 遍历列
info = {
'pos': (space + col * (side + space), space + row * (side + space)),
}
grids.append(info)
# 启动游戏
pgzrun.go()