parent
fd2f247d78
commit
37f6daab71
12
avocado.py
12
avocado.py
|
@ -1,22 +1,28 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import pygame, random
|
import pygame, random, os
|
||||||
from support import operations
|
from support import operations
|
||||||
|
|
||||||
class Avocado:
|
class Avocado:
|
||||||
|
|
||||||
def __init__(self, screen, color, size, target, level, filename='img/AvoCado_0.png'):
|
def __init__(self, screen, color, size, target, level, filename=os.path.join('img', 'AvoCado_0_PINK.png')):
|
||||||
|
|
||||||
# Set up our instance variables
|
# Set up our instance variables
|
||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.color = color
|
self.color = color
|
||||||
|
self.avocados = {(255,0,0): os.path.join('img', 'AvoCado_0_RED.png'), \
|
||||||
|
(0,255,0): os.path.join('img', 'AvoCado_0_GREEN.png'), \
|
||||||
|
(0,0,255): os.path.join('img', 'AvoCado_0_BLUE.png'), \
|
||||||
|
(255,255,0): os.path.join('img', 'AvoCado_0_YELLOW.png'), \
|
||||||
|
(255,192,203): os.path.join('img', 'AvoCado_0_PINK.png')}
|
||||||
|
self.filename = self.avocados[self.color]
|
||||||
self.target = target
|
self.target = target
|
||||||
self.screen_width, self.screen_height = screen.get_size()
|
self.screen_width, self.screen_height = screen.get_size()
|
||||||
self.w, self.y = size
|
self.w, self.y = size
|
||||||
|
|
||||||
# Initialize the image
|
# Initialize the image
|
||||||
self.i = pygame.image.load(filename).convert_alpha()
|
self.i = pygame.image.load(filename).convert_alpha()
|
||||||
operations.color_surface(self.i, color)
|
self.i = pygame.image.load(self.filename)
|
||||||
self.image = pygame.transform.scale(self.i, (self.w, self.y))
|
self.image = pygame.transform.scale(self.i, (self.w, self.y))
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
|
|
||||||
|
|
6
game.py
6
game.py
|
@ -25,7 +25,7 @@ class TheGame:
|
||||||
self.level = 1
|
self.level = 1
|
||||||
self.targetScore = 400
|
self.targetScore = 400
|
||||||
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 = [RED, GREEN, BLUE, YELLOW, PINK]
|
||||||
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_colorkey((255,255,255))
|
||||||
self.bg.set_alpha(75)
|
self.bg.set_alpha(75)
|
||||||
|
@ -34,7 +34,7 @@ class TheGame:
|
||||||
self.bigFont = pygame.font.Font(None, 90)
|
self.bigFont = pygame.font.Font(None, 90)
|
||||||
|
|
||||||
# Set splashscreen
|
# Set splashscreen
|
||||||
splashScreen = pygame.image.load("img/splashScreen.png")
|
splashScreen = pygame.image.load(os.path.join('img', 'splashScreen.png'))
|
||||||
self.screen.blit(
|
self.screen.blit(
|
||||||
pygame.transform.scale(
|
pygame.transform.scale(
|
||||||
splashScreen, (self.WIDTH, self.HEIGHT)
|
splashScreen, (self.WIDTH, self.HEIGHT)
|
||||||
|
@ -98,7 +98,7 @@ class TheGame:
|
||||||
|
|
||||||
def gameOver(self):
|
def gameOver(self):
|
||||||
screen_width, screen_height = self.screen.get_size()
|
screen_width, screen_height = self.screen.get_size()
|
||||||
gameOverImage = pygame.image.load("img/gameOver.png")
|
gameOverImage = pygame.image.load(os.path.join('img', 'gameOver.png'))
|
||||||
gameOverText = self.bigFont.render('GAME OVER', 0, YELLOW)
|
gameOverText = self.bigFont.render('GAME OVER', 0, YELLOW)
|
||||||
gameOverImage.blit(gameOverText, (screen_width/8, screen_height/7))
|
gameOverImage.blit(gameOverText, (screen_width/8, screen_height/7))
|
||||||
self.screen.blit(pygame.transform.scale(gameOverImage,
|
self.screen.blit(pygame.transform.scale(gameOverImage,
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Loading…
Reference in New Issue