def win_animation(self): ship_position = self.main_win.objects[self.p1.stacking_order].x1 distance = self.main_win.max_x - ship_position + 2 self.main_win.auto_refresh = False self.main_win.show(self.p1.thruster) self.p1.thruster.step = 1 speed = 0.25 while distance >= 0: self.main_win.move_relative(self.p1, x=1) self.p1.thruster.update() self.main_win.move_relative(self.p1.thruster, x=1) self.main_win.refresh() time.sleep(speed) speed -= 0.005 if speed < 0.04: speed = 0.04 distance -= 1 self.main_win.auto_refresh = True msg = Alert('!!! CONGRATULATIONS !!!\nTHE GUMMIES HAVE BEEN SAVED') msg.show(self.main_win) time.sleep(3) msg.hide()
def intro(self): self.midpoint_x = round( self.main_win.width * (self.screens - 0.5)/self.screens ) midpoint_y = self.main_win.height // 2 outline = Outline(self.p2) self.main_win.add_object( outline, self.midpoint_x + self.ship_space - 1, midpoint_y - self.p2.height // 2 - 1 ) outline = Outline(self.p1) self.main_win.add_object( outline, self.midpoint_x - self.ship_space - self.p1.width, midpoint_y - self.p1.height // 2 - 1 ) self.main_win.add_object( self.p2, self.midpoint_x + self.ship_space, midpoint_y - self.p2.height // 2 ) self.main_win.add_object( self.p1, 4, midpoint_y - self.p1.height // 2 ) self.main_win.add_object( self.p1.thruster, 2, midpoint_y + 1 ) self.main_win.display(0, 7) self.main_win.auto_refresh = False position = self.p1.scene.objects[self.p1.stacking_order] distance = self.midpoint_x - self.ship_space - position.x2 speed = 0.04 while distance > 0: self.main_win.move_relative(self.p1, x=1) self.main_win.move_relative(self.p1.thruster, x=1) self.p1.thruster.update() self.main_win.pan(x=1) self.main_win.refresh() time.sleep(speed) if distance == 40: self.main_win.hide(self.p1.thruster) if distance < 40: speed += 0.005 distance -= 1 msg = Alert('!!! WARNING !!!\nENEMY WEAPONS LOCKED') msg.show(self.main_win) self.main_win.refresh() time.sleep(3) msg.hide() self.main_win.refresh()
def lose_animation(self): msg = Alert('YOUR SHIP HAS BEEN DESTROYED') msg.show(self.main_win) time.sleep(5) msg.hide()