problem with exam task for college
Vincent Vande Vyvre
vincent.vandevyvre at swing.be
Mon Jan 7 12:40:26 EST 2013
Le 07/01/13 17:22, jeltedeproft at hotmail.com a écrit :
> ok after another round of reparations, my update works again and it updates the fuel meter, but i still can't get the view of the spaceship to rotate, for now only the direction the spaceship accelerates when pressing "up" changes after a rotation, but the spaceship itself keeps pointing up. This is the code for the rotating : p.s : the problem has to be in this code because the update of the view of the position of the spaceship does work.
>
>
> def update(self,dt):
> self.velocity = self.velocity + (self.acceleration * dt)
> self.pos = self.pos + self.velocity * dt
> a = 0
> b = 0
> if scene.kb.keys:
> a = a + 0.001
> s = scene.kb.getkey()
> if (s == "up"):
> if self.zicht.meter.height != 0:
> self.velocity = self.velocity + self.gas
> self.vlam.visible = True
> b = b + 2
> self.zicht.meter.height = self.zicht.meter.height - 0.1
> self.zicht.update
> if (s == "left"):
> self.gas = rotate(self.gas,angle = math.pi/10, axis = (0,0,1))
> (x,y,z) = self.frame.axis
> self.frame.axis = (x,y,z-0.1)
> if (s == "right") :
> self.gas = rotate(self.gas,angle = -(math.pi/10), axis = (0,0,1))
> (x,y,z) = self.frame.axis
> self.frame.axis = (x,y,z+0.1)
> if (a == 0):
> self.vlam.visible = False
Are you sure with this code:
(x,y,z) = self.frame.axis ?
frame.axis is a 'cvisual.vector' and this unpacking cause a program
crashes with a segfault.
For left-rigth moves of the LEM, this code seems works:
--------------------------------------
if scene.kb.keys:
key = scene.kb.getkey()
if key == "left":
# Set left deviation
self.frame.axis -= (0, 0, 0.05)
self.gas = vector(-sin(self.angle), cos(self.angle))
elif key == "right":
# Set right deviation
self.frame.axis += (0, 0, 0.05)
self.gas = vector(sin(self.angle), cos(self.angle))
elif key == "up":
self.deviate()
def deviate(self):
# Set modified velocity
self.frame.velocity += self.gas
self.frame.pos += self.frame.velocity
# Reset falling velocity
self.frame.velocity -= self.gas
--------------------------------------
with angle = PI / 2.0
--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
More information about the Python-list
mailing list