当前位置: 首页>>代码示例>>Python>>正文


Python spritesheet_functions.SpriteSheet类代码示例

本文整理汇总了Python中spritesheet_functions.SpriteSheet的典型用法代码示例。如果您正苦于以下问题:Python SpriteSheet类的具体用法?Python SpriteSheet怎么用?Python SpriteSheet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SpriteSheet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, player):
        """ Create level 1. """

        # Call the parent constructor
        Level.__init__(self, player)

        sprite_sheet = SpriteSheet("backgrounds.png")
        self.background = sprite_sheet.get_image(0, 63, 231, 63)
        self.background = pygame.transform.scale(self.background, (constants.SCREEN_WIDTH,
                                                                 constants.SCREEN_HEIGHT))
        self.background.set_colorkey(constants.WHITE)
        self.level_limit = -2500

        # Array with type of platform, and x, y location of the platform.
        level = [ [platforms.STONE_WALL, 30, 650]
                  ]

        

        # Go through the array above and add platforms
        for platform in level:
            block = platforms.Platform(platform[0])
            block.rect.x = platform[1]
            block.rect.y = platform[2]
            block.player = self.player
            self.platform_list.add(block)
开发者ID:Waveharp,项目名称:Pygame-experiments,代码行数:26,代码来源:levels.py

示例2: __init__

    def __init__(self, sprite_sheet_data):
        """ Platform constructor. Assumes constructed with user passing in
            an array of 5 numbers like what's defined at the top of this
            code. """
        super().__init__()

        #sprite_sheet = SpriteSheet("tiles_spritesheet.png")
        sprite_sheet = SpriteSheet( \
                "images/green-hill-zone/level-fragments/27190.png")

        self.x0 = sprite_sheet_data[0];
        self.y0 = sprite_sheet_data[1];
        self.x1 = sprite_sheet_data[2];
        self.y1 = sprite_sheet_data[3];

        self.image = sprite_sheet.get_image(self.x0, \
                self.y0, self.x1-self.x0, self.y1-self.y0)

        if (len(sprite_sheet_data) > 4):
            a = sprite_sheet_data[4]
            b = sprite_sheet_data[5]
            self.image = pygame.transform.scale(self.image, (a,b))
        
        colorkey = self.image.get_at((0,0))
        self.image.set_colorkey(colorkey)

        self.rect = self.image.get_rect()
开发者ID:HaraldNordgren,项目名称:sanic-the-hedgehog,代码行数:27,代码来源:platforms.py

示例3: load_sprite

 def load_sprite(self):    
     # Load sword sprite
     sprite_sheet = SpriteSheet("resources/attacks/Sword_Update1.png")
     image = sprite_sheet.get_image(0, 0, 103, 32)
     self.sword_frame_r.append(image)
     image = pygame.transform.flip(image, True, False)
     self.sword_frame_l.append(image)
开发者ID:jwj9627,项目名称:platform-fighting,代码行数:7,代码来源:weapon.py

示例4: Platform

class Platform(pygame.sprite.Sprite):
    """
    Class for basic platforms. Uses sprite_sheet.get
    to get the appropriate sprite according to defined values above
    """
    def __init__(self, sprite_sheet_data, x, y):
        super(Platform, self).__init__()

        self.sprite_sheet = SpriteSheet(path.join(img_dir, "tiles_spritesheet.png"))
        self.image = self.sprite_sheet.get_image(sprite_sheet_data[0],
                                                 sprite_sheet_data[1],
                                                 sprite_sheet_data[2],
                                                 sprite_sheet_data[3])

        self.sprite_sheet_data = sprite_sheet_data

        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y
        self.x_pos = x
        self.y_pos = y

    def collide(self):
        pass

    def update(self, dt):
        pass

    def set_image(self, block):
        self.image = self.sprite_sheet.get_image(block[0],
                                                 block[1],
                                                 block[2],
                                                 block[3])
开发者ID:ToBaer94,项目名称:pygame_platformer,代码行数:33,代码来源:platforms.py

