예제 #1
0
    def __init__(self):
        # Always call super in the constructor:
        super( ChessBoard, self ).__init__()

        the_board = [6, 4, 2, 0, 5, 7, 1, 3] # 8x8 board
        colors = [(255,0,0), (0,0,0)]
        
        n = len(the_board)         # This is an NxN chess board.
        sq_sz = windowWidth // n    # sq_sz is length of a square.
        
        # Build layers for board squares
        for row in range(n):           # Draw each row of the board.
            c_indx = row % 2           # Alternate starting color
            for col in range(n):       # Run through cols drawing squares
                l = ColorLayer(
                   colors[c_indx][0],
                   colors[c_indx][1],
                   colors[c_indx][2],
                   255,
                   width=sq_sz, height=sq_sz)
                l.position = (col*sq_sz, row*sq_sz)
                self.add( l )

                # Now flip the color index for the next square
                c_indx = (c_indx + 1) % 2
예제 #2
0
    def __init__(self, skin_red, skin_green, skin_blue, clothes_red, clothes_green, clothes_blue):
        
        super(CharacterBody, self).__init__()
        
        from cocos.layer.util_layers import ColorLayer
        #red, green, blue = self.config['player']['color']
        body_width = 48
        body_height = 16
        body = ColorLayer(clothes_red, clothes_green, clothes_blue, 255, body_width, body_height)
        half_body_width = body_width / 2
        half_body_height = body_height / 2
        body.position = -half_body_width, -half_body_height
        
        self.add(body)
        
        head_size = 18
        half_head_size = head_size / 2
        head = ColorLayer(skin_red, skin_green, skin_blue, 255, head_size, head_size)
        head.position = -half_head_size, -half_head_size
        
        self.body_width = body_width
        self.body_height = body_height
        self.head_size = head_size
        
        self.skin_red = skin_red
        self.skin_green = skin_green
        self.skin_blue = skin_blue
        
        self.clothes_red = clothes_red
        self.clothes_green = clothes_green
        self.clothes_blue = clothes_blue
        
        self.add(head)

        self.anchor = 0, 0
예제 #3
0
 def __init__(self):
     super().__init__()
     x, y = director.get_window_size()
     title = text.Label("GAME OVER", (x/2, y/2), anchor_x="center", \
                        anchor_y="center", font_size=52, color=(255,255,0,255))
     clayer = ColorLayer(0, 128, 128, 128)
     clayer.add(title)
     self.add(clayer)
예제 #4
0
    def init_background(self):
        color = self.cfg['background.color']
        height = self.cfg['background.height']
        bg_y = self.cfg['background.y']

        r, g, b, a = color
        bg = ColorLayer(r, g, b, a, height=height)
        if bg_y is not None:
            bg.y = bg_y
        self.add(bg, z=-1)
예제 #5
0
 def __init__(self, *args):
     from cocos.layer.util_layers import ColorLayer
     
     super(Zombie, self).__init__(0, 255, 0, *args)
     arm_width = 10
     arm_height = 2 * arm_width
     
     left_arm = ColorLayer(self.skin_red, self.skin_green, self.skin_blue, 255, arm_width, arm_height)
     left_arm.position = -self.body_width/2, self.head_size/2
     
     right_arm = ColorLayer(self.skin_red, self.skin_green, self.skin_blue, 255, arm_width, arm_height)
     right_arm.position = self.body_width/2 - arm_width, self.head_size/2
     
     self.add(left_arm)
     self.add(right_arm)
예제 #6
0
 def __init__(self, *args):
     from cocos.layer.util_layers import ColorLayer
     super(Player, self).__init__(*args)
     
     hand_size = 10
     half_hand_size = hand_size / 2
     
     left_hand = ColorLayer(self.skin_red, self.skin_green, self.skin_blue, 255, hand_size, hand_size)
     left_hand.position = -self.body_width/2, self.head_size/2
     
     right_hand = ColorLayer(self.skin_red, self.skin_green, self.skin_blue, 255, hand_size, hand_size)
     right_hand.position = self.body_width/2 - hand_size, self.head_size/2
     
     self.add(left_hand)
     self.add(right_hand)
예제 #7
0
파일: hud.py 프로젝트: Intey/pygamed
    def __init__(self, player, width, height):
        Layer.__init__(self)
        self.width = width
        self.height = height
        self.player = player.domain
        msg = Label(
            'health %s, sticks: %s' %
            (self.player.health, self.player._inventory.get('sticks')),
            font_name='somebitch',
            anchor_x='left',
            anchor_y='bottom',  # really - it's top of screen
            width=width,
            height=25,
            x=5,
            y=-3,
        )

        color = (73, 106, 44, 255)
        hudBackground = ColorLayer(*color, width=self.width, height=25)
        hudBackground.position = (0, 0)
        self.add(hudBackground)
        self.add(msg, name='msg')
        self.schedule(self.update)
예제 #8
0
파일: game_menu.py 프로젝트: SMajev/blobjob
def pause_menu():
    w, h = director.window.width, director.window.height
    texture = pyglet.image.Texture.create_for_size(GL_TEXTURE_2D, w, h,
                                                   GL_RGBA)
    texture.blit_into(pyglet.image.get_buffer_manager().get_color_buffer(), 0,
                      0, 0)
    scene = PauseMenuScene()
    bg = Sprite(texture.get_region(0, 0, w, h))
    bg.x = w / 2
    bg.y = h / 2
    scene.add(bg, z=-999)
    overlay = ColorLayer(25, 25, 25, 205)
    scene.add(overlay)
    menu = PauseMenu()
    scene.add(menu)
    return scene