class Gem(Sprite): def on_create(self): self.image = random.choice([ "gem_shiny01.png", "gem_shiny02.png", "gem_shiny03.png", "gem_shiny04.png", "gem_shiny05.png" ]) self.scale = float(0.34) self.goto_random_position() self.y = 600 def on_update(self, dt): self.y -= 5 if is_aabb_collision(self, player): self.delete() player.point += 1 print(player.point) elif self.y <= 0: self.delete() player.point -= 1 print(player.point) def wow(dt): w.create_sprite(Gem) Scheduler.update(wow, delay=1) w.run()
animal = input("Please enter the animal you want to see:") size = input("Do you want your animal to be big or small or not?") #x=input("How about the x?") #y=input("How about the y?") left = input("Do you want your animal at left or right or not?") point = input("Do you want your animal point left or right?") #placex=float(x) #placey=float(y) animal_png = window.create_sprite() animal_png.opacity = 250 animal_png.x = animal_png.x + 650 animal_png.y = animal_png.y + 350 #animal_png.x=animal_png.x+placex #animal_png.y=animal_png.y+placey if animal == "elephant": animal_png.image = "elephant.png" if animal == "owl": animal_png.image = "owl.gif" if size == "big": animal_png.scale = 2 if size == "small": animal_png.scale = 0.5 if left == "left": animal_png.x = 550 if left == "right": animal_png.x = 750 if point == "left": animal_png.scale_x = -1 print("here is your animal." "position:x=", animal_png.x, "y=", animal_png.y) window.run()
class Wowow(Sprite): def on_create(self): self.image = "rooster.png" self.x = 1160 self.y = 50 def on_update(self, dt): if o.get_key(KeyCode.I): self.rotation = 90 self.move_forward(10) if o.get_key(KeyCode.K): self.rotation = 270 self.move_forward(10) if o.get_key(KeyCode.J): self.rotation = 180 self.move_forward(10) if o.get_key(KeyCode.L): self.rotation = 0 self.move_forward(10) if self.touching_any_sprite(): print('Oh Yeah!') o.exit() oh = o.create_sprite(Wow) ohma = o.create_sprite(Wowow) o.run()