-
Notifications
You must be signed in to change notification settings - Fork 2
/
StaticObject.py
99 lines (73 loc) · 2.94 KB
/
StaticObject.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
86
87
88
89
90
91
92
93
94
95
96
97
98
from GameObject import GameObject
from pandac.PandaModules import (
Vec3,
Vec4,
Point3,
PointLight,
OdeBoxGeom,
NodePath,
BitMask32,
OdeUtil,
Texture,
TextureStage
)
class StaticObject(GameObject):
def getPos(self):
return self.collGeom.getPosition()
def setPos(self, pos):
self.visualNode.setPos( pos )
self.collGeom.setPosition( pos )
#rotate in degrees counterclockwise
def setRotation(self, rotate):
self.rotation = rotate
self.update()
def update(self):
self.visualNode.setHpr( Vec3(self.rotation, 0, 0) )
pos = self.collGeom.getRotation()
self.collGeom.setRotation( pos.rotateMat(self.rotation) )
# BigWallin model skaalautuu parametreihin arvoista 50, 4, 1
class BigWall(StaticObject):
def __init__(self, game, width=200.0, thickness=4.0, height=10):
self.game = game
self.collGeom = OdeBoxGeom( self.game.physicsSpace, width, thickness, height)
#self.collGeom.setBody(self.body)
self.collGeom.setCategoryBits( BitMask32(0x000000ff) )#ffffffff) )
self.collGeom.setCollideBits( BitMask32(0x000000ff) )
self.visualNode = NodePath('Visual node')
self.visualNode.reparentTo(render)
model = loader.loadModel('BigWall.egg')
model.setScale(width/50.0, thickness/4.0, height)
model.reparentTo(self.visualNode)
model.setZ(266)
# tex = loader.loadTexture('seina.jpg')
# model.setTexture(tex, 1)
def osuminen(self, ship1):
if OdeUtil.collide(ship1.collGeom, self.collGeom):
print "sdfgfdhgdfhxfhdhghcfh"
print "ship1 xdfhgxdgxdgfbcdll!!"
class smallWall(StaticObject):
def __init__(self, game):
self.collGeom = OdeBoxGeom( self.game.physicsSpace, 10, 2, 30)
#self.collGeom.setBody(self.body)
self.collGeom.setCategoryBits( BitMask32(0x000000ff) )
self.collGeom.setCollideBits( BitMask32(0x000000ff) )
self.visualNode = NodePath('Visual node')
self.visualNode.reparentTo(render)
model = loader.loadModel('testipalikka.egg')
model.reparentTo(self.visualNode)
class AntiGravityPlate(StaticObject):
def __init__(self, game, x=100, y=100):
self.game = game
self.collGeom = OdeBoxGeom( self.game.physicsSpace, x, y, 2)
#self.collGeom.setBody(self.body)
self.collGeom.setCategoryBits( BitMask32(0x000000ff) )
self.collGeom.setCollideBits( BitMask32(0x000000ff) )
self.visualNode = NodePath('Visual node')
model = loader.loadModel('agplate.egg')
# ts = TextureStage('ts')
# ts.setMode(TextureStage.MReplace)
tex = loader.loadTexture('agplatetex.jpg')
model.setTexture(tex, 1)
model.setScale(30)
model.reparentTo(self.visualNode)
self.visualNode.reparentTo(render)