Slightly better balance
commit
feea1079e9
13
avocado.py
13
avocado.py
|
@ -5,16 +5,7 @@ from support import operations
|
|||
|
||||
class Avocado:
|
||||
|
||||
def __init__(self, screen, color, size, target, 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
|
||||
def __init__(self, screen, color, size, target, level, filename='img/AvoCado_0.png'):
|
||||
|
||||
# Set up our instance variables
|
||||
self.screen = screen
|
||||
|
@ -32,7 +23,7 @@ class Avocado:
|
|||
# Set the avocado's initial position and velocity
|
||||
self.init_pos()
|
||||
self.vx = 2
|
||||
self.vy = 4
|
||||
self.vy = 4 * (level * 0.5)
|
||||
|
||||
# Avocado state
|
||||
self.is_still_falling = True
|
||||
|
|
|
@ -16,7 +16,7 @@ class Crystal:
|
|||
self.imageCenterY = self.screen.get_rect().centery
|
||||
|
||||
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):
|
||||
self.color = color
|
||||
|
|
11
game.py
11
game.py
|
@ -108,7 +108,11 @@ class TheGame:
|
|||
def main(self):
|
||||
clock = pygame.time.Clock()
|
||||
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
|
||||
level = 1
|
||||
levelChange = 0
|
||||
|
@ -169,10 +173,11 @@ class TheGame:
|
|||
avocadosInGame = len(movingAvocados)
|
||||
avocadosWanted = level * multiplier
|
||||
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()
|
||||
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)
|
||||
|
||||
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