I am trying to make a ball move extremely fast in AppGameKit and for the life of me cannot get it to work. Any ideas how to make this work?
//Set the Physics Gravity to 0,0 so that the world is like a Blockbreaker game where the ball bounces off everything.
SetPhysicsGravity(0,0)
//Loaded the ball image and created the sprite. Set Physics to Dynamic, set Restitution = 1 so the ball has full bounce. And, set Friction = 0 so there's no friction. Thus, ball should move as freely as possible
Ball = LoadImage("Player.png")
Player = CreateSprite(Ball)
SetSpritePhysicsOn(Player,2)
SetSpritePhysicsRestitution(Player,1)
SetSpritePhysicsFriction(Player,0)
BallForce# = 5000.0
do
//Then in my Do Loop, I am drawing a line to know what direction the ball will move and that's done with the GetPointerState()=1 state as it constantly draws a new line to the mouse pointer while the mouse is pressed down.
if GetPointerState() = 1 //Means the pointer is pressed down
DrawLine(GetSpriteX(Player)+(GetSpriteWidth(Player)/2),GetSpriteY(Player)+(GetSpriteHeight(Player)/2),GetPointerX(),GetPointerY(),255,0,0)
endif
if GetPointerReleased()
//Then when I release the Mouse, I calculate the XDiff# and YDiff# values which is just how far the GetPointerX() is from the X position of the ball (Player) and the GetPointerY() is from the Y position of the ball.
XDiff# = GetPointerX()-(GetSpriteX(Player)+(GetSpriteWidth(Player)/2))
YDiff# = GetPointerY()-(GetSpriteY(Player)+(GetSpriteHeight(Player)/2))
//Then I determine which if these 2 values is higher because I want to bring the difference down to values <= 1.0 so that I can apply a consistence Velocity to it.
HighVal# = XDiff#
if YDiff# > HighVal# then HighVal# = YDiff#
XDiff# = XDiff# / HighVal#
YDiff# = YDiff# / HighVal#
//At this point, XDiff# and YDiff# are both <=1.0 Then I apply a BallForce# value to each so I can determine how much Velocity to apply to the ball.
XDiff# = XDiff# * BallForce#
YDiff# = YDiff# * BallForce#
//But no matter how big I make BallForce#, the ball only moves so fast. It just moves an average speed across the screen. I can't get it to more super fast across the screen.
SetSpritePhysicsVelocity(Player,XDiff#,YDiff#)
endif
//I have also grabbed the XForce# and YForce# values based on the balls Velocity and then multiplied it to these values and applied it back to the Velocity at this point and checked the before and after values. MAKES NO DIFFERENCE. The ball
//continues to go at the same speed. WHAT IS GOING ON HERE??? Why can't I apply a super fast Velocity or Force or ANYTHING to an object and make it go super fast? This has got me puzzled!!!
XForce# = GetSpritePhysicsVelocityX(Player)
YForce# = GetSpritePhysicsVelocityY(Player)
print(str(XForce#) + " : " + str(YForce#))
Sync()
loop