feat: draw track borders
This commit is contained in:
17
src/game.py
17
src/game.py
@@ -49,8 +49,19 @@ class Game:
|
||||
def render(self):
|
||||
self.win.fill(self.BACKGROUND_COLOR)
|
||||
road: Road = self.track.objects[0] # type: ignore
|
||||
|
||||
side1: list[Vec] = []
|
||||
side2: list[Vec] = []
|
||||
|
||||
for i, pt in enumerate(road.pts):
|
||||
pos: Vec = self.camera.world2screen(pt.pos)
|
||||
col: float = i * 10 + 150
|
||||
pygame.draw.circle(self.win, (col, 100, 100), pos, 5)
|
||||
p1: Vec = pt.pos
|
||||
p2: Vec = p1 + pt.normal * pt.width
|
||||
p3: Vec = p1 - pt.normal * pt.width
|
||||
side1.append(self.camera.world2screen(p2))
|
||||
side2.append(self.camera.world2screen(p3))
|
||||
col: tuple[float, float, float] = (i * 10 + 150, 100, 100)
|
||||
pygame.draw.circle(self.win, col, self.camera.world2screen(p1), 5)
|
||||
|
||||
pygame.draw.lines(self.win, (255, 255, 255), True, side1)
|
||||
pygame.draw.lines(self.win, (255, 255, 255), True, side2)
|
||||
pygame.display.flip()
|
||||
|
||||
@@ -41,9 +41,9 @@ class Track:
|
||||
|
||||
|
||||
class RoadPoint:
|
||||
def __init__(self, pos: Vec, direction: Vec, width: float) -> None:
|
||||
def __init__(self, pos: Vec, normal: Vec, width: float) -> None:
|
||||
self.pos: Vec = pos
|
||||
self.direction: Vec = direction
|
||||
self.normal: Vec = normal.normalized
|
||||
self.width: float = width
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user