sp2

来源:互联网 发布:有趣的品牌 知乎 编辑:程序博客网 时间:2024/05/22 09:03
class Box:
    def __init__(self,x,y,width=BOXWIDTH,height=BOXHEIGHT,image=None):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.image = image
        self.surf = Surface((self.width,self.height))
        self.surf_cover = Surface((self.width,self.height))
        self.color = BOXCOLOR
        self.surf.fill(self.color)
        self.surf_cover.fill(COVERCOLOR)
        self.is_revealed = False
        self.cover_color = COVERCOLOR
        self.boxx = 0
        self.boxy = 0
        self.is_blank = False
        self.num = 0
    def set_cord(self,x,y):
        self.x = x
        self.y = y
   
    def set_image(self,image):
        self.image = image
   
    def set_surf(self,surf):
        self.surf = surf
    def set_surf_color(self,color):
        self.surf.fill(color)
   
    def can_move(self):
        global BLANK
        print "BLANK:",BLANK,self.boxx,self.boxy
        if self.boxx == BLANK[0] + 1 and self.boxy == BLANK[1]:
            return  LEFT
        elif self.boxx == BLANK[0] - 1 and self.boxy == BLANK[1]:
            return  RIGHT
        elif self.boxx == BLANK[0]  and self.boxy == BLANK[1] - 1:
            return  DOWN
        elif self.boxx == BLANK[0]  and self.boxy == BLANK[1] + 1:
            return  UP
        else:
            return False
       
    def move_to(self,move):
        global BLANK
        self.is_blank = True
        BLANK = (self.boxx,self.boxy)
原创粉丝点击