I hope someone can help me with this Pi3D animation/loop problem. It is most likely just a rock bottom logic error.
Here's what I'm trying to do.
I have two buttons, left and right. Plus a basic scene consisting of a 3d-Object in front of a background plane.
If the left button was pushed the 3d-Object should move left, to a certain x value by a given acceleration value. The same with the right button, only in the right direction.
For my understanding it should work the way I implemented it (see code below). What happens though is that the Object just jumps to the left or right x value when the according button was pushed.
What's the problem here?
Code: Select all
…
knotX = 0 #initial x-position
accel = 0.07
left = False
right = False
while DISPLAY.loop_running():
gesture_value = gesture(ser, 1000)
#draw elements
endlessKnot.draw()
yellowBgnd.draw()
#if left button pushed activate left trigger boolean
if gesture_value == 1:
left = True
#if right button pushed activate right trigger boolean
elif gesture_value == 2:
right = True
#if left boolean triggered move knot left until x = -5
while left == True:
while knotX >= -5:
knotX -= accel
left = False
#if right boolean triggered move knot right until x = 5
while right == True:
while knotX <= 5:
knotX += accel
right = False
#animate
endlessKnot.positionX(knotX)
endlessKnot.rotateIncY( 1 )
if mykeys.read() == 27:
mykeys.close()
DISPLAY.destroy()
break
Has anyone implemented tweening in a Pi3D project yet and could share some experience?