Tiny changes
parent
025f2e7e66
commit
ceb3316755
43
game.py
43
game.py
|
@ -22,9 +22,10 @@ class TheGame:
|
||||||
self.size = (800, 600)
|
self.size = (800, 600)
|
||||||
self.screen = pygame.display.set_mode(self.size)
|
self.screen = pygame.display.set_mode(self.size)
|
||||||
self.colors = [BLUE, GREEN, RED, YELLOW]
|
self.colors = [BLUE, GREEN, RED, YELLOW]
|
||||||
|
self.bg = pygame.image.load(os.path.join('img', 'lawyerCrystalBall.png'))
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
self.big = pygame.font.Font(None, 90)
|
self.bigFont = pygame.font.Font(None, 90)
|
||||||
|
|
||||||
self.pinned = []
|
self.pinned = []
|
||||||
|
|
||||||
|
@ -74,11 +75,11 @@ class TheGame:
|
||||||
def gameOver(self):
|
def gameOver(self):
|
||||||
screen_width, screen_height = self.size
|
screen_width, screen_height = self.size
|
||||||
gameOverImage = pygame.image.load("img/gameOver.png")
|
gameOverImage = pygame.image.load("img/gameOver.png")
|
||||||
gameOverText = self.big.render('GAME OVER', 0, YELLOW)
|
gameOverText = self.bigFont.render('GAME OVER', 0, YELLOW)
|
||||||
gameOverImage.blit(gameOverText, (screen_width/8, screen_height/6))
|
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.size), (0, 0))
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
self.fade()
|
self.fade() # Fade the music
|
||||||
pygame.time.wait(3000)
|
pygame.time.wait(3000)
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
@ -88,16 +89,20 @@ class TheGame:
|
||||||
self.pinned.append(avocado)
|
self.pinned.append(avocado)
|
||||||
|
|
||||||
|
|
||||||
|
def drawBackground(self):
|
||||||
|
if type(self.bg) is tuple:
|
||||||
|
self.screen.fill(self.bg)
|
||||||
|
else:
|
||||||
|
self.screen.blit(pygame.transform.scale(self.bg, self.size), (0, 0))
|
||||||
|
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
bg = pygame.image.load("img/lawyerCrystalBall.png")
|
|
||||||
desired_fps = 60
|
desired_fps = 60
|
||||||
multiplier = 3
|
multiplier = 3
|
||||||
score = 0
|
|
||||||
time = timeleft = 30
|
time = timeleft = 30
|
||||||
level = 1
|
level = 1
|
||||||
levelChange = 0
|
levelChange = 0
|
||||||
reachScore = 200
|
|
||||||
avoClick = self.loadClick()
|
avoClick = self.loadClick()
|
||||||
|
|
||||||
# initialize the HUD class and the lawyer
|
# initialize the HUD class and the lawyer
|
||||||
|
@ -108,7 +113,9 @@ class TheGame:
|
||||||
color = self.chooseRandomColor()
|
color = self.chooseRandomColor()
|
||||||
fullegast.setColor(color)
|
fullegast.setColor(color)
|
||||||
|
|
||||||
avocados = [] # We could use this for redrawing only this part
|
# We could use this list for redrawing only this part
|
||||||
|
# of the screen install of all of it
|
||||||
|
avocados = []
|
||||||
running = True
|
running = True
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
|
@ -116,27 +123,23 @@ class TheGame:
|
||||||
fps = clock.get_fps()
|
fps = clock.get_fps()
|
||||||
screen_width, screen_height = self.size
|
screen_width, screen_height = self.size
|
||||||
|
|
||||||
if type(bg) is tuple:
|
# Redraw the background and put our lawyer back on top
|
||||||
self.screen.fill(bg)
|
self.drawBackground()
|
||||||
else:
|
fullegast.blitme()
|
||||||
self.screen.blit(pygame.transform.scale(bg, self.size), (0, 0))
|
|
||||||
|
|
||||||
# Next level?
|
# Next level?
|
||||||
if score >= reachScore:
|
if score >= targetScore:
|
||||||
score = 0
|
self.score = 0
|
||||||
level += 1
|
level += 1
|
||||||
levelChange = 35
|
pauseFor = 35
|
||||||
timeleft = time
|
timeleft = time
|
||||||
avocados = []
|
avocados = []
|
||||||
self.pinned = []
|
self.pinned = []
|
||||||
print('DEBUG :: Level ' + str(level))
|
print('DEBUG :: Level ' + str(level))
|
||||||
game.playLevel(level)
|
self.playLevel(level)
|
||||||
|
|
||||||
# Let's add the lawyer
|
|
||||||
fullegast.blitme()
|
|
||||||
|
|
||||||
if levelChange > 0:
|
if levelChange > 0:
|
||||||
levelText = self.big.render('Level ' + str(level), 0, WHITE)
|
levelText = self.bigFont.render('Level ' + str(level), 0, WHITE)
|
||||||
self.screen.blit(levelText, (screen_width / 3, screen_height / 2))
|
self.screen.blit(levelText, (screen_width / 3, screen_height / 2))
|
||||||
levelChange -= 1
|
levelChange -= 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue