-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.py
More file actions
115 lines (74 loc) · 3.24 KB
/
platform.py
File metadata and controls
115 lines (74 loc) · 3.24 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
"""
**************************************************
* *
* Katelyn Biesiadecki *
* CS454 Game Programming (Kang, Ijaz) *
* *
* Start Date: July 6, 2016 *
* Midway Due Date: July 13, 2016 *
* Final Due Date: July 23, 2016 *
* *
* Project Name: Hopper *
* Description: This class creates the ocean *
* layout as a foundation for the *
* game. *
* *
**************************************************
"""
import random, sys, os, math
from math import sin, cos
from direct.actor.Actor import Actor
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
from direct.showbase.ShowBase import ShowBase
from direct.showbase.InputStateGlobal import inputState
from direct.interval.IntervalGlobal import *
from panda3d.core import *
from panda3d.bullet import *
from direct.gui.OnscreenText import OnscreenText
class Platform(object):
def __init__(self, render, world, heading, sizeMap, originMap, roll = 0, tex = "models/165.jpg"):
self.render = render
self.world = world
self.origin = originMap
self.size = sizeMap
self.heading = heading
self.roll = roll
self.randomStart = random.randint(5, 10)
shape = BulletBoxShape(self.size*0.55)
self.platformBulletNode = self.render.attachNewNode(BulletRigidBodyNode("Platform"))
self.platformBulletNode.node().addShape(shape)
self.platformBulletNode.setPos(self.origin + self.size)
self.platformBulletNode.setH(self.heading)
self.platformBulletNode.setR(self.roll)
self.platformBulletNode.setCollideMask(BitMask32.allOn())
"""
self.directionalLight = DirectionalLight( "directionalLight" )
self.directionalLight.setColor( Vec4( 1, 1, 1, 1 ) )
self.directionalLight.setDirection(Vec3(0, -0.6, -1))
self.directionalLightNP = render.attachNewNode(self.directionalLight)
"""
#----- Platform Model ------
self.platformModel = loader.loadModel("models/ModelCollection/EnvBuildingBlocks/stone-cube/stone.egg")
self.platformModel.reparentTo(self.platformBulletNode)
self.platformModel.setPos(0, 0, 0)
self.platformModel.setScale(self.size.x * 1.1, self.size.y * 1.1, self.size.z * 0.625)
#self.platformModel.setLight(self.directionalLightNP)
self.volcTex = loader.loadTexture(tex)
self.platformModel.setTexture(self.volcTex, 1)
self.volcNormal = loader.loadTexture("models/165_norm.jpg")
self.vt = TextureStage('vt')
self.vt.setMode(TextureStage.MNormal)
self.platformModel.setTexture(self.volcTex, 1)
self.platformModel.setTexture(self.volcTex, 1)
self.world.attachRigidBody(self.platformBulletNode.node())
def removeNormal(self):
#self.platformModel.clearLight(self.directionalLightNP)
self.platformModel.setTexture(self.volcTex, 1)
pass
def addNormal(self):
self.platformModel.setTexture(self.vt, self.volcNormal)
def spinPlatform(self, task):
theta = (task.time + self.randomStart)*40.0
self.platformBulletNode.setH(theta)
return task.cont