Merge branch 'master' of github.com:lvl2/avocados
|
@ -68,6 +68,7 @@ class Avocado:
|
||||||
else:
|
else:
|
||||||
self.clickFail.play()
|
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
|
# BUG - isHit is called 4 times upon click which makes it return the
|
||||||
# first time but fail the consecutive times
|
# first time but fail the consecutive times
|
||||||
#else:
|
#else:
|
||||||
|
|
15
game.py
|
@ -34,6 +34,8 @@ class TheGame:
|
||||||
self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT))
|
self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT))
|
||||||
self.colors = [BLUE, GREEN, RED, YELLOW]
|
self.colors = [BLUE, GREEN, RED, YELLOW]
|
||||||
self.bg = pygame.image.load(os.path.join('img', 'lawyerCrystalBall.png'))
|
self.bg = pygame.image.load(os.path.join('img', 'lawyerCrystalBall.png'))
|
||||||
|
self.bg.set_colorkey((255,255,255))
|
||||||
|
self.bg.set_alpha(75)
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
self.bigFont = pygame.font.Font(None, 90)
|
self.bigFont = pygame.font.Font(None, 90)
|
||||||
|
@ -260,20 +262,31 @@ class TheGame:
|
||||||
# Check if any avocados have been hit
|
# Check if any avocados have been hit
|
||||||
for avo in self.movingAvocados:
|
for avo in self.movingAvocados:
|
||||||
hit, center = avo.isHit(mousepos)
|
hit, center = avo.isHit(mousepos)
|
||||||
|
if hit is None:
|
||||||
|
continue
|
||||||
if hit:
|
if hit:
|
||||||
score += 100
|
score += 100
|
||||||
newPin.throwAt(center)
|
newPin.throwAt(center)
|
||||||
color = self.chooseRandomColor()
|
color = self.chooseRandomColor()
|
||||||
crystalBall.setColor(color)
|
crystalBall.setColor(color)
|
||||||
elif hit == False:
|
else:
|
||||||
score -= 50
|
score -= 50
|
||||||
|
|
||||||
|
|
||||||
# Had enough of this?
|
# Had enough of this?
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
game.gameOver()
|
game.gameOver()
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
sys.exit()
|
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()
|
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 |