You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
import pygame
|
|
import pymunk
|
|
|
|
from common.drawableItem import DrawableItem
|
|
from common.game.billiards.baseBilliard import BaseBilliard
|
|
from common.game.gameData import GameData
|
|
from config.sys import HOLE_RADIUS, BALL_RADIUS
|
|
from enums.color import GARY
|
|
|
|
|
|
class Hole(DrawableItem):
|
|
|
|
def __init__(self, pos, game_data: GameData):
|
|
self.__pos = pos
|
|
self.__game_data = game_data
|
|
pass
|
|
|
|
def draw(self, window: pygame.Surface):
|
|
pygame.draw.circle(window, GARY, self._get_relative_pos(self.__pos), HOLE_RADIUS)
|
|
|
|
def goal(self, space: pymunk.Space, balls: list[BaseBilliard]):
|
|
for _ in balls:
|
|
pos = pygame.Vector2(_.rigid_body.position.x - self.__pos[0], _.rigid_body.position.y - self.__pos[1])
|
|
if pos.length() <= HOLE_RADIUS:
|
|
_.rigid_body.position = pymunk.Vec2d(99999, 99999)
|
|
_.rigid_body.velocity = pymunk.Vec2d.zero()
|
|
_.activity = False
|
|
self.__game_data.goal_balls.append(_.category)
|
|
pass
|
|
|