Пример #1
0
 def draw(self, screen):
     for piece in self.pieces_of_food:
         color = pygame.Color(0, 0, 0)
         position = piece.position
         position = [utils.calculatePygameValue(position[0]), utils.calculatePygameValue(position[1])]
         radius = utils.calculatePygameValue(piece.fixtures[0].shape.radius)
         pygame.draw.circle(screen, color, position, radius)
Пример #2
0
 def removeOutsiders(self):
     i = 0
     while i < len(self.pieces_of_food):
         position = self.pieces_of_food[i].position
         position = [utils.calculatePygameValue(position[0]), utils.calculatePygameValue(position[1])]
         if position[1] > 600:
             self.removePieceAt(i)
         else:
             i += 1
Пример #3
0
 def updateScore(self):
     i = 0
     score = 0
     while i < len(self.pieces_of_food):
         position = self.pieces_of_food[i].position
         position = [utils.calculatePygameValue(position[0]), utils.calculatePygameValue(position[1])]
         if position[0] > 347 and position[0] < 445 and position[1] > 600:
             score += 1
             self.removePieceAt(i)
         else:
             i += 1
     if(score):
         self.chewing.stop()
         self.chewing.play()
     return score
Пример #4
0
 def getFoodInside(self, food_machine):
     ball_position = self.getPosition()
     radius = self.getRadius()
     i = 0
     while i < len(food_machine.pieces_of_food):
         piece_position = [utils.calculatePygameValue(food_machine.pieces_of_food[i].position[0]), utils.calculatePygameValue(food_machine.pieces_of_food[i].position[1])]
         if piece_position[0] > 145 and utils.distanceBetweenPoints(ball_position, piece_position) < radius:
             self.counter = self.counter + 1
             self.has_food_inside = True
             food_machine.removePieceAt(i)
         else:
             i = i + 1
Пример #5
0
 def draw(self, screen):
     color = pygame.Color(56, 159, 191)
     position = self.getPosition()
     radius = utils.calculatePygameValue(self.shape.radius)
     surface = pygame.Surface((2*radius, 2*radius))
     surface.fill((0,255,0))
     surface.set_colorkey((0,255,0))
     surface.set_alpha(200)
     pygame.draw.circle(surface, color, [radius,radius], radius)
     screen.blit(surface, [position[0]-radius, position[1]-radius, 2*radius, 2*radius])
     if(self.has_food_inside):
         half_radius = radius/2
         font = pygame.font.Font('gfx/font.ttf', half_radius)
         size = font.size(str(self.counter))
         text = font.render(str(self.counter), True, [50, 50, 150])
         screen.blit(text, [position[0]-size[0]/2, position[1]-size[1]/2])
Пример #6
0
 def getRadius(self):
     return utils.calculatePygameValue(self.shape.radius)
Пример #7
0
 def getPosition(self):
     return [utils.calculatePygameValue(self.body.position[0]), utils.calculatePygameValue(self.body.position[1])]
Пример #8
0
 def draw(self, screen):
     position = [utils.calculatePygameValue(self.body.position[0]), utils.calculatePygameValue(self.body.position[1])-80]
     screen.blit(self.image, position)