示例5: __init__

    def __init__(self, file_name):
        ''' (1) charge le fichier TMX
            (2) charge le fichier image ou se trouvent les sprites dans l'objet sheet
        '''

        self.carte    = None                 # json data from file
        self.sheet    = None                 # SpriteSheet object
        self.spritesize = 0                  # sprite size in pixels (assume its a square)
        self.rowsize,self.colsize = None,None# number of sprites in a row , column

        dirname = os.path.dirname(os.path.abspath(__file__))

        with open(dirname + "/" + file_name, 'r') as f:
            self.carte = json.load(f)

        assert self.carte["tilewidth"]==self.carte["tileheight"], "les sprites doivent etre carres"

        self.spritesize               = self.carte["tilewidth"]
        self.rowsize , self.colsize   = self.carte["width"],self.carte["height"]

        try:
            sheet_filename  = dirname + "/" + self.carte["tilesets"][0]["image"]
            self.sheet      = SpriteSheet(sheet_filename,self.spritesize)
        except pygame.error:
            try:
                sheet_filename  = dirname + "/Cartes/" + self.carte["tilesets"][0]["image"]
                self.sheet      = SpriteSheet(sheet_filename,self.spritesize)
            except pygame.error as e2:
                print ("Error - impossible de trouver le fichier images des sprites -")
                raise e2
开发者ID:3201101,项目名称:3I025,代码行数:30,代码来源:spritebuilder.py

示例6: __init__

    def __init__(self, x, y):
        """
        Initializes the image at the given location.
        
        Args:
            x (int): the x coordinate to place the Sprite.
            y (int): the y coordinate to place the Sprite.
        """
        pygame.sprite.Sprite.__init__(self)

        #Get the ghost images from the Sprites folder
        script_dir = sys.path[0]
        image_directory = os.path.join(script_dir, 'Sprites/ghost2.bmp')
        
        # Get the 2 images for the sprite sheet. 
        sprite_sheet = SpriteSheet(image_directory)
        image = sprite_sheet.get_image(0, 0, 62, 75)
        self.__movement_frames.append(image)
        image = sprite_sheet.get_image(64 , 0, 62, 75)
        self.__movement_frames.append(image)
        
        
        # set the Player to the first sprite
        self.image = self.__movement_frames[self.__current_frame_reference]
        
        self.rect = self.image.get_rect()
        
        # Setting the location of rectangle
        self.rect.x = x
        self.rect.y = y
开发者ID:habahnow,项目名称:332L,代码行数:30,代码来源:Ghost.py

示例7: __init__

 def __init__(self):
     super().__init__()
     #Motion variables
     self.change_x = 0
     self.change_y = 0
     self.boundary_top = 0
     self.boundary_bottom = 0
     self.boundary_left = 0
     self.boundary_right = 0
     #Level information
     self.level = None
     self.player = None
     #How fast this sprite attacks, in number of frames. 5 = every 5 frames
     self.attack_speed = 10
     #How many times updated has been called. reset to zero when it = attack speed
     self.updates = 0
     self.firing = False
     self.fired_ticks = 0
     sheet = SpriteSheet("enemy_sheet.png")
     self.frames_l = []
     self.frames_r = []
     image = sheet.get_image(0, 48, 64, 132)
     self.frames_l.append(image)
     image = sheet.get_image(68, 48, 64, 132)
     self.frames_l.append(image)
     image = pygame.transform.flip(self.frames_l[0], True, False)
     self.frames_r.append(image)
     image = pygame.transform.flip(self.frames_l[1], True, False)
     self.frames_r.append(image)
     self.direction = 'L'
     if self.direction == 'R':
         self.image = self.frames_r[0]
     if self.direction == 'L':
         self.image = self.frames_l[0]
     self.rect = self.image.get_rect()
开发者ID:tkdberger,项目名称:pygame-fun,代码行数:35,代码来源:collectables.py

示例8: __init__

    def __init__(self):
        super(WallSprite, self).__init__()

        sprite_sheet = SpriteSheet('images/tilesets/walls.png')#3 x 4
        horiz = [0, 32, 64]
        vert= [0, 32, 64, 96]
        self.image = sprite_sheet.get_image(random.choice(horiz),random.choice(vert),32,32)
