def sample_map(): m = Map( (10, 10), display.get_image( os.path.join( 'img', 'dungeon tileset calciumtrice.png' ) ), offset=(16*2, 16*2) ) tiles = [ 82, 41, 41, 42, 43, 41, 43, 43, 42, 81, 44, 124, 122, 121, 123, 124, 128, 123, 127, 36, 45, 154, 152, 151, 153, 154, 158, 153, 157, 35, 44, 211, 219, 220, 220, 218, 219, 218, 212, 37, 44, 216, 271, 273, 271, 271, 272, 278, 226, 37, 46, 217, 272, 274, 272, 274, 273, 272, 224, 37, 46, 215, 271, 271, 272, 271, 271, 271, 226, 36, 45, 216, 271, 271, 274, 273, 277, 274, 225, 35, 44, 215, 272, 273, 271, 273, 272, 273, 224, 35, 80, 38, 39, 40, 40, 38, 39, 38, 40, 79, ] m.set_map(tiles) return m
def display(self, screen, padding): updates = [] for row in self.grid: for block in row: surf, pt = display.get_image(block, padding) updates.append(screen.blit(surf, pt)) return updates
def __init__(self, id, sprite_map_xml, sprite_map, sprite_name, x, y, scale_factor, collision, z_index, type, input, physics, graphics): super(GameObject, self).__init__(display.get_image(sprite_map), xml_parser.load_sprite_map_info(sprite_map_xml), z_index) # Identification self.id = id self.type = type # The name of the sprite (as found on the sprite sheet. Unless it is a multiple framed sprite # then this represents a unquie sub string of all the frames). self.sprite_name = sprite_name self.sprites_info = self.get_sprite_info(self.sprite_name) # Better to scale here than in the main loop for sprite in self.sprites_info: self.sprites_info[sprite][1].append(int(self.sprites_info[sprite][1][0] / scale_factor)) self.sprites_info[sprite][1].append(int(self.sprites_info[sprite][1][1] / scale_factor)) # Components self.input = input self.physics = physics self.graphics = graphics # Status of GameObject self.is_alive = True self.health = 0 self.prev_health = 0 self.hit_time = 0 self.collision = collision self.on_land = False self.air_time = 0 self.attacking = False self.life_counter = 0 self.buffer_attack = 0 # Positions self.oldx = x self.oldy = y self.x = x self.y = y self.dx = 0 self.dy = 0 # Size self.scale_factor = scale_factor self.width = 0 self.height = 0 self.oldwidth = 0 self.oldheight = 0 # Action of Sprite self.current_action = self.graphics.get_default_action() self.pre_render() # Keys that are down and up that affect the game object self.keys_down = [] self.keys_up = []
def __init__(self): # Call the parent constructor super(HeroStatue, self).__init__( display.get_image( os.path.join( 'img', 'dungeon tileset calciumtrice.png' ) ) )
def __init__(self): # Call the parent constructor super(Minotaur, self).__init__( display.get_image( os.path.join( 'img', 'minotaur spritesheet calciumtrice.png' ) ) ) self.clock = pygame.time.Clock() self.frame = 0.0