-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAI.py
More file actions
52 lines (46 loc) · 1.73 KB
/
Copy pathAI.py
File metadata and controls
52 lines (46 loc) · 1.73 KB
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
42
43
44
45
46
47
48
49
50
51
52
from Ship import Ship
from kivy.vector import Vector
from abc import ABCMeta, abstractmethod
class AI(Ship):
mass = 1000000
cooldown = {
"Bullet": 0,
}
selected_ammo = "Bullet"
weapon = "Cannon"
heat = {
# (heat value, overheat(planned), thruster down timer(planned))
"forward_t": [0, 0, 0],
"backward_t": [0, 0, 0],
"left_t": [0, 0, 0],
"right_t": [0, 0, 0],
"weapon_1": [0, 0, 0]
}
def __init__(self, user, *args, **kwargs):
self.user = user
self.source = 'img/usership.png'
super().__init__(*args, **kwargs)
def thrust(self, direction):
if self.velocity.length() > self.max_speed:
self.velocity = self.velocity.normalize()*self.max_speed
return
if direction == "forward_t":
self.velocity = (self.velocity
+ Vector(0.1, 0).rotate(self.angle)
* self.heat[direction][0])
self.overheat(direction)
elif direction == "backward_t":
self.velocity = (self.velocity
+ Vector(0.05, 0).rotate(self.angle + 180)
* self.heat[direction][0])
self.overheat(direction)
elif direction == "left_t":
self.velocity = (self.velocity
+ Vector(0.03, 0).rotate(self.angle + 90)
* self.heat[direction][0])
self.overheat(direction)
elif direction == "right_t":
self.velocity = (self.velocity
+ Vector(0.03, 0).rotate(self.angle + 270)
* self.heat[direction][0])
self.overheat(direction)