Пример #1
0
    def __init__(self,name,image,frames,directions=1,timing=100,sound=None):
        GameObject.__init__(self)

        assert isinstance(image, Image)

        #if sound:
        #    assert(sound, Sound)


        self.name = name
        self.image = image
        self.images = None
        self.directions = directions
        self.frames = frames
        self.timing = timing

        # TODO: some checking to make sure inputs are the correct length
        if isinstance(self.frames, int):
            self.frames = tuple(range(0, self.frames))
        else:
            self.frames = tuple(self.frames)

        self.real_frames = len(set(self.frames))

        if isinstance(self.timing, int):
            self.timing = tuple([self.timing] * len(self.frames))
        else:
            self.timing = tuple(self.timing)
Пример #2
0
 def __init__(self, p, locked=False, blocks=None, *args, **kwargs):
     GameObject.__init__(self, 'door', location=p, char='+', *args, **kwargs)
     self.tileindex = (0,0)
     self.block_move = True
     self.block_sight = True
     self.blocks = blocks
     self.locked = locked
Пример #3
0
    def __init__(self, tmx, size, **kwargs):
        GameObject.__init__(self)

        self.default_image = generateDefaultImage(
            (tmx.tilewidth, tmx.tileheight))
        self.tmx = tmx
        self.setSize(size)
Пример #4
0
    def __init__(self,
                 name,
                 image,
                 frames,
                 directions=1,
                 timing=100,
                 sound=None):
        GameObject.__init__(self)

        assert isinstance(image, Image)

        #if sound:
        #    assert(sound, Sound)

        self.name = name
        self.image = image
        self.images = None
        self.directions = directions
        self.frames = frames
        self.timing = timing

        # TODO: some checking to make sure inputs are the correct length
        if isinstance(self.frames, int):
            self.frames = tuple(range(0, self.frames))
        else:
            self.frames = tuple(self.frames)

        self.real_frames = len(set(self.frames))

        if isinstance(self.timing, int):
            self.timing = tuple([self.timing] * len(self.frames))
        else:
            self.timing = tuple(self.timing)
Пример #5
0
    def __init__(self,name,image,frames,directions=1,timing=100,sound=None):
        GameObject.__init__(self)
        self.add(image)

        self.name = name
        self.image = image
        self.images = None
        self.directions = directions
        self.frames = frames
        self.timing = timing

        # TODO: some checking to make sure inputs are the correct length
        if isinstance(self.frames, int):
            self.frames = tuple(range(0, self.frames))
        else:
            self.frames = tuple(self.frames)

        self.real_frames = len(set(self.frames))

        if isinstance(self.timing, int):
            self.timing = tuple([self.timing] * len(self.frames))
        else:
            self.timing = tuple(self.timing)

        if (self.images is not None) and (not force):
            return
Пример #6
0
    def __init__(self, tmx, size, **kwargs):
        GameObject.__init__(self)

        self.default_image = generateDefaultImage((tmx.tilewidth,
                                                   tmx.tileheight))
        self.tmx = tmx
        self.setSize(size)
Пример #7
0
 def __init__(self, unlocks, *args, **kwargs):
     GameObject.__init__(self, 'key', char='[', *args, **kwargs)
     self.unlocks = unlocks
     self.facts.append(Solves(self, unlocks.blocks_fact.obj))
     for obj in self.world.player.wants:
         if obj.location_fact.obj == self.unlocks.blocks:
             # Todo: player doesn't *want* us until they know about us!
             self.facts.append(Wants(self.world.player, self))
Пример #8
0
    def __init__(self, filename, name, tile=None, size=None):
        GameObject.__init__(self)

        self.filename = filename
        self.name = name
        self.tile = tile
        self.size = size

        self.image = None
Пример #9
0
 def __init__(self, data):
     GameObject.__init__(self)
     self.rect = Rect(data.x, data.y, data.width, data.height)
     if hasattr(data, 'points'):
         self.points = data.points
     else:
         self.points = None
     self.name = data.name
     self.properties = data.properties
     self.entered = False
Пример #10
0
    def __init__(self, name, image, tile=None, size=None):
        GameObject.__init__(self)

        self.image = image
        self.name = name
        self.tile = tile
        self.size = size

        self.frames = [0]
        self.timing = [-1]
Пример #11
0
Файл: zone.py Проект: MacLeek/mh
    def __init__(self, data):
        GameObject.__init__(self)
        self.extent = Rect(data.x, data.y, data.width, data.height)
        if hasattr(data, 'points'):
            self.points = data.points
        else:
            self.points = None
        self.name = data.name
        self.properties = data.properties

        self.entered = False
Пример #12
0
Файл: ani.py Проект: bitcraft/mh
    def __init__(self, filename, size, name=None, directions=1):
        GameObject.__init__(self)

        self.filename = filename
        self.size = size

        if name == None:
            self.name = filename

        self.directions = directions  # number of directions for animation
        self.frames = ([],) * directions
