MCPcopy Create free account
hub / github.com/alg-bug-engineer/Cheesy-AI-Fish / draw_grid

Function draw_grid

v1.py:103–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101
102# 绘制网格函数
103def draw_grid():
104 grid_pen.clear()
105
106 # 设置网格边界
107 left = -GRID_WIDTH * GRID_SIZE // 2
108 right = GRID_WIDTH * GRID_SIZE // 2
109 top = GAME_HEIGHT // 2 - 50
110 bottom = top - GRID_HEIGHT * GRID_SIZE
111
112 # 绘制垂直线
113 for x in range(-GRID_WIDTH // 2, GRID_WIDTH // 2 + 1):
114 grid_pen.penup()
115 grid_pen.goto(x * GRID_SIZE, bottom)
116 grid_pen.pendown()
117 grid_pen.goto(x * GRID_SIZE, top)
118
119 # 绘制水平线
120 for y in range(GRID_HEIGHT + 1):
121 y_pos = top - y * GRID_SIZE
122 grid_pen.penup()
123 grid_pen.goto(left, y_pos)
124 grid_pen.pendown()
125 grid_pen.goto(right, y_pos)
126
127# 像素坐标转网格坐标
128def pixel_to_grid(x, y):

Callers 1

init_gameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected