Beispiel #1
0
 def __init__(self, owner, *groups):
     size = prepare.CELL_SIZE
     _Particle.__init__(self, owner.rect.topleft, size, *groups)
     self.owner = owner
     self.vec = None
     self.speed = 5
     self.attack = 5
     self.frames = tools.strip_from_sheet(SHOOT_SHEET, (100, 250), size, 2)
     self.anim = tools.Anim(self.frames, 12)
     self.image = self.anim.get_next_frame(pg.time.get_ticks())
     self.mask = pg.mask.from_surface(self.image)
 def get_attack_info(self, start, size, columns, fps=15.0):
     """Get attack frames from the attack sheet."""
     sheet = prepare.GFX["equips"]["attacks1"]
     raw_frames = tools.strip_from_sheet(sheet, start, size, columns)
     anims = {}
     rects = {}
     for i, direct in enumerate(["right", "back", "left", "front"]):
         frames = [pg.transform.rotate(pic, i * 90) for pic in raw_frames]
         anims[direct] = tools.Anim(frames, fps, 1)
         rects[direct] = [pic.get_rect() for pic in frames]
     return anims, rects
Beispiel #3
0
 def __init__(self, _a, _b, target, mask, fps=4, frames=2, src=None):
     """
     The frames argument is the number of frames in the animation, and
     fps is the desired framerate of the animation; src is the source
     location on the animation sheet (not the water sheet).
     _a and _b are dummy variables that are not actually needed.  They
     are in the list of args so that the interface to Tile and AnimatedTile
     are the same.
     """
     Tile.__init__(self, "animsheet", src, target, mask)
     size = prepare.CELL_SIZE
     frames = tools.strip_from_sheet(self.sheet, src, size, frames)
     self.anim = tools.Anim(frames, fps)
 def __init__(self, pos, *groups):
     pg.sprite.Sprite.__init__(self, *groups)
     if not self.frames:
         sheet = prepare.GFX["objects"]["projectiles"]
         self.frames.extend(tools.strip_from_sheet(sheet, (300, 0), (30, 30), 3))
         self.frames += [self.frames[1]]
     self.frame = 0
     self.image = self.frames[self.frame]
     self.rect = self.image.get_rect(center=pos)
     self.blink_timer = tools.Timer(100)
     self.blink_timer.check_tick(pg.time.get_ticks())
     self.delay = random.randrange(200, 3000)
     self.delay_timer = 0.0
     self.animate = random.random() < 0.1
 def get_images(self, sheet, sheet_pos):
     """
     Slice images from the sheet with respect to a standard layout.
     Note that an exception must be made for right facing while holding a
     shield.
     """
     frames = tools.strip_from_sheet(sheet, sheet_pos, prepare.CELL_SIZE,
                                     18)
     self.images = {}
     self.attack_images = {}
     for i, direction in enumerate(prepare.DIRECTIONS):
         self.images[direction] = frames[4 * i:4 * i + 2]
         self.attack_images[direction] = frames[4 * i + 2:4 * i + 4]
     self.images["right_with_shield"] = frames[16:]
Beispiel #6
0
 def __init__(self, *args):
     _Enemy.__init__(self, "evil_elf", ENEMY_SHEET_2, *args)
     self.ai = LinearAI(self)
     walk = {
         "front": tools.Anim(self.frames[:2], 7),
         "back": tools.Anim(self.frames[6:8], 7),
         "left": tools.Anim(self.frames[2:4], 7),
         "right": tools.Anim(self.frames[4:6], 7)
     }
     hit = {
         "front": tools.Anim(self.frames[:2], 20),
         "back": tools.Anim(self.frames[6:8], 20),
         "left": tools.Anim(self.frames[2:4], 20),
         "right": tools.Anim(self.frames[4:6], 20)
     }
     death_args = (ENEMY_SHEET, (150, 50), prepare.CELL_SIZE, 3)
     death_frames = tools.strip_from_sheet(*death_args)
     die = tools.Anim(death_frames, 3, loops=1)
     self.anims = {"walk": walk, "hit": hit, "die": die}
     self.image = self.get_anim().get_next_frame(pg.time.get_ticks())
     self.health = 6
     self.attack = 6
     self.drops = ["heart", None]
 def get_images(self, sheet, sheet_pos):
     """Get the weapon images assuming a standard layout."""
     frames = tools.strip_from_sheet(sheet, sheet_pos, prepare.CELL_SIZE, 8)
     self.images = {}
     for i, direction in enumerate(prepare.DIRECTIONS):
         self.images[direction] = frames[2 * i:2 * i + 2]
Beispiel #8
0
 def __init__(self):
     menu_functions.BidirectionalMenu.__init__(self, (5, 2))
     self.arrows = tools.strip_from_sheet(STAT_ARROWS, (0, 0),
                                          STAT_ARROW_SIZE, 3)
     self.rendered = {}
Beispiel #9
0
 def __init__(self):
     menu_functions.BasicMenu.__init__(self, 5)
     self.arrows = tools.strip_from_sheet(ARROWS, (0, 0), ARROW_SIZE, 2)
     self.rendered = {}