Slightly better balance
commit
feea1079e9
13
avocado.py
13
avocado.py
|
@ -5,16 +5,7 @@ from support import operations
|
||||||
|
|
||||||
class Avocado:
|
class Avocado:
|
||||||
|
|
||||||
def __init__(self, screen, color, size, target, filename='img/AvoCado_0.png'):
|
def __init__(self, screen, color, size, target, level, filename='img/AvoCado_0.png'):
|
||||||
|
|
||||||
# HELP please!!
|
|
||||||
# We randomly decide whether we should instanciate or not
|
|
||||||
# I'd rather just not return an instance,
|
|
||||||
# but I don't know how to do that :(
|
|
||||||
if random.randint(0,40) != 1:
|
|
||||||
self.is_still_falling = False
|
|
||||||
self.has_been_pinned = False
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Set up our instance variables
|
# Set up our instance variables
|
||||||
self.screen = screen
|
self.screen = screen
|
||||||
|
@ -32,7 +23,7 @@ class Avocado:
|
||||||
# Set the avocado's initial position and velocity
|
# Set the avocado's initial position and velocity
|
||||||
self.init_pos()
|
self.init_pos()
|
||||||
self.vx = 2
|
self.vx = 2
|
||||||
self.vy = 4
|
self.vy = 4 * (level * 0.5)
|
||||||
|
|
||||||
# Avocado state
|
# Avocado state
|
||||||
self.is_still_falling = True
|
self.is_still_falling = True
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Crystal:
|
||||||
self.imageCenterY = self.screen.get_rect().centery
|
self.imageCenterY = self.screen.get_rect().centery
|
||||||
|
|
||||||
def blitme(self):
|
def blitme(self):
|
||||||
pygame.draw.ellipse(self.screen, self.color, (self.imageCenterX-158,self.imageCenterY-5,277,217), 0)
|
pygame.draw.ellipse(self.screen, self.color, (self.imageCenterX-100,self.imageCenterY-5,200,183), 0)
|
||||||
|
|
||||||
def setColor(self, color):
|
def setColor(self, color):
|
||||||
self.color = color
|
self.color = color
|
||||||
|
|
13
game.py
13
game.py
|
@ -35,7 +35,7 @@ class TheGame:
|
||||||
# fonts
|
# fonts
|
||||||
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("img/splashScreen.png")
|
||||||
self.screen.blit(pygame.transform.scale(splashScreen, self.size), (0, 0))
|
self.screen.blit(pygame.transform.scale(splashScreen, self.size), (0, 0))
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
@ -108,7 +108,11 @@ class TheGame:
|
||||||
def main(self):
|
def main(self):
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
desired_fps = 60
|
desired_fps = 60
|
||||||
multiplier = 3
|
# Never set below 4, else we have a high
|
||||||
|
# probability of losing the game due to a missing color
|
||||||
|
# Alternatively, you could edit chooseRandomColor()
|
||||||
|
# to only work on the first multiplier colors
|
||||||
|
multiplier = 4
|
||||||
time = timeleft = 30
|
time = timeleft = 30
|
||||||
level = 1
|
level = 1
|
||||||
levelChange = 0
|
levelChange = 0
|
||||||
|
@ -169,10 +173,11 @@ class TheGame:
|
||||||
avocadosInGame = len(movingAvocados)
|
avocadosInGame = len(movingAvocados)
|
||||||
avocadosWanted = level * multiplier
|
avocadosWanted = level * multiplier
|
||||||
if avocadosInGame < avocadosWanted:
|
if avocadosInGame < avocadosWanted:
|
||||||
for i in range(avocadosInGame, avocadosWanted):
|
probability = int(1.0/(avocadosWanted - avocadosInGame) * 100)
|
||||||
|
if random.randint(0, probability) < 3:
|
||||||
avocolor = self.chooseRandomColor()
|
avocolor = self.chooseRandomColor()
|
||||||
avosize = (50, 50) # should we randomize this?
|
avosize = (50, 50) # should we randomize this?
|
||||||
a = avocado.Avocado(self.screen, avocolor, avosize, color)
|
a = avocado.Avocado(self.screen, avocolor, avosize, color, level)
|
||||||
movingAvocados.append(a)
|
movingAvocados.append(a)
|
||||||
|
|
||||||
pinnedAvocados += [avo for avo in movingAvocados if avo.isPinned() ]
|
pinnedAvocados += [avo for avo in movingAvocados if avo.isPinned() ]
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.7 MiB |
Loading…
Reference in New Issue