Пример #1
0
def create_item():
    item_display_list.insert(INSERT,
                             "For a player of %s level:\n" %
                             player_level_scale.get())
    item = create()
    item_display_list.insert(INSERT,"%s \n" % item['name'])
    return 1
Пример #2
0
    def projectile_fire(self):
        if not self.firing:
            self.firing = True

            a = math.radians(self.angle[self.player])
            f = self.force[self.player] * 5
            force = Vector2f(math.cos(a), math.sin(a)) * f

            if self.player == 1:
                force.x *= -1

            p = Game.proj_spawn[self.player]
            self.catapults[self.player].set_loaded(False)
            self.projectile = item.create('projectile', name='projectile', x=p.x, y=p.y, flip=self.player==0)
            self.projectile.impulse(force, 0.1)
Пример #3
0
    def put_item(self):
        if len(self.inventory) == 0:
            return
        # Are we standing on something other than floor?
        obj = self.inventory[0][1:]
        target = self.items.get(self.player.pos, None)
        if target is None:
            action = "put %s" % obj
        else:
            action = "put %s on %s" % (obj, target.name)

        self.perform_action(action)

        # Do we still have the item?
        self.render_inventory()
        if ("@" + obj) not in self.inventory:
            # Remove leading "@"
            i = item.create(self, obj)
            i.drop(self.player.pos)
Пример #4
0
    def place_monsters(self, m):
        """Place monsters on the map."""

        self.monsters = {}
        self.items = {}
        for y, line in enumerate(m):
            for x, tile in enumerate(line):
                urls = self.map_key[tile]
                if urls:
                    for url in urls[1:]:
                        kind, name = url.split(".", 1)
                        if kind == "monster":
                            m = monster.create(self, (x, y), name)
                            if name == 'player':
                                self.player = m
                            m.place((x, y))
                        elif kind == "item":
                            i = item.create(self, name)
                            i.place((x, y))
                        elif kind == "status":
                            self.monsters[(x, y)].add_status(name)
Пример #5
0
    def use_exit(self, pos, direction):
        self.pos = pos
        self.direction = direction

        self.perform_action("leave %s" % direction)

        newroom = self.world.room_of(self.discourse.spin['focalizer'])
        if self.world.prevents_sight(self.discourse.spin['focalizer'], str(newroom)):
            print "Can't see inside this room."
            self.create_room(str(newroom), [0,0], [0,0], False)
        else:
            self.create_room(str(newroom), [0,0], [0,0], True)
            for obj in newroom.children:
                if obj[0] == "part_of":
                    room = self.rooms[str(newroom)]
                    mid = room[int(len(room) / 2)]
                    (mid_x, mid_y) = mid
                    # Remove leading "@"
                    i = item.create(self, obj[1][1:])
                    i.place((mid_x, mid_y))

        self.display.draw_map(self)
        self.display.add_sprite(*(self.monsters.values()))
        self.display.add_sprite(*(self.items.values()))
Пример #6
0
 def load_objects(self, src):
     for obj in src:
         x = item.create(obj['type'], **obj)
         if x.name != '':
             self.named_objects[x.name] = x
         yield x
Пример #7
0
 def drop(self, item_name="goo", i=None):
     """Make the monster drop a specified item"""
     if i is None:
         i = item.create(self.level, item_name)
     i.drop(self.pos)