-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
29 lines (24 loc) · 823 Bytes
/
player.py
File metadata and controls
29 lines (24 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from config import Config
from line import Line
from vector import Vector
class Player:
def __init__(self, pos: Vector = None) -> None:
self.pos = pos
self.size = Config.player_size
self.height = Config.player_height
def get_vertices(self) -> list[Vector]:
x_offset = Vector(self.size/2, 0)
z_offset = Vector(0, self.height)
return [
self.pos - x_offset,
self.pos + x_offset,
self.pos + z_offset + x_offset,
self.pos + z_offset - x_offset,
]
def get_lines(self) -> list[Line]:
vertices = self.get_vertices()
vertices.append(vertices[0])
lines = []
for i in range(len(vertices) - 1):
lines.append(Line(vertices[i], vertices[i+1]))
return lines