def tick(self) : if self.inputLeft.pressed() : self.getActor().adjustDirection( self.rotationSpeed ) if self.inputRight.pressed() : self.getActor().adjustDirection( -self.rotationSpeed ) if self.inputThrust.pressed() : theta = self.getActor().getHeadingRadians() self.vx += math.cos(theta) * self.thrust self.vy += math.sin(theta) * self.thrust heading = self.getActor().getDirection() ExplosionBuilder(self.getActor()) \ .projectiles(4).follow().projectilesPerTick(1) \ .spread(heading+160, heading+200).distance(40) \ .randomSpread().speed(1,2,0,0).fade(3).eventName("spark") \ .create() if self.fireTimer == None or self.fireTimer.isFinished() : if self.inputFire.pressed() : if self.fireTimer is None : firePeriod = self.actor.costume.getCompanion(self.bulletName).costumeFeatures.firePeriod self.fireTimer = Timer.createTimerSeconds(firePeriod) self.fire() self.fireTimer.reset() if self.inputWeapon1.pressed() : self.bulletName = "bullet-1" self.fireTimer = None if self.inputWeapon2.pressed() : self.bulletName = "bullet-2" self.fireTimer = None # Move and wrap from one edge of the world to the opposite. Moving.tick(self) if self.collided("deadly") : self.explode() # For debugging. if self.inputCheat.pressed() : game.getSceneDirector().addRocks(-1)
def tick(self): Moving.tick(self) self.actor.appearance.direction += self.rotationSpeed
def tick(self) : Moving.tick(self) if self.actor.appearance.alpha < 20 : self.actor.kill() return for role in self.collisions("shootable") : if not role.getActor().isDying() : role.shot(self) self.getActor().kill() return