Example #1
0
    def draw_editor(self):
        self.game.screen_objects_to_draw.append(self.game.editor)
        trig = self.game.editor.trigger_editor.drop_lists['triggers'].selected
        if not trig is None:
            zone = self.game.editor.trigger_editor.drop_lists['zones'].selected
            for z in trig.zones:
                r = primitives.RectPrimitive(rect=z, color=(135, 206, 250, 50))
                if not zone is None:
                    if z == zone:
                        r = primitives.RectPrimitive(rect=z,
                                                     color=(65, 105, 225, 100))

                self.game.world_objects_to_draw.append(r)
Example #2
0
    def draw_torch(self):
        # TODO: do this in a sane/clever way
        ppos = (self.game.players['player1'].coord[0] +
                self.game.players['player1'].dimensions[0] // 2,
                self.game.players['player1'].coord[1] +
                self.game.players['player1'].dimensions[1] // 2)

        hole = rect.Rect(
            self.game.camera.apply_camera((ppos[0] - self.light_size[0] // 2,
                                           ppos[1] - self.light_size[1] // 2)),
            self.light_size)

        hole.width *= self.game.camera.zoom
        hole.height *= self.game.camera.zoom

        self.light.scale_x = (200 /
                              self.light.image.height) * self.game.camera.zoom
        self.light.scale_y = (200 /
                              self.light.image.height) * self.game.camera.zoom

        self.light.position = hole.bottomleft

        self.game.screen_objects_to_draw.append(
            primitives.RectPrimitive(x=0,
                                     y=0,
                                     width=hole.right,
                                     height=hole.bottom,
                                     color=(0, 0, 0, 255)))

        self.game.screen_objects_to_draw.append(
            primitives.RectPrimitive(x=hole.right,
                                     y=0,
                                     width=window.width - hole.right,
                                     height=hole.top,
                                     color=(0, 0, 0, 255)))

        self.game.screen_objects_to_draw.append(
            primitives.RectPrimitive(x=hole.left,
                                     y=hole.top,
                                     width=window.width - hole.left,
                                     height=window.height - hole.top,
                                     color=(0, 0, 0, 255)))

        self.game.screen_objects_to_draw.append(
            primitives.RectPrimitive(x=0,
                                     y=hole.bottom,
                                     width=hole.left,
                                     height=window.height - hole.bottom,
                                     color=(0, 0, 0, 255)))

        self.game.screen_objects_to_draw.append(self.light)
Example #3
0
    def function(self, harvester):
        obj = self.object
        obj.fear = 0
        obj.fainted = True

        sprite = primitives.RectPrimitive(width=10,
                                          height=10,
                                          color=(120, 0, 0, 255))
        obj.flair['fear_harvested'] = (sprite, (-5, obj.dimensions[1] + 5))
Example #4
0
    def func(interactee, interacter, options=None):
        for target in targets:
            target.fear = 0
            target.fainted = True

            sprite = primitives.RectPrimitive(width=10,
                                              height=10,
                                              color=(120, 0, 0, 255))
            target.flair['fear_harvested'] = (sprite,
                                              (-5, target.dimensions[1] + 5))
Example #5
0
 def draw_fear_bar(self):
     nplayers = len(self.game.players)
     self.game.screen_objects_to_draw.append(self.fear_text)
     w = window.width - self.fear_text.content_width
     h = 32
     for i, p in enumerate(self.game.players.itervalues()):
         sp = primitives.RectPrimitive(x=self.fear_text.content_width,
                                       y=h * i,
                                       width=w * (p.fear / MAX_FEAR),
                                       height=h,
                                       color=(255, 0, 0, 255))
         self.game.screen_objects_to_draw.append(sp)
Example #6
0
    def __init__(self, game, message, on_complete_fun):
        self.game = game
        self.on_complete_fun = on_complete_fun
        self.message = message

        self.background = primitives.RectPrimitive(x=0,
                                                   y=0,
                                                   width=1280,
                                                   height=200,
                                                   color=(70, 80, 65, 200))

        self.text_layout = None
        self._update_text()

        self.wait_up = False
Example #7
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
Example #8
0
    def func(interactee, interacter, option=None):
        sprite = primitives.RectPrimitive(width=2,
                                          height=24,
                                          color=(139, 69, 19, 255))

        interacter.flair['torch'] = (sprite, (10, 0))