diff --git a/avocado.py b/avocado.py index 81961c9..a067e18 100644 --- a/avocado.py +++ b/avocado.py @@ -47,12 +47,13 @@ class Avocado: Checks whether this object collides with the given position in click """ - #if collision and … - if self.color == self.select: + mousex, mousey = click + if self.pycard.left < mousex and self.pycard.right > mousex and \ + self.pycard.top < mousey and self.pycard.bottom > mousey and \ + self.color == self.select: self.destroy() return True - def destroy(self): """destroys this object""" del(self) diff --git a/game.py b/game.py index 0dd2a18..c4cd111 100755 --- a/game.py +++ b/game.py @@ -66,10 +66,13 @@ def main(): timeleft -= time_passed / 1000 timeleft = round(timeleft, 2) + if timeleft <= 0: screen_width, screen_height = size screen.blit(game_over, (screen_width/3, screen_height/2)) displaytime = 'Timed out!' + pygame.display.flip() + continue else: displaytime = timeleft @@ -98,7 +101,7 @@ def main(): for avo in avocados: if avo.collides(pygame.mouse.get_pos()): score += 100 - + avo.init_pos() # Had enough of this? if event.type == pygame.QUIT: running = False