示例#1
0
    def __init__(self):
        Rectangle.__init__(self, width=15, height=50)
        self.center(x=10)
        
        self.set_speed(100)

        self.up_pressed = 0
        self.down_pressed = 0
示例#2
0
    def __init__(self, pos, size):
        cx, cy = trans(pos)
        w, h = scale(size)
        x = cx - (w / 2)
        y = cy - (h / 2)

        sq = Rectangle(width=w, height=h, color=(120, 50, 50))
        Stationary.__init__(self, sprite=sq)
        self.set_position((x, y))
        self.draw()
示例#3
0
    def start_level(self, ev=None, kwargs=None):
        self.state='level-load'
        self.level.reinit()
        self.cleanup()
        BTN_flip.set_callback(self.flip_piece)
        BTN_select.set_callback(self.select_piece)
        self.flip=0
        self.set_background(img=BG_level)
        x_offset=X_offset+(int((16-self.level.size[1])/2))*32
        y_offset=Y_offset+(int((16-self.level.size[0])/2))*32
        self.offset=(x_offset,y_offset)
        IMG_cat.set_position((10,10))

        board=Rectangle(width=(self.level.size[1]+1)*32,
                        height=(self.level.size[0]+1)*32, color=(112,112,112))
        self.boardbg=Stationary(sprite=board)
        self.boardbg.set_position((x_offset, y_offset))
        #self.mysprites.add(self.boardbg)
        line=0
        for i in self.level.pieces:
            col=0
            for j in i:
                if j.kind!='g':
                    j.set_position((col*32+x_offset-6,line*32+y_offset-6))
                    j.set_callback(self.move_piece,kwargs=j)
                    self.pieces.add(j)
                    self.piece_events.append(j.events)
                col+=1
            line+=1
        col+=1
        msg='You need '+str(self.level.wcount)+' white and '+str(self.level.bcount)+' black stones.'
        self.MSG_count=String(message=msg, fontSize=15, color=(250,250,250))
        self.MSG_count.set_position((40,5))
        self.MSG_count.draw()
        #self.sprites.add(self.pieces,1)
        self.events.add(self.piece_events)
        self.moving_stuff.append(self.level.pieces[0][0])
        self.moving=1
        #self.moving_stuff.append(self.pieces[0])

        #draw select border
        self.flip_coord=[(0,0)]
        SEL['top'].set_position((x_offset-1, y_offset-1))
        SEL['left'].set_position((x_offset-1, y_offset-1))
        SEL['bottom'].set_position((x_offset-1, y_offset+31))
        SEL['right'].set_position((x_offset+31, y_offset-1))
        self.mysprites.add(SEL.values())
        self.sprites.add(self.mysprites, 3)

        #generate & display preview
        size=3 #size of squares
        block=4 #size of the "block" -> border
        self.preview.empty()
        x_offset=657+((int((16-self.level.size[1])/2))*block)
        y_offset=222+((int((16-self.level.size[0])/2))*block)
        line=0
        for i in self.level.map:
            col=0
            for piece in i:
                tile=None
                if piece=='w':
                    tile=Stationary(sprite=Rectangle(width=size,height=size,color=(250,250,250)))
                elif piece=='b':
                    tile=Stationary(sprite=Rectangle(width=size,height=size,color=(0,0,0)))
                if tile:
                    tile.set_position((col*block+x_offset,line*block+y_offset))
                    self.preview.add(tile)
                col+=1
            line+=1
#        self.sprites.add(self.preview,5)
        self.step()
        self.state = 'level-play'
示例#4
0
 def move(self):
     self.set_vel()
     Rectangle.move(self) 
     self.onscreen(top=-5, bottom=-5, jail=1)