class draw_maze(screen):NameError:name 'screen' is not defin

冉西梁2022-10-04 11:39:541条回答

class draw_maze(screen):NameError:name 'screen' is not defined
'''
create on 2013 831
@author XGong
'''
import pygame
from pygame.locals import *
from random import randint,choice
global screen_size
screen_size=800
global r_color
r_color=(0,0,0)
class room(object):
def __init__(self,x,y):
self.x=x
self.y=y
self.wells=[True,True,True,True]
self.size=10
#self.visited=False
def visited(self):
return False
class draw_maze(screen):
room_list= [[0 for j in range(0,600)] for i in range(600)]
for i in range(0,600):
for j in range(0,600):
room_list[i]=room(i,j)
draw_room(screen,room_list[i][j],r_color)
class draw_room(screen,room,r_color):
n=0
for well in room.wells:
x=room.x
y=room.y
size=room.size
n=n+1
if well and n==1:
python.draw.line(screen,r_color,(x,y-size),(x,y))
if well and n==2:
python.draw.line(screen,r_color,(x,y),(x+size,y))
if well and n==3:
python.draw.line(screen,r_color,(x,y),(x,y+size))
if well and n==4:
python.draw.line(screen,r_color,(x-size,y),(x,y))
pygame.init()
screen=pygame.display.set_mode([screen_size,600])
pygame.display.set_caption("MAZE GAME")
screen.fill([255,255,0])
draw_maze(screen)
done=False
while done==False:
for event in pygame.event.get():
if event.type==QUIT:
done=True
pygame.display.flip()
pygame.quit()

已提交,审核后显示!提交回复

共1条回复
jahoya 共回答了17个问题 | 采纳率82.4%
__init__(self,screen)
1年前

相关推荐