Merge branch 'master' of github.com:lvl2/avocados
|
@ -67,7 +67,8 @@ class Avocado:
|
|||
return True, self.rect.center
|
||||
else:
|
||||
self.clickFail.play()
|
||||
return False, (0, 0)
|
||||
return False, (0, 0)
|
||||
return None, (0, 0)
|
||||
# BUG - isHit is called 4 times upon click which makes it return the
|
||||
# first time but fail the consecutive times
|
||||
#else:
|
||||
|
|
15
game.py
|
@ -34,6 +34,8 @@ class TheGame:
|
|||
self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT))
|
||||
self.colors = [BLUE, GREEN, RED, YELLOW]
|
||||
self.bg = pygame.image.load(os.path.join('img', 'lawyerCrystalBall.png'))
|
||||
self.bg.set_colorkey((255,255,255))
|
||||
self.bg.set_alpha(75)
|
||||
|
||||
# fonts
|
||||
self.bigFont = pygame.font.Font(None, 90)
|
||||
|
@ -260,20 +262,31 @@ class TheGame:
|
|||
# Check if any avocados have been hit
|
||||
for avo in self.movingAvocados:
|
||||
hit, center = avo.isHit(mousepos)
|
||||
if hit is None:
|
||||
continue
|
||||
if hit:
|
||||
score += 100
|
||||
newPin.throwAt(center)
|
||||
color = self.chooseRandomColor()
|
||||
crystalBall.setColor(color)
|
||||
elif hit == False:
|
||||
else:
|
||||
score -= 50
|
||||
|
||||
|
||||
# Had enough of this?
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
game.gameOver()
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
if pygame.key.get_pressed()[pygame.K_f] != 0:
|
||||
print("Toggling full screen, in the Future")
|
||||
elif (pygame.key.get_pressed()[pygame.K_q] != 0) or (pygame.key.get_pressed()[pygame.K_ESCAPE] != 0):
|
||||
running = False
|
||||
game.gameOver()
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
|
|
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 33 KiB |