def _update_bezier(self): direction = self.direction() particle.thrust(self.pos-direction*4, self.speed - direction*2) self._t += 1 self.rot += 2 current = self._bezier.B(self._t) self.pos = current[:3] self.theta = current[3] self.phi = current[4] if self._t >= self._bezier.tmax: if self._state == 2: self._state = 1 else: self._state = 0
def update(self): p = lambda: None [p, self._update_normal, self._update_bezier, self._update_bezier, p][self._state]() if self._thrusting: direction = self.direction() self.speed += SHIP_ACCEL * direction particle.thrust(self.pos - direction * 4, self.speed - direction * 2) if self._turning: self.theta += SHIP_ROTSPEED * self._turning self.rot = self.theta if self.autofire and self._trigger: self.fire() self.bullets.update() if self._health_vis > 0: self._health_vis -= SHIP_HEALTH_FADE
def update(self): # Choose the appropriate update function based on the current state p = lambda: None [p, self._update_normal, # 0 and 1 self._update_bezier, self._update_bezier, # 2 and 3 p][self._state]() # Thrusting? if self._thrusting: direction = self.direction() self.speed += SHIP_ACCEL * direction particle.thrust(self.pos-direction*4, self.speed - direction*2) if self._turning: self.theta += SHIP_ROTSPEED * self._turning self.rot = self.theta if self.autofire and self._trigger: self.fire() # update bullets self.bullets.update() if self._shield_vis > 0: self._shield_vis -= SHIP_SHIELD_FADE