-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cars.py
43 lines (33 loc) · 1.19 KB
/
Cars.py
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
30
31
32
33
34
35
36
37
38
39
40
41
class Car:
def __init__(self, position, velocity):
self.position = position
self.velocity = velocity
self.collisionbox = [[], []]
def GetVel(self):
return self.velocity
def GetPos(self):
return self.position
def updatePos(self):
self.collisionbox[0] = [self.position-1, self.position +1]
self.position += self.velocity
if self.position >=500:
self.collisionbox[0] = [0,0]
self.collisionbox[1] = [0, 0]
else:
self.collisionbox[1] = [self.position-1, self.position+1]
def CollisionBox(self):
return self.collisionbox
def updateVeloc(self, inputvel):
self.velocity = inputvel
class PlayerCar(Car):
def __init__(self, position, velocity):
super().__init__(position, velocity)
self.velchange = 0
def updatePos(self):
self.collisionbox[0] = [self.position - 1, self.position + 1]
self.position += self.velocity
self.collisionbox[1] = [self.position - 1, self.position + 1]
def updateVeloc(self, inputvel):
temp = self.velocity
self.velocity = inputvel
self.velchange = self.velocity - temp