def __init__(self): Monster.__init__(self) monsters = SpriteSheet( 'instant_dungeon_artpack/By Scott Matott/monsters.png') pick_monster = monsters.image_at([0, 64, 16, 16]).convert() self.scale_factor = [64, 64] self.enlarge = lambda x: pygame.transform.smoothscale( x, self.scale_factor) self.image = self.enlarge(pick_monster) # pygame.Surface self.image.set_colorkey((0, 0, 0)) monster_images = monsters.load_strip([0, 64, 16, 16, 8], 8) self.load_images(monster_images) self.direction = randrange(1, 9) # Refer to Mover.update method self.walk_counter = 0 # Keep monsters from changing directions constantly # Speed is used for finding direction. Velocity already contains that direction. self.speed = [2, 2] self.velocity = pygame.math.Vector2(self.speed) self.health = 80 + (10 * self.level) self.max_health = self.health
def __init__(self): Monster.__init__(self) self.level = 3 self.exp_value = 250 monsters = SpriteSheet( 'instant_dungeon_artpack/By Scott Matott/monsters.png') self.image = self.enlarge( monsters.image_at([0, 128, 16, 16]).convert()) # pygame.Surface self.image.set_colorkey((0, 0, 0)) monster_images = monsters.load_strip([0, 128, 16, 16, 8], 8) self.load_images(monster_images) # Speed is used for finding direction. Velocity already contains that direction. self.speed = [5, 5] self.velocity = pygame.math.Vector2(self.speed) self.health = 150 + (30 * self.level) self.max_health = 150 + (30 * self.level) self.cooldown = 500 self.uses_caps = True self.offset = (-40, -30) self.healthbar = Bar(self.offset, self.uses_caps, False, 'health')
def load_transform_image(self): ''' :action: Loads image of sword and scales it accordingly, and rotates it in the correct direction. ''' sword_images = SpriteSheet('instant_dungeon_artpack/By Voytek Falendysz/shield_knife_and_scrolls.png') image = sword_images.image_at([86, 0, 5, 16]) self.image = pygame.transform.smoothscale(image, [20, 64]) # Rotate sword to go in direction of click. Minus 90 because sword originally points upwards. self.image = pygame.transform.rotate(self.image, self.angle - 90)
def load_transform_image(self): ''' :action: Loads image of sword and scales it accordingly, and rotates it in the correct direction. ''' sword_images = SpriteSheet( 'instant_dungeon_artpack/By Voytek Falendysz/shield_knife_and_scrolls.png' ) image = sword_images.image_at([86, 0, 5, 16]) self.image = pygame.transform.smoothscale(image, [20, 64]) # Rotate sword to go in direction of click. Minus 90 because sword originally points upwards. self.image = pygame.transform.rotate(self.image, self.angle - 90)
def __init__(self): Mover.__init__(self) monsters = SpriteSheet( 'instant_dungeon_artpack/By Scott Matott/monsters.png') pick_monster = monsters.image_at([0, 112, 16, 16]).convert() self.exp_value = 100 self.level = 2 self.scale_factor = [64, 64] self.enlarge = lambda x: pygame.transform.smoothscale( x, self.scale_factor) self.image = self.enlarge(pick_monster) # pygame.Surface self.image.set_colorkey((0, 0, 0)) monster_images = monsters.load_strip([0, 112, 16, 16, 8], 8) self.load_images(monster_images) self.rect = self.image.get_rect() # pygame.Rect self.rect = self.rect.move( [randrange(700, 3670), randrange(700, 2160)]) # Random spawn location self.direction = randrange(1, 9) # Refer to Mover.update method self.walk_counter = 0 # Keep monsters from changing directions constantly # Speed is used for finding direction. Velocity already contains that direction. self.speed = [3, 3] self.velocity = pygame.math.Vector2(self.speed) self.health = 90 + (25 * self.level) self.max_health = self.health self.timer = pygame.time.get_ticks() self.cooldown = 800 self.uses_caps = False self.offset = [5, -15] self.healthbar = Bar(self.offset, self.uses_caps, False, 'health')
def __init__(self, gamestate_area): Mover.__init__(self) self.level = 1 self.experience = 1 self.level_experience = 1000 self.ability_levels = { S.Attack: 1, S.Sweep: 0, S.Arrow: 0, S.SplitShot: 0, S.Lightning: 0, S.FireStorm: 0, S.ToughenUp: 0, S.Wisen: 0 } left_ability_boundary = 40 self.ability_manager = AbilityManager(40) left_inventory_boundary = 880 self.inventory = Inventory(left_inventory_boundary) self.from_player = True scale_factor = [64, 64] enlarge = lambda x: pygame.transform.smoothscale(x, scale_factor) characters = SpriteSheet( 'instant_dungeon_artpack/By Jos Luis Peir Lima/players-mages.png') self.image = enlarge(characters.image_at( [64, 0, 16, 16])).convert() # pygame.Surface self.rect = self.image.get_rect() # pygame.Rect # Start character at center of screen. center_character = list(gamestate_area.center) center_character = list( map(lambda x, y: x - (y / 2), center_character, scale_factor)) self.rect = self.rect.move(center_character[0], center_character[1]) # Used to face different direction when walking that way. player_images = characters.load_strip([0, 0, 16, 16], 8) self.down_image = enlarge(player_images[0]).convert() self.up_image = enlarge(player_images[2]).convert() self.right_image = enlarge(player_images[4]).convert() self.left_image = enlarge(player_images[6]).convert() # Get rid of green box around player. self.image.set_colorkey((0, 255, 0)) self.down_image.set_colorkey((0, 255, 0)) self.up_image.set_colorkey((0, 255, 0)) self.right_image.set_colorkey((0, 255, 0)) self.left_image.set_colorkey((0, 255, 0)) # Used for movement. self.speed = [.1, .1] # pixels per millisecond self.velocity = [0, 0] # Used to limit attacks per second. self.timer = pygame.time.get_ticks() self.start_max_health = 700 self.start_max_energy = 250 self.max_health = 700 self.health = 700 self.max_energy = 250 self.energy = 250 self.base_health_regen = .01 self._base_energy_regen = .01 self.uses_caps = True # Drawing health bar utility. health_bar_offset = [-570, -320] energy_bar_offset = [-570, -280] experience_bar_offset = [-200, 340] self.healthbar = Bar(health_bar_offset, self.uses_caps, True, 'health') self.energybar = Bar(energy_bar_offset, self.uses_caps, True, 'energy') self.experiencebar = Bar(experience_bar_offset, self.uses_caps, True, 'experience')
class InvaderSheet: def __init__(self): self.sheet = SpriteSheet('res/space_invaders.png') def get_image(self, rect): return self.sheet.image_at(rect, colorkey=ALPHA_KEY)
def __init__(self, gamestate_area): Mover.__init__(self) self.level = 1 self.experience = 1 self.level_experience = 1000 self.ability_levels = {S.Attack: 1, S.Sweep: 0, S.Arrow: 0, S.SplitShot: 0, S.Lightning: 0, S.FireStorm: 0, S.ToughenUp: 0, S.Wisen: 0} left_ability_boundary = 40 self.ability_manager = AbilityManager(40) left_inventory_boundary = 880 self.inventory = Inventory(left_inventory_boundary) self.from_player = True scale_factor = [64, 64] enlarge = lambda x: pygame.transform.smoothscale(x, scale_factor) characters = SpriteSheet('instant_dungeon_artpack/By Jos Luis Peir Lima/players-mages.png') self.image = enlarge(characters.image_at([64, 0, 16, 16])).convert() # pygame.Surface self.rect = self.image.get_rect() # pygame.Rect # Start character at center of screen. center_character = list(gamestate_area.center) center_character = list(map(lambda x, y: x - (y/2), center_character, scale_factor)) self.rect = self.rect.move(center_character[0], center_character[1]) # Used to face different direction when walking that way. player_images = characters.load_strip([0, 0, 16, 16], 8) self.down_image = enlarge(player_images[0]).convert() self.up_image = enlarge(player_images[2]).convert() self.right_image = enlarge(player_images[4]).convert() self.left_image = enlarge(player_images[6]).convert() # Get rid of green box around player. self.image.set_colorkey((0, 255, 0)) self.down_image.set_colorkey((0, 255, 0)) self.up_image.set_colorkey((0, 255, 0)) self.right_image.set_colorkey((0, 255, 0)) self.left_image.set_colorkey((0, 255, 0)) # Used for movement. self.speed = [.1, .1] # pixels per millisecond self.velocity = [0, 0] # Used to limit attacks per second. self.timer = pygame.time.get_ticks() self.start_max_health = 700 self.start_max_energy = 250 self.max_health = 700 self.health = 700 self.max_energy = 250 self.energy = 250 self.base_health_regen = .01 self._base_energy_regen = .01 self.uses_caps = True # Drawing health bar utility. health_bar_offset = [-570, -320] energy_bar_offset = [-570, -280] experience_bar_offset = [-200, 340] self.healthbar = Bar(health_bar_offset, self.uses_caps, True, 'health') self.energybar = Bar(energy_bar_offset, self.uses_caps, True, 'energy') self.experiencebar = Bar(experience_bar_offset, self.uses_caps, True, 'experience')