Пример #13
0
    def __init__(self, name, description='', location=None, *args, **kwargs):
        self.map_memory = {}

        GameObject.__init__(self, name=name, description=description, location=location, *args, **kwargs)

        self.tiletype = 2
        self.knowledge = set()
        self.wants = []
        self.relationships = None
        self.hp = 1
        self.block_move = True
Пример #14
0
    def __init__(self, name, image):
        GameObject.__init__(self)

        try:
            assert isinstance(image, Image) or isinstance(image, ImageTile)
        except AssertionError:
            print name, image
            raise

        self.image = image
        self.name = name
        self.frames = [0]
        self.timing = [-1]
Пример #15
0
Файл: env.py Проект: bitcraft/mh
    def __init__(self):
        GameObject.__init__(self)
        self.exits    = {}
        self.geometry = {}       # geometry (for collisions) of each layer
        self.objects = {}        # position and size of objects in 3d space
        self.orientations = {}   # records where the object is facing
        self.extent = None       # absolute boundries of the area
        self.joins = []
        self._oldPositions = {}  # used in collision handling

        self.messages = []

        self.time = 0
Пример #16
0
    def __init__(self, name, image):
        GameObject.__init__(self)

        try:
            assert isinstance(image, Image) or isinstance(image, ImageTile)
        except AssertionError:
            print name, image
            raise

        self.image = image
        self.name = name
        self.frames = [0]
        self.timing = [-1]
Пример #17
0
 def __init__(self):
     GameObject.__init__(self)
     self.default      = None
     self.callback     = None    # called when animation finishes
     self.curImage     = None    # cached for drawing ops
     self.curFrame     = None    # current frame number
     self.curAnimation = None
     self.animations   = {}
     self.loop_frame = 0
     self.looped     = 0
     self.loop       = -1
     self.timer      = 0
     self._prevAngle = None
     self._prevFrame = None
     self._is_paused = False
Пример #18
0
    def __init__(self, animations):
        GameObject.__init__(self)
        self.default      = None
        self.curImage     = None    # cached for drawing ops
        self.curFrame     = None    # current frame number
        self.curAnimation = None
        self.animations   = {}
        self.looped     = 0
        self.loop       = -1
        self.timer      = 0.0
        self.ttl = 0
        self._prevAngle = None

        for animation in animations:
            self.add(animation)
            self.animations[animation.name] = animation

        self.setDefault(animations[0])
        self.play()
Пример #19
0
    def __init__(self, filename, name, frames, directions=1, timing=None):
        GameObject.__init__(self)

        self.filename = filename
        self.name = name
        self.order = None

        if isinstance(frames, int):
            self.frames = frames
            self.real_frames = frames

        elif isinstance(frames, list):
            self.frames = len(frames)
            self.real_frames = max(frames) + 1
            self.order = frames

        self.directions = directions
        self.timing = timing
        self.images = []
Пример #20
0
 def __init_(self):
     GameObject.__init__(
         self,
         components=[
             components.CPosition(),
             components.CPlayerMovement(),
             components.CActorAnimParser(self.pathLists),
         ])
     
     # Create a flipped copy of LEFT_WALK as our RIGHT_WALK animation
     # -- this will be changed when we have more walking animations.
     components.CActorAnimParser.animations[
         enums.ActorAnim.WALK_RIGHT
         ] = tools.AnimCreator.createHorizontallyFlippedAnimation(
                 components.CActorAnimParser.animations[WALK_LEFT])
     # do the same for STANDING_RIGHT with STANDING_LEFT
     components.CActorAnimParser.animations[
         enums.ActorAnim.STANDING_RIGHT
         ] = tools.AnimCreator.createHorizontallyFlippedAnimation(
                 components.CActorAnimParser.animations[
                     STANDING_RIGHT])
Пример #21
0
    def __init__(self, animations, axis_offset=(0, 0)):
        GameObject.__init__(self)
        self.axis_offset = Vec2d(axis_offset)

        self.curImage = None  # cached for drawing ops
        self.curFrame = None  # current frame number
        self.curAnimation = None
        self.animations = {}
        self.looped = 0
        self.timer = 0.0
        self.ttl = 0
        self.flip = 0
        self.speed_mod = 1.0
        self._prevAngle = None
        self._changed = True
        self.axis = Vec2d(0, 0)

        for animation in animations:
            self.add(animation)
            self.animations[animation.name] = animation

        self.play(self.animations.keys()[0])
Пример #22
0
    def __init__(self, animations, axis_offset=(0,0)):
        GameObject.__init__(self)
        self.axis_offset = Vec2d(axis_offset)

        self.curImage     = None    # cached for drawing ops
        self.curFrame     = None    # current frame number
        self.curAnimation = None
        self.animations   = {}
        self.looped     = 0
        self.timer      = 0.0
        self.ttl = 0
        self.flip = 0
        self.speed_mod = 1.0
        self._prevAngle = None
        self._changed = True
        self.axis = Vec2d(0,0)

        for animation in animations:
            self.add(animation)
            self.animations[animation.name] = animation

        self.play(self.animations.keys()[0])
Пример #23
0
Файл: env.py Проект: bitcraft/mh
 def __init__(self):
     GameObject.__init__(self)