next level

master
David Raison 2014-08-30 22:48:49 +02:00
parent 3ff7fac4dc
commit 4ecc9bf928
2 changed files with 17 additions and 8 deletions

View File

@ -36,6 +36,7 @@ class Avocado:
self.is_falling = True self.is_falling = True
self.has_been_pinned = False self.has_been_pinned = False
def updateTargetColor(self, targetColor): def updateTargetColor(self, targetColor):
self.target = targetColor self.target = targetColor

24
game.py
View File

@ -43,7 +43,11 @@ class TheGame:
#size = initialize_screen() #size = initialize_screen()
size = (800, 600) size = (800, 600)
bg = pygame.image.load("img/background.png") bg = pygame.image.load("img/background.png")
desired_fps = 10 desired_fps = 15
multiplier = 6
score = 0
time = timeleft = 30
level = 1
font = pygame.font.Font(None, 40) font = pygame.font.Font(None, 40)
# I don't know, should we move this text out of the way? # I don't know, should we move this text out of the way?
@ -60,20 +64,23 @@ class TheGame:
color = self.chooseRandomColor() color = self.chooseRandomColor()
fullegast.setColor(color) fullegast.setColor(color)
score = 0
time = timeleft = 15
level = 5
avocados = [] avocados = []
running = True running = True
while running: while running:
time_passed = clock.tick(desired_fps) time_passed = clock.tick(desired_fps)
fps = clock.get_fps() fps = clock.get_fps()
if type(bg) is tuple: if type(bg) is tuple:
screen.fill(bg) screen.fill(bg)
else: else:
screen.blit(pygame.transform.scale(bg,(800,600)),(0,0)) screen.blit(pygame.transform.scale(bg, (800, 600)), (0, 0))
# Next level?
if score >= 500:
score = 0
level += 1
print('DEBUG :: Level ' + string(level))
# Let's add the lawyer # Let's add the lawyer
fullegast.blitme() fullegast.blitme()
@ -94,8 +101,9 @@ class TheGame:
# Initialize a number of avocados, depending on the level # Initialize a number of avocados, depending on the level
avocados_in_game = len(avocados) avocados_in_game = len(avocados)
if avocados_in_game != level: avocadosWanted = level * multiplier
for i in range(avocados_in_game, level): if avocados_in_game < avocadosWanted:
for i in range(avocados_in_game, avocadosWanted):
avocolor = self.chooseRandomColor() avocolor = self.chooseRandomColor()
avosize = (50, 50) # should we randomize this? avosize = (50, 50) # should we randomize this?
a = avocado.Avocado(screen, avocolor, avosize, color, noSound) a = avocado.Avocado(screen, avocolor, avosize, color, noSound)