feat: render car
This commit is contained in:
19
src/game.py
19
src/game.py
@@ -48,6 +48,12 @@ class Game:
|
|||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
self.win.fill(self.BACKGROUND_COLOR)
|
self.win.fill(self.BACKGROUND_COLOR)
|
||||||
|
self.render_track()
|
||||||
|
self.render_car()
|
||||||
|
|
||||||
|
pygame.display.flip()
|
||||||
|
|
||||||
|
def render_track(self):
|
||||||
road: Road = self.track.objects[0] # type: ignore
|
road: Road = self.track.objects[0] # type: ignore
|
||||||
|
|
||||||
side1: list[Vec] = []
|
side1: list[Vec] = []
|
||||||
@@ -64,4 +70,15 @@ class Game:
|
|||||||
|
|
||||||
pygame.draw.lines(self.win, (255, 255, 255), True, side1)
|
pygame.draw.lines(self.win, (255, 255, 255), True, side1)
|
||||||
pygame.draw.lines(self.win, (255, 255, 255), True, side2)
|
pygame.draw.lines(self.win, (255, 255, 255), True, side2)
|
||||||
pygame.display.flip()
|
|
||||||
|
def render_car(self):
|
||||||
|
u: Vec = self.car.direction * 0.3
|
||||||
|
v: Vec = self.car.direction.perp * 0.2
|
||||||
|
pt: Vec = self.car.pos
|
||||||
|
p1: Vec = pt + u + v
|
||||||
|
p2: Vec = pt - u + v
|
||||||
|
p3: Vec = pt - u - v
|
||||||
|
p4: Vec = pt + u - v
|
||||||
|
pts: list[Vec] = [p1, p2, p3, p4]
|
||||||
|
pts = [self.camera.world2screen(p) for p in pts]
|
||||||
|
pygame.draw.polygon(self.win, (230, 150, 80), pts)
|
||||||
|
|||||||
Reference in New Issue
Block a user