示例#1
0
    def __init__(self, game):
        self.game = game

        self.field = sprite.Sprite(
            pyglet.image.load(os.path.join(SPRITES_DIR,
                                           'field.png')).get_texture())
        self.field.opacity = options['VOF_opacity']
        self.field.scale_x = window.width / self.field.image.width
        self.field.scale_y = window.height / self.field.image.height

        self.light = sprite.Sprite(
            pyglet.image.load(os.path.join(SPRITES_DIR,
                                           'light.png')).get_texture())
        self.light.scale_x = self.light.scale_y = 200 / self.light.image.height
        self.light_size = (self.light.width, self.light.height)

        self.fear_text = text.new(FONT, 20, u'FEAR')

        self.map_texture = {}
        self.tile_sprite = {}

        self.camera_group = camera.CameraGroup(self.game.camera)

        options.push_handlers(self)
        window.push_handlers(self)
        self.game.push_handlers(self)
示例#2
0
    def __init__(self, game, button_size):
        super(MainMenu, self).__init__(game, button_size)

        self.controls['main_game'] = MenuButton(order=(0, 0),
                                                function=self.go_to_main_game,
                                                text=u'Start Game',
                                                batch=self.batch)
        self.controls['credits'] = MenuButton(order=(1, 0),
                                              function=self.go_to_credits,
                                              text=u'Credits',
                                              batch=self.batch)
        self.controls['options'] = MenuButton(order=(2, 0),
                                              function=self.go_to_options,
                                              text=u'Options',
                                              batch=self.batch)
        self.controls['quit'] = MenuButton(order=(3, 0),
                                           function=self.game.quit_game,
                                           text=u'Quit',
                                           batch=self.batch)

        self.arrange_buttons()

        t = 'TODO:\n'
        for l in self.game.TODO:
            t += ' - ' + l + '\n'
        self.todo_sprite = text.new(text=t,
                                    font_size=10,
                                    width=1000,
                                    batch=self.batch)
        self.todo_sprite.x, self.todo_sprite.y = (400, 200)
示例#3
0
 def _update_text(self):
     self.text_layout = text.new(FONT,
                                 font_size=26,
                                 text=self.message,
                                 width=1180,
                                 height=175)
     self.text_layout.content_valign = 'top'
     self.text_layout.x = 50
     self.text_layout.y = 0
示例#4
0
def draw_info_sheet(stats):
    if not stats:
        return None
    font_size = 20
    #dim = w, h = (GAME_WIDTH - LEVEL_WIDTH, int((GAME_WIDTH - LEVEL_WIDTH) / 1.6))

    x = 0
    y = 0

    sprites = []

    h = 200.0
    w = h / 1.6
    dim = (w, h)

    border = 8
    #fill_background(surf, border) # TODO PYGLET

    # draw character image
    im = textures.get(stats['image_name'])
    im_sprite = sprite.Sprite(im)
    im_sprite.scale_x = w / im_sprite.width
    im_sprite.scale_y = h / im_sprite.height


    # draw name/age and text boxes
    name_text = text.new('comic sans', font_size, u'Name: ' + stats['name'])
    age_text = text.new('comic sans', font_size, u'Age: ' + str(stats['age']))


    # age_text.x = name_text.x
    # age_text.y = name_text.y - name_text.content_height

    # draw background
    background_sprite = primitives.RectPrimitive(width=w + name_text.content_width + border * 2,
                                                 height=h + 2 * border,  # - name_text.content_height - age_text.content_height - 3 * border
                                                 color=GREY)

    sprites.append(background_sprite)
    sprites.append(im_sprite)
    sprites.append(name_text)
    sprites.append(age_text)

    return sprites
示例#5
0
    def __init__(self, game, button_size):
        super(MainMenu, self).__init__(game, button_size)

        self.controls['main_game'] = MenuButton(order=(0, 0), function=self.go_to_main_game, text=u'Start Game',
                                                batch=self.batch)
        self.controls['credits'] = MenuButton(order=(1, 0), function=self.go_to_credits, text=u'Credits',
                                              batch=self.batch)
        self.controls['options'] = MenuButton(order=(2, 0), function=self.go_to_options, text=u'Options',
                                              batch=self.batch)
        self.controls['quit'] = MenuButton(order=(3, 0), function=self.game.quit_game, text=u'Quit',
                                           batch=self.batch)

        self.arrange_buttons()

        t = 'TODO:\n'
        for l in self.game.TODO:
            t += ' - ' + l + '\n'
        self.todo_sprite = text.new(text=t, font_size=10, width=1000, batch=self.batch)
        self.todo_sprite.x, self.todo_sprite.y = (400, 200)
示例#6
0
    def __init__(self, game):
        self.game = game

        self.field = sprite.Sprite(pyglet.image.load(os.path.join(SPRITES_DIR, 'field.png')).get_texture())
        self.field.opacity = options['VOF_opacity']
        self.field.scale_x = window.width / self.field.image.width
        self.field.scale_y = window.height / self.field.image.height

        self.light = sprite.Sprite(pyglet.image.load(os.path.join(SPRITES_DIR, 'light.png')).get_texture())
        self.light.scale_x = self.light.scale_y = 200 / self.light.image.height
        self.light_size = (self.light.width, self.light.height)

        self.fear_text = text.new(FONT, 20, u'FEAR')

        self.map_texture = {}
        self.tile_sprite = {}

        self.camera_group = camera.CameraGroup(self.game.camera)

        options.push_handlers(self)
        window.push_handlers(self)
        self.game.push_handlers(self)
示例#7
0
 def _update_text(self):
     self.text_layout = text.new(FONT, font_size=26, text=self.message, width=1180, height=175)
     self.text_layout.content_valign = 'top'
     self.text_layout.x = 50
     self.text_layout.y = 0