diff --git a/avocado.py b/avocado.py index 787efbb..177aef4 100644 --- a/avocado.py +++ b/avocado.py @@ -62,10 +62,10 @@ class Avocado: self.has_been_pinned = True self.is_still_falling = False self.click.play() - return True + return True, self.rect.center else: self.clickFail.play() - return False + return False, (0, 0) # BUG - isHit is called 4 times upon click which makes it return the # first time but fail the consecutive times #else: diff --git a/game.py b/game.py index 0c12aa7..16f8f7e 100755 --- a/game.py +++ b/game.py @@ -106,7 +106,8 @@ class TheGame: gameOverImage = pygame.image.load("img/gameOver.png") gameOverText = self.bigFont.render('GAME OVER', 0, YELLOW) gameOverImage.blit(gameOverText, (screen_width/8, screen_height/7)) - self.screen.blit(pygame.transform.scale(gameOverImage, self.size), (0, 0)) + self.screen.blit(pygame.transform.scale(gameOverImage, + self.screen.get_size()), (0, 0)) pygame.display.flip() self.fadeSound() pygame.time.wait(3000) @@ -257,9 +258,10 @@ class TheGame: # Check if any avocados have been hit for avo in self.movingAvocados: - hit = avo.isHit(mousepos) + hit, center = avo.isHit(mousepos) if hit: score += 100 + newPin.throwAt(center) color = self.chooseRandomColor() crystalBall.setColor(color) elif hit == False: diff --git a/pingenerator.py b/pingenerator.py index 18bb84c..08e809d 100644 --- a/pingenerator.py +++ b/pingenerator.py @@ -13,11 +13,12 @@ class Generate: screen_width, screen_height = screen.get_size() self.pos = (screen_width / 2, screen_height) self.image = pygame.image.load(os.path.join('img','pin.png')).convert_alpha() - + self.size = self.image.get_size() def throwAt(self, target): self.inFlight = True - self.target = target + x, y = target + self.target = (x, y - self.size[1]) def isStuck(self): @@ -29,7 +30,6 @@ class Generate: def blitme(self): self.screen.blit(self.image, self.pos) - def moveTowardsTarget(self): ############################## #