Esempio n. 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
Esempio n. 2
0
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
Esempio n. 3
0
File: hud.py Progetto: 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)