So I have decided to use the render2d to show the values of the dice on the side of the screen. I'm having some difficulty getting that to work however. I should be able to get it done tomorrow. I'm growing concerned about screen space in my final game. There is a lot of information to be displayed on the screen, and I don't know how all of it is going to fit in. I'm going to look into upping the size of the window and/or getting a higher resolution going. There's going to be a model of the monster(s) in the encounter, plus all four of the player's characters and their abilities, plus the rolling dice, plus the dice values that can be selected. I'm thinking the monster is going to basically replace the back wall of the "room" that the dice are being thrown in, but that doesn't really leave a lot of room for everything else. Anyway, here's a few pieces of my code:
Here's a couple functions that are used to rotate the dice randomly when the game is first started, to give the cool floating effect.
# spin the models randomly
def rotateModels(self, task):
self.frame = self.frame + 1
if self.frame >= FRAMESKIP:
self.frame = 0
for die in self.dice:
x = random.randint(0,359)
y = random.randint(0,359)
z = random.randint(0,359)
die[0].setHpr(x,y,z)
die[3].setPosition(die[0].getPos(render))
die[3].setQuaternion(die[0].getQuat(render))
if self.collision == False:
return Task.cont
else:
return Task.done
# start the dice rotating
def startRotation(self):
if self.rotationRunning == False:
self.rotationRunning = True
self.inSimulation = False
self.taskMgr.add(self.rotateModels, "rotateModels")
This function is the dice throw. It comes up with a random direction to throw the dice, that is always directed upwards. Notice that this is done by setting a force to work on the object. It is very nice how panda provides a function like this, instead of me having to program in some complicated function with a whole bunch of physics that I have probably forgotten since I took physics.
# force (explode) the dice
def forceDie(self):
for i in range(0,7):
body = self.dice[i][3]
a = random.randint(-17000000,17000000)
b = random.randint(-17000000,17000000)
c = random.randint(10000000,33000000) # up is always big to overcome gravity
body.setForce(Vec3(a, b, c))
No comments:
Post a Comment