I am making a game called Pizza Panic, which basically is a guy throwing pizzas down and you have to catch them. Now I want to increase the difficulty level once the player has reached certain scores. But when I try to increase the pizza's speed, the whole game seems to slow down. Below is my code:
class Pan(games.Sprite):
image = games.load_image("pan.bmp", transparent=True)
def __init__(self):
super(Pan, self).__init__(image=Pan.image,
bottom=games.screen.height,
x=games.mouse.x)
self.score = games.Text(value=0, size=25, color=color.black, right=games.screen.width-10, top=10)
games.screen.add(self.score)
self.level = 0
def update(self):
self.x = games.mouse.x
if self.left < 0:
self.left = 0
if self.right > games.screen.width:
self.right = games.screen.width
self.check_collide()
if self.score.value > 200:
text = games.Message(value='Increased difficulty',
color=color.red,
size=60,
x=games.screen.width/2,
y=games.screen.height/2,
lifetime=100,
after_death=Pizza.increased_speed)
games.screen.add(text)
def check_collide(self):
for pizza in self.overlapping_sprites:
self.score.value += 10
self.score.right = games.screen.width-10
pizza.handle_caught()
class Pizza(games.Sprite):
image = games.load_image('pizza.bmp')
speed = 1
def __init__(self, x=90, y=90):
super(Pizza, self).__init__(image=Pizza.image,
y=y,
x=x,
dy=Pizza.speed)
def handle_caught(self):
self.destroy()
def update(self):
if self.bottom > games.screen.height:
self.end_game()
self.destroy()
def end_game(self):
end_message = games.Message(value='GAME OVER',
size=90,
color=color.red,
x=games.screen.width / 2,
y=games.screen.height / 2,
lifetime=4 * games.screen.fps,
after_death=games.screen.quit)
games.screen.add(end_message)
@staticmethod
def increased_speed():
Pizza.speed = 2