Physics are inherently inaccurate, but here is my best shoot! I don't think the percentage system works too good with physics, so I use virtual resolution system, to get pixel perfection.
The sprites are setup at pixel perfection, but as soon as the physics system is activated, some forces messes with that.
// Rewrite to resolution based, by: impetus73
dim the_sprites[1000] AS integer
i_spr = 0
rem Portrait App
SetVirtualResolution(1024,768)
//set sync rate
SetSyncRate( 60, 0 )
//Set Gravity
SetPhysicsGravity(0,100)
//Create Ground
GroundSprite = createsprite(0)
setspritesize(GroundSprite,1024,75)
setspriteposition(GroundSprite,0,693)
setspritecolor(GroundSprite,239,228,176,255)
SetSpritePhysicsOn(GroundSprite,1)
//Create Girder Structure
for x=1 to 10
for y=1 to 9
GirderTall=createsprite(0)
setspritecolor(GirderTall,random(1,200)+55,random(1,200)+55,random(1,200)+55,255)
setspritesize(GirderTall,10,40)
setspriteposition(GirderTall,270+(x*44),693-(y*50))
the_sprites[i_spr] = GirderTall
INC i_spr
next y
next x
for x=1 to 9
for y=1 to 10
GirderWide=createsprite(0)
setspritecolor(GirderWide,random(1,200)+55,random(1,200)+55,random(1,200)+55,255)
setspritesize(GirderWide,40,10)
setspriteposition(GirderWide,277+(x*44),733-(y*50))
the_sprites[i_spr] = GirderWide
INC i_spr
next y
next x
DEC i_spr
while getpointerpressed()=0
Print("Press screen to activate physics!")
sync()
endwhile
for i=0 to i_spr
SetSpritePhysicsOn(the_sprites[i],2)
SetSpritePhysicsRestitution(the_sprites[i],0)
SetSpritePhysicsMass(the_sprites[i],10)
SetSpritePhysicsFriction(the_sprites[i],0.1)
next i
do
//delete girder user selects
if getpointerpressed()>0
SelectedGirderDelete = GetSpriteHit(GetPointerX(),GetPointerY())
if SelectedGirderDelete > 0
deletesprite(SelectedGirderDelete)
endif
endif
// update the screen
Print("FPS: " + str(ScreenFPS()))
Print(GetPointerX())
Print(GetPointerY())
Sync()
loop
Maybe if one carefully activate physics for each sprite in the right order from the bottom and up, then call Sync() between sets of sprites, it would end up perfectly balanced?
----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.