# plane 0 name = 'plane0' type = 'gif' from baseairobj import * image = None import random DY_CHANGE_INTERVAL = 20 DY = 0.2 TOP = game.arena.top BOTTOM = game.arena.bottom-70 def load_game_resources(): global image, name image = gfx.load('%s.%s' % (name,type)) class Plane0(AirObj): def __init__(self): global name,image AirObj.__init__(self,name,image) self.dx = -3 * game.groundspeed self.timer = 0 def tick(self, speedadjust): self.x += self.dx * speedadjust if self.x < 0 - self.rect.width: self.dead = 1 self.timer += 1 if self.timer % DY_CHANGE_INTERVAL == 0: sign = random.randrange(0,3) - 1 self.dy += DY * sign self.y += self.dy * speedadjust if self.y < TOP: self.y = TOP elif self.y > BOTTOM: self.y = BOTTOM self.rect.topleft = [self.x,self.y]