here below contacts , u can get all contact points.
http://www.appgamekit.com/documentation/Reference/2DPhysics.htm
the ball itself can have only one moving direction, a result of all forces.
// Ball
function BallCreate()
ball = loadsprite("ball.png")
setspritesize(ball,2,-1)
setspriteshape(ball,1) //Kreis
SetSpriteGroup(ball,1)
setspritepositionbyoffset(ball,50,70)
setspritedepth(ball,1)
SetSpritePhysicsOn ( ball, 2 )
SetSpritePhysicsFriction ( ball, 0.1 )
SetSpritePhysicsDamping( ball, 0.0 )
SetSpritePhysicsAngularDamping(ball, 0.5)
SetSpritePhysicsRestitution( ball, 1.0 )
SetSpritePhysicsMass ( ball, 0.1 )
setSpritePhysicsCanRotate (ball,1)
SetSpritePhysicsIsBullet(ball,1)
endfunction ball
function BallStartPosition(spr,startspr)
setspritephysicsvelocity(spr,0,0)
setspritephysicsangularvelocity(spr,0)
setspritepositionbyoffset(spr,getspritexbyoffset(startspr),getspriteybyoffset(startspr)-getspriteheight(startspr)/2-getspriteheight(spr)/2)
endfunction
function BallStart(spr,x#,y#)
SetSpritePhysicsImpulse( spr, getspritexbyoffset(spr),getspriteybyoffset(spr), x#, y# )
endfunction
function BallStop(spr)
setspritephysicsvelocity(spr,0,0)
setspritephysicsangularvelocity(spr,0)
endfunction
function BallGravity(spr)
//SetSpritePhysicsforce( spr, getspritexbyoffset(spr),getspriteybyoffset(spr), 0,1 )
endfunction
function BallCollisionSchlaeger(ball, schlaeger)
//Abprall
if GetPhysicsCollision( ball, schlaeger ) //must be in correct order else no collision^^
dx#=getspritexbyoffset(ball)-getspritexbyoffset(schlaeger)
//print(dx#)
vx#=dx#/2.0
vy#=-1
SetSpritePhysicsImpulse( ball, getspritexbyoffset(ball),getspriteybyoffset(ball), vx#, vy# )
endif
endfunction
function BallCollision(ball)
c=GetSpriteFirstContact(ball)
do
if c=0 then exit
spr=GetSpriteContactSpriteID2() //komisch knn 0 zurück geben^^
if spr<>0
cx#=GetSpriteContactWorldX()
cy#=GetSpriteContactWorldy()
BrickHit(spr) //< löscht ein Sprite!
vx#= getspritexbyoffset(ball)-cx#
vy#= getspriteybyoffset(ball)-cy#
l#=sqrt(vx#*vx# + vy#*vy#)
if l#<1.0 then l#=1.0
vx#=vx#/l#
vy#=vy#/l#
vx#=vx#*0.5
vy#=vy#*0.5
SetSpritePhysicsImpulse( ball, getspritexbyoffset(ball),getspriteybyoffset(ball), vx#, vy# )
endif
c=GetSpriteNextContact()
loop
endfunction
function BallSpeedLimit(spr)
x#=GetSpritePhysicsVelocityX(spr)
y#=GetSpritePhysicsVelocityY(spr)
v#=120 //80.0
if x#<-v# then x#=-v#
if y#<-v# then y#=-v#
if x#>v# then x#=v#
if y#>v# then y#=v#
SetSpritePhysicsVelocity(spr,x#,y#)
endfunction
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)