コード例 #1
0
ファイル: character.py プロジェクト: andy-davies/platformgame
 def __init__(self, standing_image, walk_left_images, walk_right_images):
     Movable.__init__(self, standing_image)
     self.walk_right_images = walk_right_images
     self.walk_left_images = walk_left_images
     self.standing_image = standing_image
     self.is_player = False
     self.dead = False
コード例 #2
0
ファイル: big.py プロジェクト: nickthecoder/itchy
    def tick(self) :

        Movable.tick(self)

        for part in self.parts :
            if part.square :
                part.tick()
コード例 #3
0
ファイル: ball.py プロジェクト: saltire/roverchip
    def __init__(self, level, pos):
        Movable.__init__(self, level, pos)
        
        self.tile = 0, 1
        self.speed = 100

        self.moves_continuously = True
コード例 #4
0
ファイル: cart.py プロジェクト: saltire/roverchip
 def __init__(self, level, pos):
     Movable.__init__(self, level, pos)
     
     self.tile = 1, 1
     self.speed = 100
     
     self.is_sinkable = False
     self.moves_continuously = True
コード例 #5
0
ファイル: mirror.py プロジェクト: saltire/roverchip
 def __init__(self, level, pos, facing):
     Movable.__init__(self, level, pos, facing)
     
     self.tile = 7, 1
     
     # facing = diagonal dir the mirror is facing: 0-3, clockwise from northeast
     # out_dirs = the two cardinal dirs the mirror is facing
     self.out_dirs = facing, (facing + 1) % 4
コード例 #6
0
ファイル: bee.py プロジェクト: nickthecoder/itchy
    def tick( self ) :

        Movable.tick(self)

        if self.pause :
            return

        if not self.isMoving() :
        
            if self.logic == 1 or self.logic == 2 :
                self.moveRound()
            else :
                self.moveRandom()
コード例 #7
0
ファイル: plane.py プロジェクト: nickthecoder/itchy
    def tick(self) :

        Movable.tick(self)

        # Check that dummy hasn't been removed from the grid (which will happen if my tick caused it to die)
        if self.dummy.square :
            self.dummy.tick()

        if self.square and not self.isMoving() :

            forward = self.look( self.direction, 0 )

            if forward.hasTag(self.squash) :
                self.move(self.direction, 0)
コード例 #8
0
ファイル: part.py プロジェクト: nickthecoder/itchy
    def __init__( self, parent, dx, dy ) :
        Movable.__init__(self)

        self.parent = parent
        self.offsetx = dx
        self.offsety = dy

        self.speed = parent.speed

        self.parent.parts.append( self )

        x = parent.square.x + dx
        y = parent.square.y + dy
        self.square = parent.square.grid.getSquare(x, y)
        self.square.occupant = self
コード例 #9
0
ファイル: character.py プロジェクト: andy-davies/platformgame
    def update(self):

        if self.dead:
            return

        # Called every frame
        self.check_for_key_press()

        rc = Movable.update(self)
        if rc == MovableRC.FELL_OFF_SCREEN:
            self.die()
        elif not rc == MovableRC.STOP_ALL:
            self.animate()
コード例 #10
0
ファイル: character.py プロジェクト: andy-davies/platformgame
 def act_on_collision(self, tile):
     log.debug(
         "Collided with {}.  y_speed = {}.  Tile attributes = {}".format(
             tile.tile_id, self.y_speed, tile.attrs))
     self.rotating = False
     if tile.attrs & TileAttr.DISABLE_ON_ROTATE and not tile.rotation_enabled:
         return Movable.act_on_collision(self, tile)
     if tile.attrs & TileAttr.KILL:
         self.die()
         return MovableRC.STOP_ALL
     if tile.tile_id == "EXIT":
         print("Posting exit event")
         self.scene = None
         pygame.event.post(pygame.event.Event(config.REACHED_EXIT_EVENT_ID))
         return MovableRC.STOP_ALL
     if tile.tile_id == "SPIN":
         self.y_speed = 0
         self.last_collided = None  # Make sure we don't hit spin again after it's been deleted
         self.scene.spin_activated(tile)
         return MovableRC.STOP
     if self.y_speed > config.SPRING_ACTIVE_SPEED and tile.attrs & TileAttr.SPRING and tile.state == 0:
         log.info("Hit SPRING_UP.  y_speed = {}".format(self.y_speed))
         self.scene.animate_spring(tile)
         self.y_speed = min(self.y_speed, 10)
         self.falling = True
         return MovableRC.STOP_ALL
     elif self.y_speed > config.SPRING_ACTIVE_SPEED and tile.attrs & TileAttr.SPRING and tile.state == 1:
         log.info("Hit SPRING_DOWN")
         self.scene.animate_spring(tile)
         # ToDo.  This is a nasty hack to avoid the tile springing back and overlapping the sprite.
         self.rect.top -= int(config.TILE_SIZE_PX) / 2
         self.y_speed = -1 * config.SPRING_JUMP_SPEED
         return MovableRC.STOP_ALL
     elif self.y_speed > config.SPRING_ACTIVE_SPEED and tile.attrs & TileAttr.BUTTON:
         log.info("Hit button.  y_speed = {}".format(self.y_speed))
         self.scene.hit_button(tile)
         self.y_speed = min(self.y_speed, 10)
         return MovableRC.CONTINUE
     return Movable.act_on_collision(self, tile)
コード例 #11
0
 def __init__(self, x, y, dx, dy, rotation, world_width, world_height):
     Movable.__init__(self, x, y, dx, dy, world_width, world_height)
     self.mRotation = rotation
コード例 #12
0
ファイル: plane.py プロジェクト: nickthecoder/itchy
 def move(self, dx, dy,speed=None) :
     Movable.move(self,dx,dy,speed)
     # Check if dummy is still on the grid (it won't be if my movement caused us both to die).
     if self.dummy.square :
         self.dummy.move(dx, dy, speed)
コード例 #13
0
ファイル: plane.py プロジェクト: nickthecoder/itchy
 def onDeath(self) :
     if self.dummy :
         self.dummy.removeFromGrid()
     Movable.onDeath(self)
コード例 #14
0
ファイル: dirt.py プロジェクト: saltire/roverchip
 def __init__(self, level, pos):
     Movable.__init__(self, level, pos)
     
     self.tile = 8, 1
コード例 #15
0
ファイル: big.py プロジェクト: nickthecoder/itchy
    def move( self, dx, dy, speed=None ) :
    
        Movable.move( self, dx, dy, speed )

        for part in self.parts :
            part.move( dx, dy, speed )
コード例 #16
0
ファイル: character.py プロジェクト: andy-davies/platformgame
 def start_scene(self, scene, initial_left, initial_top):
     Movable.start_scene(self, scene, initial_left, initial_top)
     self.walking = False
     self.walk_index = 0
     self.dead = False
コード例 #17
0
ファイル: big.py プロジェクト: nickthecoder/itchy
 def removeFromGrid(self) :
     Movable.removeFromGrid(self)
     for part in self.parts :
         part.removeFromGrid()
コード例 #18
0
ファイル: big.py プロジェクト: nickthecoder/itchy
 def __init__(self) :
     Movable.__init__(self)
     
     # A list of Part objects
     self.parts = []