I asked on the panda3d irc channel earlier about this but couldnt get it to work so i thought id finally ask here.
My problem is i have a ship that when you press a it strafes right and left when you press b but i need it to return to the center when both keys are up.
i have a task called playerMove and i put this in it:
base.accept('a-repeat', ship.playerStrafe, extraArgs = [self, "left"] )
base.accept('d-repeat', ship.playerStrafe, extraArgs = [self, "right"] )
base.accept('a-up', ship.playerStrafe, extraArgs = [self, "center"])
base.accept('d-up', ship.playerStrafe, extraArgs = [self, "center"])
but when i try to detect when the a and d key are up it can only detect one of them at a time. i need them to both be detected in one frame.
Here is my playerStrafe code if you need it :
def playerStrafe(self, dir):
if self.strafeAmount != 0:
self.ship.hide()
self.copyShip.show()
else:
self.ship.show()
self.copyShip.hide()
if dir == "left":
self.strafeCenter = 2
if self.strafeAmount > -45:
self.copyShip.setR(self.ship, -5)
self.strafeAmount -= 5
if self.strafeAmount == -45:
self.ship.setX(self.ship, -5)
if dir == "right":
self.strafeCenter = 2
if self.strafeAmount < 45:
self.copyShip.setR(self.ship, 5)
self.strafeAmount += 5
if self.strafeAmount == 45:
self.ship.setX(self.ship, 5)
if dir == "center":
if self.strafeCenter > 0:
self.strafeCenter -= 1
if self.strafeCenter == 0:
if self.strafeAmount < 0:
self.copyShip.setR(self.copyShip, 1)
self.strafeAmount += 1
if self.strafeAmount > 0:
self.copyShip.setR(self.copyShip, -1)
self.strafeAmount -= 1
the strafe center is set to 2 whenever the player presses a or d but its supposed to go back to 0 when the keys are up (decreased by 1 when each key is up)
Its kinda confusing, i know. But if you have any advice i would really appreciate it!