def __init__(self): super(Player, self).__init__((100, 355)) self.spr_carry = animation.TimedAnimation( self.pos, load_image('guywalkhands_animnew.png'), 4, 30, 'loop') self.spr_walk = animation.TimedAnimation( self.pos, load_image('guywalk_animnew.png'), 4, 5, 'loop') self.spr = self.spr_walk self.facing = 1 # 1: right -1: left d = sign(self.vel.x) if d: self.facing = d self.kdir = 0 self.rect = pygame.Rect(self.spr.rect) self.rect.inflate_ip(-self.rect.w / 2, -self.rect.h / 2) self._pickup = None self._pickup_time = 0.0 self.collider = None self.last_thrown = None self.build_up_power = False self.actionkey_walk_l = K_a self.actionkey_walk_r = K_d self.actionkey_pickup = K_s self.actionkey_throw = K_w self.side = -1 # left # crosshair img = pygame.Surface((3, 3)) img.fill((255, 0, 0)) self.crosshair = animation.FrameAnimation(self.pos.clone(), img)
def __init__(self): super(NPCharacter, self).__init__(Vec2D(SCREENWIDTH - 100, 355), self._state_think) self.app = states.TheStateManager.cur_state self.spr_walk = animation.TimedAnimation( self.pos, load_image('guy2walk_animnew.png'), 4, 5, 'loop') self.spr_carry = animation.TimedAnimation( self.pos, load_image('guy2walkhands_animnew.png'), 4, 30, 'loop') self.spr = self.spr_walk self.rect = pygame.Rect(self.spr.rect) self.rect.inflate_ip(-self.rect.w / 2, -self.rect.h / 2) self.pickupable = False self._st = StatsTracker() self._st_lasthealth = 0 self.facing = 1 self._pickup = None self._pickup_time = 0.0 self.build_up_power = False self.target = None self.targetkind = None self.carrypos = None self.carrykind = None self.flipwater = False i = pygame.Surface((3, 3)) i.fill((255, 0, 0)) self.crosshair = animation.FrameAnimation(self.pos.clone(), i)
def __init__(self, pos, facing): super(WaterDrop, self).__init__(pos) self.vel.x = facing * randint(0, 100) * 0.0005 self.vel.y = -randint(0, 20) * 0.001 self.accel.y = FALLSPEED img = load_image('waterdrop.png') self.spr = animation.FrameAnimation(self.pos, img) self.rect.size = self.spr.rect.size
def __init__(self, pos): super(FlyObj, self).__init__(pos, self._state_thrown) s = rand.randint(10, 30) if s > 20: img = load_image('block.png') else: img = load_image('stone.png') self.spr = animation.FrameAnimation( self.pos, pygame.transform.smoothscale(img, (s, s))) self.rect = pygame.Rect(self.spr.rect) self.weight = s / 40. + 1.5 self.size = s self.pickupable = False
def __init__(self, pos): super(FlyObj, self).__init__(pos, self._state_thrown) s = rand.randint(20, 40) img = load_image('poop_anim.png') img = pygame.transform.smoothscale(img, (s, s)) self.spr = animation.TimedAnimation(self.pos, img, 2, 3, 'loop') self.rect = pygame.Rect(self.spr.rect) self.weight = s / 40. + 1.5 self.size = s self.pickupable = False self.accel.y = FALLSPEED self.accel.x = 0 self.vel = Vec2D(0, 0) self.lifetime = POOPLIFETIME # 10 sec img = load_image('poopground.png') img = pygame.transform.scale(img, (s, s)) self.ground_spr = animation.FrameAnimation(self.pos, img)
def __init__(self, pos): super(LawnSegment, self).__init__(pos) # Setup sprites for state self.type = randint(1, 3) self.frames = [] for t in [ 'healthy%d.png', 'annoyed%d.png', 'hurt%d.png', 'damaged%d.png', 'dead%d.png' ]: self.frames.append( animation.FrameAnimation( self.pos, load_image('grass/' + (t % self.type)))) self.hurt_icon = animation.TimedAnimation( self.pos, load_image('grass/hurt_icon.png'), 10, 10, mode='once') self.heal_icon = animation.TimedAnimation( self.pos, load_image('grass/heal_icon.png'), 6, 10, mode='once') self.state = self.HEALTHY self.hitpoints = self.MAXHEALTH self.image = self.frames[self.state] self.rect = self.image.rect