-
Notifications
You must be signed in to change notification settings - Fork 0
/
sentry.py
55 lines (39 loc) · 1.37 KB
/
sentry.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from bge import logic
from main import Sentry
import random
import math
import aud
import utils
laser_sound = aud.Factory.file(logic.expandPath("//sound/laser/laserfire01.ogg")).volume(.5).fadeout(0, .4)
def search():
cont = logic.getCurrentController()
own = cont.owner
scene = logic.getCurrentScene()
target = scene.objects["player"]
hit = own.rayCast(target, own, 0.0, "solid", 0, 1, 0)
if hit[0] == target:
own["cansee"] = True
if own.get("fireclock", 0)*logic.getTimeScale() > 1:
# l.pitch = random.randrange(5, 15)*.1
fire(hit[2])
own["fireclock"] = 0
else:
own["cansee"] = False
own["fireclock"] = own.get("fireclock", 0) + 1
def fire(direction):
cont = logic.getCurrentController()
own = cont.owner
scene = logic.getCurrentScene()
projectile = scene.addObject("standard_projectile", own, 0)
projectile.alignAxisToVect(direction, 0, 1)
projectile.setLinearVelocity((-20, 0, 0), True)
projectile["sound_handler"] = aud.device().play(laser_sound)
if projectile.get("sound_handler", 0):
projectile["sound_handler"].pitch = logic.getTimeScale()
def main(cont):
own = cont.owner
if not "init" in own:
own["init"] = True
print("setup")
own = Sentry(own)
own.main()