Hi all,
I tried to start with something simple like Pong and if I get more used to AppGameKit try and do something Breakout style.
First steps were promising. I managed to set up the physics correctly(?) using dynamic for the ball and kinetic for the paddles, giving the ball a small impulse to get it going in the beginning.
Now (as you'd expect) I am facing a problem that I cannot solve although I think that it cannot be that complicated:
- How can I maintain a set speed of the ball? If it hits a moving paddel for example it loses much of it's speed depending on the angle. I tried with damping and even restricted the angular velocity (which didn't work at all).
- In case you hit it perfectly the ball goes straight up and down indefinitely?
For the second one I came up with the following lines of sloppy code but I'm pretty sure that there are better ways:
counter = counter +1
ballXold = getspritex(2)
ballyold = getspritey(2)
if counter = 10
ballxnew = getspritex(2)
ballynew = getspritey(2)
counter = 0
endif
if ballxold = ballxnew then lazyX = lazyX +1
if lazyX > 1000
SetSpritePhysicsImpulse ( 2, getspritex(2), getspritey(2), 100, 100)
lazyX = 0
endif
if ballyold = ballynew then lazyY = lazyY +1
if lazyY > 1000
SetSpritePhysicsImpulse ( 2, getspritex(2), getspritey(2), 100, 100)
lazyY = 0
endif
As usual thanks a lot for your help,
Cel