def update(self, dt, t): super(Player, self).update(dt, t) # bounderies if self.side == -1: if self.pos.x < 0: self.pos.x = 0 elif self.pos.x > 380: self.pos.x = 380 else: if self.pos.x > 800: self.pos.x = 800 elif self.pos.x < 420: self.pos.x = 420 # sprite self.spr.update(dt, t) # facing d = sign(self.vel.x) if d: self.facing = d # holding obj if self._pickup: self._pickup.pos.values = self.pos self._pickup.pos.y -= 35 + (self._pickup.rect.h / 2) self._pickup.facing = self.facing # power if self.build_up_power: self._pickup_time += dt / 1500.0 self._pickup_time = min(1.0, self._pickup_time) self.calc_apex() self.rect.midbottom = self.spr.rect.midbottom self.crosshair.update(dt, t)
def update(self, dt, t, *args, **kwargs): hp = self.app.lawn.right_score() if hp < self._st_lasthealth: self._st_f_damaged = 1 self._st_lasthealth = hp self._st_time += dt if self._st_time >= self._st_limit: self._st_time = 0.0 # Track damage we take if self._st_f_damaged != 0: self._st.add_event('damaged',self._st_f_damaged) self._st_f_damaged = 0 else: self._st.add_event('damaged', 0) # Track when the other player is healing if self._st_f_otherhealed != 0: self._st.add_event('otherhealed', self._st_f_otherhealed) self._st_f_otherhealed = 0 else: self._st.add_event('otherhealed', self._st_f_otherhealed) print "STATS: damaged - ", self._st.calc_average('damaged') print "STATS: otherhealed - ", self._st.calc_average('otherhealed') self.cur_state.update(self, dt, t, *args, **kwargs) dir = sign(self.vel.x) if dir: self.facing = dir
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 update(_self, self, dt, t, *args, **kwargs): super(StateMachine, self).update(dt, t) _self.checkScreenClipping(self) if self.pos.x > 10 and self.pos.x < SCREENWIDTH - 10: if have_luck(BIRDPOOPCHANCE) and ( self.pos.x < FENCELEFT - 40 or self.pos.x > FENCERIGHT + 40): self.change_state(self._state_poop) elif have_luck(BIRDTURNCHANCE): self.vel.x *= -1 if sign(self.vel.x) > 0: self.spr = self.spr_fly_r else: self.spr = self.spr_fly_l self.spr.play() if self.vel.y: if have_luck(BIRDSTOPCHANCE) and self.pos.y < 350: self.accel.y = 0 self.vel.y = 0 if self.pos.y < 0: self.pos.y = 10 self.accel.y = 0 self.vel.y = 0 self.spr.update(dt, t) self.rect.center = self.pos
def enter(self_, self): super(LadyBug.StateWalk, self_).enter(self) self.spr = self.spr_walk self.spr.play() self.vel.x = choice((-1, 1)) * 0.01 self.facing = sign(self.vel.x) self.spr.face = self.facing
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 update(self, dt, t, *args, **kwargs): hp = self.app.lawn.right_score() if hp < self._st_lasthealth: self._st_f_damaged = 1 self._st_lasthealth = hp self._st_time += dt if self._st_time >= self._st_limit: self._st_time = 0.0 # Track damage we take if self._st_f_damaged != 0: self._st.add_event('damaged', self._st_f_damaged) self._st_f_damaged = 0 else: self._st.add_event('damaged', 0) # Track when the other player is healing if self._st_f_otherhealed != 0: self._st.add_event('otherhealed', self._st_f_otherhealed) self._st_f_otherhealed = 0 else: self._st.add_event('otherhealed', self._st_f_otherhealed) print "STATS: damaged - ", self._st.calc_average('damaged') print "STATS: otherhealed - ", self._st.calc_average('otherhealed') self.cur_state.update(self, dt, t, *args, **kwargs) dir = sign(self.vel.x) if dir: self.facing = dir
def update(_self, self, dt, t, *args, **kwargs): super(StateMachine, self).update(dt, t) _self.checkScreenClipping(self) if self.pos.x > 10 and self.pos.x < SCREENWIDTH - 10: if have_luck(MOLECLIMBCHANCE): self.change_state(self._state_walk_u) return elif have_luck(MOLEDIRCHGCHANCE): self.vel.x *= -1.0 if sign(self.vel.x) > 0: self.spr = self.spr_walk_r else: self.spr = self.spr_walk_l self.spr.play() self.spr.update(dt, t) self.rect.center = self.pos
def update(_self, self, dt, t, *args, **kwargs): super(StateMachine, self).update(dt, t) _self.checkScreenClipping(self) if self.pos.x > 10 and self.pos.x < SCREENWIDTH - 10: if have_luck(MOLECLIMBCHANCE): self.change_state(self._state_walk_u) return elif have_luck(MOLEDIRCHGCHANCE): self.vel.x *= -1.0 if sign(self.vel.x)>0: self.spr = self.spr_walk_r else: self.spr = self.spr_walk_l self.spr.play() self.spr.update(dt, t) self.rect.center = self.pos
def update(self, dt, t, *args, **kwargs): self.cur_state.update(self, dt, t, *args, **kwargs) dir = sign(self.vel.x) if dir: self.facing = dir