def main(): fateImage = games.load_image("nebula.jpg", transparent=False) games.screen.background = fateImage chefImage = games.load_image("explosion1.bmp") chefPosX = random.randrange(games.screen.width) chefPosY = random.randrange(games.screen.height) chef = Chef(image=chefImage, x=chefPosX, y=chefPosY) games.screen.add(chef) explosionFiles = [ "explosion1.bmp", "explosion2.bmp", "explosion3.bmp", "explosion4.bmp", "explosion5.bmp", "explosion6.bmp", "explosion7.bmp", "explosion8.bmp", "explosion9.bmp", ] explosion = games.Animation(images=explosionFiles, x=games.screen.width / 2, y=games.screen.height / 2, n_repeats=0, repeat_interval=5) mouseFollow = FollowMouse(image=explosion) games.screen.add(mouseFollow) games.mouse.is_visible = False games.screen.event_grab = True games.screen.mainloop()
def main(): earth_image = games.load_image('earth.jpg', transparent=False) games.screen.background = earth_image ship_image = games.load_image('ship.bmp') the_ship = Ship(image=ship_image, x=games.screen.width / 2, y=games.screen.height / 2) games.screen.add(the_ship) explosion_files = ['explosion1.bmp', 'explosion2.bmp', 'explosion3.bmp', 'explosion4.bmp', 'explosion5.bmp', 'explosion6.bmp', 'explosion7.bmp', 'explosion8.bmp', 'explosion9.bmp'] explosion = games.Animation(images=explosion_files, x=480, y=240, n_repeats=0, repeat_interval=5) games.screen.add(explosion) games.screen.mainloop()
def die(self): '''Destroys itself''' global user_dead self.destroy() x = self.x y = self.y #Play explosion animation explosion = games.Animation(images=explosion_files, is_collideable=False, x=x, y=y, n_repeats=1, repeat_interval=3) games.screen.add(explosion) Create_spaceship.explosion_sound.play() user_dead = True
def die(self): '''Will destroy itself''' global enemy_count self.destroy() enemy_count -= 1 x = self.x y = self.y explosion = games.Animation(images=explosion_files, is_collideable=False, x=x, y=y, n_repeats=1, repeat_interval=3) games.screen.add(explosion) Enemy.explosion_sound.play() global score_value score_value += 50
# Explosion # Demonstrates creating an animation from livewires import games games.init(screen_width=640, screen_height=480, fps=50) nebula_image = games.load_image("nebula.jpg", transparent=0) games.screen.background = nebula_image explosion_files = [ "explosion1.bmp", "explosion2.bmp", "explosion3.bmp", "explosion4.bmp", "explosion5.bmp", "explosion6.bmp", "explosion7.bmp", "explosion8.bmp", "explosion9.bmp" ] explosion = games.Animation(images=explosion_files, x=games.screen.width / 2, y=games.screen.height / 2, n_repeats=0, repeat_interval=5) games.screen.add(explosion) games.screen.mainloop()
from livewires import games games.init(screen_width=600, screen_height=489, fps=50) pitch_image = games.load_image('pitch.png', transparent=False) games.screen.background = pitch_image goal_images = [ '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png', '10.png', '11.png', '10.png', '9.png', '8.png', '7.png', '6.png', '5.png', '4.png', '3.png', '2.png' ] goal = games.Animation(images=goal_images, x=300, y=290, repeat_interval=8, n_repeats=0, is_collideable=False) games.screen.add(goal) games.screen.mainloop()
from livewires import games games.init(screen_width = 640, screen_height = 480, fps = 50) wallImage = games.load_image("waterbackground.jpg", transparent = False) games.screen.background = wallImage bloodExplosionFiles = ["bloodexplosion1.jpg", "bloodexplosion2.jpg", "bloodexplosion3.jpg", "bloodexplosion4.jpg",] bloodExplosion = games.Animation(images = bloodExplosionFiles, x = games.screen.width/2, y = games.screen.height/2, n_repeats = 0, repeat_interval = 20) games.screen.add(bloodExplosion) games.screen.mainloop()
from livewires import games games.init(screen_width=640, screen_height=480, fps=50) wall_image = games.load_image('mglawica.jpg', transparent=False) games.screen.background = wall_image explosions_images = [ 'eksplozja1.bmp', 'eksplozja2.bmp', 'eksplozja3.bmp', 'eksplozja4.bmp', 'eksplozja5.bmp', 'eksplozja6.bmp', 'eksplozja7.bmp', 'eksplozja8.bmp', 'eksplozja9.bmp' ] explosions = games.Animation( images=explosions_images, x=games.screen.width / 2, y=games.screen.height / 2, n_repeats= 0, # ustawiam ile razy ma być powatarza animacja. Ustawienie na 0 spowoduje że bez się powtarzać bez przerwy repeat_interval=15) # ustawienie jak szybko animacja ma przebiegać games.screen.add(explosions) games.screen.mainloop()