开发者ID:IanOlin,项目名称:InteractiveProgramming,代码行数:7,代码来源:level.py

示例9: __init__

 def __init__(self, sprite_sheet_data):
   pygame.sprite.Sprite.__init__(self)
   sprite_sheet = SpriteSheet("elevator.png")
   # grab the image for the elevator
   self.image = sprite_sheet.get_image(sprite_sheet_data[0], sprite_sheet_data[1], sprite_sheet_data[2], sprite_sheet_data[3])
   self.rect = self.image.get_rect()
   self.router = ElevatorData(FLOORS)
   self.path = []
   self.wait = 0
开发者ID:jacooob,项目名称:Cs415Elevator,代码行数:9,代码来源:Building.py

示例10: __init__

    def __init__(self, sprite_sheet_data):
        pygame.sprite.Sprite.__init__(self)

        sprite_sheet = SpriteSheet("tiles_spritesheet.png")
        # grab image for this platform
        self.image = sprite_sheet.get_image(
            sprite_sheet_data[0], sprite_sheet_data[1], sprite_sheet_data[2], sprite_sheet_data[3]
        )
        self.rect = self.image.get_rect()
开发者ID:Waveharp,项目名称:Arcade_games,代码行数:9,代码来源:platforms.py

示例11: __init__

 def __init__(self, sprite_sheet_data, x=0, y=0):
     super().__init__()
     sprite_sheet = SpriteSheet("platform_sheet.png")
     # Grab the image for this platform
     self.image = sprite_sheet.get_image(sprite_sheet_data[0], sprite_sheet_data[1], sprite_sheet_data[2], sprite_sheet_data[3])
     # This platform can set its own position based on passed-in args
     self.rect = self.image.get_rect()
     self.x = x
     self.y = y
开发者ID:tkdberger,项目名称:pygame-fun,代码行数:9,代码来源:platforms.py

示例12: __init__

    def __init__(self):
        super().__init__()

        sprite_sheet = SpriteSheet("spritesheet.png")
        # Grab the image for this platform
        self.image = sprite_sheet.get_image(32, 128, 32, 32)

        self.imagesAndDurations = [(sprite_sheet.get_image(32, 96, 32, 32), 0.1),
                                   (sprite_sheet.get_image(63, 96, 32, 32), 0.5)]
开发者ID:Allyrax,项目名称:Bomberman,代码行数:9,代码来源:level.py

示例13: __init__

    def __init__(self, sprite_sheet_data):
        pygame.sprite.Sprite.__init__(self)

        sprite_sheet = SpriteSheet("Levels/tiles_spritesheet.png")
        self.image = sprite_sheet.get_image(sprite_sheet_data[0],
                                            sprite_sheet_data[1],
                                            sprite_sheet_data[2],
                                            sprite_sheet_data[3])

        self.rect = self.image.get_rect()
开发者ID:epifalcon,项目名称:leviathan,代码行数:10,代码来源:platforms.py

示例14: __init__

    def __init__(self, sprite_sheet_data):

        super(Platform, self).__init__()
        self.x_velocity = 0
        self.y_velocity = 0
        sprite_sheet = SpriteSheet(TILES_SS_PATH)
        self.image = sprite_sheet.get_image(sprite_sheet_data[0],
                                            sprite_sheet_data[1],
                                            sprite_sheet_data[2],
                                            sprite_sheet_data[3])
        self.rect = self.image.get_rect()
开发者ID:AShrewdRepentThing,项目名称:symmetry-ninja,代码行数:11,代码来源:platforms.py

示例15: __init__

	def __init__(self, sprite_sheet_data):
		pygame.sprite.Sprite.__init__(self)
		
		sprite_sheet = SpriteSheet(sprite_sheet_data[0])
		# Grab the image for this platform
		self.image = sprite_sheet.get_image(sprite_sheet_data[1],
											sprite_sheet_data[2],
											sprite_sheet_data[3],
											sprite_sheet_data[4])

		self.rect = self.image.get_rect()
开发者ID:reakain,项目名称:Punk_Game,代码行数:11,代码来源:object_class.py


注:本文中的spritesheet_functions.SpriteSheet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。