this is my code that moves my ship:
def move(self, dire):
if dire == "up":
self.newp = self.battleship.getP() + (9 *globalClock.getDt())
if dire == "down":
self.newp = self.battleship.getP() - (9 *globalClock.getDt())
if dire == "left":
self.newh = self.battleship.getH() + (9 *globalClock.getDt())
if dire == "right":
self.newh = self.battleship.getH() - (9 *globalClock.getDt())
def autoMove(self, task):
self.procent = self.proc/100
battleshipPrevPos = self.battleship.getNetTransform().getMat().getRow3(1)
battleshipPrevPos.normalize()
self.battleship.setPos(self.battleship.getPos() + self.procent*(battleshipPrevPos*(globalClock.getDt()*10)))
self.battleship.setHpr(self.newh,self.newp,self.newr)
return task.cont
taskMgr.add(autoMove,"automove",extraArgs=[self],appendTask=True)
taskMgr.add(campos,"camera position",extraArgs=[self],appendTask=True)
self.accept("q", sys.exit)
self.accept("escape", sys.exit)
self.accept("w-repeat", move, [self,"up"])
self.accept("a-repeat", move, [self,"left"])
self.accept("s-repeat", move, [self,"down"])
self.accept("d-repeat", move, [self,"right"])
self.accept("+-repeat", move, [self,"faster"])
self.accept("--repeat", move, [self,"slower"])
idea is that there is a standard speed (10) and there is the speed controler(self.proc) if you press + it self.proc will be increased and the ship will go faster because there is a higher value.
the only problem is that it gives an error:
unsuported operand type(s) for *: int and libpanda.Vbase3
how do i correct this?
assainator