board_x=0
board_y=0
road_w=0
road_map=[]
def setup():
size(800,600)
make_board(13,9,46)
init_maze()
def draw():
draw_maze()
def make_board(x,y,w):
global board_x,board_y,road_w,road_map
board_x=x
board_y=y
road_w=w
road_map=[[0]*board_y]*board_x
def init_maze():
for x in range(board_x):
for y in range(board_y):
road_map[x][y]=1
for x in range(3,board_x-3):
for y in range(3,board_y-3):
road_map[x][y]=0
road_map[2][3]=2
road_map[board_x-3][board_y-4]=3
print(road_map)
def draw_maze():
noStroke()
background(100)
for x in range(2,board_x-3):
for y in range(2,board_y-3):
if road_map[x][y]==0:
fill(100,0,0)
elif road_map[x][y]==1:
fill(0,200,0)
elif road_map[x][y]==2:
fill(200,200,0)
elif road_map[x][y]==3:
fill(200,0,200)
rect(road_wx,road_wy,road_w,road_w)
回答1件
あなたの回答
tips
プレビュー