def __init__(self, x, y, center): self._click = x self._click2 = y self._x = center[0] self._y = center[1] Mobile_Simulton.__init__(self, self._x, self._y, 24, 24, 0, 15) self._angle = math.atan2(self._click2-center[1], self._click-center[0])
def __init__(self,x ,y, speed, recharge_time, capacity): '''Introduces two new attributes: recharge_time and capacity (for ammo)''' Mobile_Simulton.__init__(self, x, y, 10, 10, 0, speed) self._image = PhotoImage(file = "spaceship.gif") self._recharge_image = PhotoImage(file = "spaceship_recharge.gif") #new attributes self.charge = 0 #the charge time after the ship runs out of ammo self.bullets = capacity #ship starts out with fully loaded ammunition self.capacity = capacity #the max amount of ammo that the ship can carry self.recharge_time = recharge_time #the amount of time that it takes for the ship to reload
def update(self): eat = Pulsator.update(self) Mobile_Simulton.update(self) aim = model.find(lambda x: isinstance(x, Prey) and self.visible_distance(x.get_location())) if aim: first_target = min([s.get_location() for s in aim], key = lambda x: self.distance(x)) x,y = first_target self.set_angle(self.angle_to(x,y)) return eat
def __init__(self, x,y): Mobile_Simulton.__init__(self,x,y,Floater.radius*2,Floater.radius*2,random.random()*math.pi*2,5) self._image = PhotoImage(file='ufo.gif')
def __init__(self,x,y): Pulsator.__init__(self,x,y) w,h = self.get_dimension() Mobile_Simulton.__init__(self,x,y,w,h,0,5) self.randomize_angle()
def __init__(self, x, y): Pulsator.__init__(self, x, y) Mobile_Simulton.__init__(self, x, y, 20, 20, 0, 5) self.randomize_angle()
def __init__(self, x,y, angle, radius, color): '''Projectiles are circles, so the radius determines its size''' self.radius = radius self.color = color Mobile_Simulton.__init__(self, x, y, radius*2, radius*2, angle, 8)
def __init__(self, x, y): Mobile_Simulton.__init__(self, x, y, self.radius*2, self.radius*2, 1, 5) Pulsator.__init__(self, x, y) self.randomize_angle()
def __init__(self,x,y): Pulsator.__init__(self, x, y) Mobile_Simulton.__init__(self, x, y, self._width, self._height, 0, 5) self.randomize_angle()
def __init__(self, x, y): Black_Hole.__init__(self, x, y) Mobile_Simulton.__init__(self, x, y, 2*self.radius, 2*self.radius, 0, 5) self.randomize_angle() self.color = 'Orange' self.end_of_chain = self
def __init__(self,x,y,width,height,angle,speed): Mobile_Simulton.__init__(self,x,y,width,height,angle,speed)
def __init__(self, x, y): Pulsator.__init__(self,x,y) Mobile_Simulton.__init__(self,x,y, width = 10 * 2, height = 10 * 2, angle = random()* math.pi ,speed = 5)
def __init__ (self, x, y): Mobile_Simulton.__init__(self, x, y, 20, 20, 0, 5) self.randomize_angle() self._counter = 30
def __init__(self,x,y,size = 20): Pulsator.__init__(self,x,y) Mobile_Simulton.__init__(self, x, y, self.radius, self.radius, random.random()*math.pi*2,5) self.set_dimension(size, size) self._image = PhotoImage(Image.open('deathstar.gif').convert('RGBA').resize((size, size), Image.ANTIALIAS)) self.radius = (self._image.height()/2)+((self._image.width()**2)/(8 * self._image.height()))
def __init__(self, x, y, width=30, height=30, angle=radians(90), speed=8): Mobile_Simulton.__init__(self, x, y, width, height, angle, speed) self._color = "#ff1493" self.counter = 0 self.changed = set()