-
Notifications
You must be signed in to change notification settings - Fork 2
/
Base.py
executable file
·85 lines (71 loc) · 2.85 KB
/
Base.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import random
from pandac.PandaModules import (
# AmbientLight,
# DirectionalLight,
PointLight,
NodePath,
Vec3,
Vec4,
Point3,
# Quat,
OdeUtil,
# OdeWorld,
# OdeHashSpace,
# OdeJointGroup,
# OdeMass,
# OdeBody,
# OdeSphereGeom,
OdeBoxGeom,
BitMask32,
# TextNode
)
from StaticObject import StaticObject
#from CollectibleTypes import Restore
class Base(StaticObject):
#17.12.2009: collGeomInner -> collGeom, dropBall(x, y ,z, linX, linY), collectible.setPos() ja setVelocity()
def __init__(self, game):
self.game = game
#poista se fysiikka-avaruus ja vaan tee se alue... justiinsa
self.collGeom = OdeBoxGeom( 24,8,2 )
#self.collGeom.setBody(self.body)
self.collGeom.setCategoryBits( BitMask32(1) )
self.collGeom.setCollideBits( BitMask32(1) )
# self.collGeomOuter = OdeBoxGeom( self.game.physicsSpace, 28,6,2)
# #self.collGeom.setBody(self.body)
# self.collGeomOuter.setCategoryBits( BitMask32(1) )
# self.collGeomOuter.setCollideBits( BitMask32(1) )
self.visualNode = NodePath('Visual node')
self.visualNode.reparentTo(render)
model = loader.loadModel('Base.egg')
model.reparentTo(self.visualNode)
plight = PointLight('baselight')
plight.setPoint( Point3(0, 0, 12) )
plight.setColor( Vec4(1,1,1,1) )
plight.setAttenuation( Vec3(0.1, 0.1, 0.005) )
self.visualNode.setLight(model.attachNewNode(plight))
def checkCollision( self, ship, collectiblelist ):
if OdeUtil.collide(ship.collGeom, self.collGeom) and ship.hasBall():
#if ship.hasBall():
ship.addPoints( (ship.Ball.getValue()*2) )
pos = self.getPos()
ship.dropBall( x = pos[0], y = pos[1], z = 50, linX = random.randrange(-10,10), linY = (0-pos[1]) / 4 )
print ship.SHIP_TYPE + " " + str(ship.getPoints()) + " Points! "
if (self.game.goalSfx.status() == 1):
self.game.goalSfx.play()
self.game.updateHUD()
#print " Base One! "
for collectible in collectiblelist:
if OdeUtil.collide(collectible.collGeom, self.collGeom):
pos = self.getPos()
ship.addPoints(collectible.getValue())
collectible.setPos( Vec3(pos[0], pos[1], 50))
collectible.setVelocity(x = random.randrange(-10,10), y = (0-pos[1]) / 4)
self.game.goalSfx.play()
self.game.updateHUD()
print ship.SHIP_TYPE + " " + str(ship.getPoints()) + " Points! by throwing the ball"
def addToBaseList(self, baseList):
baseList.append(self)
def setPos(self, pos, pos2):
self.visualNode.setPos( pos )
self.collGeom.setPosition( pos2 )
# self.collGeomOuter.setPosition( pos )