I see that it is still not very friendly to a percentage based coordinate system.
It is pretty reliant on subtle balances to get it spinning properly.
In the percentage based system the particles you created actually help to balance out the twirling.
Any easy way to limit the speed of the spin?
//setVirtualResolution(640,480)
setdisplayaspect (0.66)
CreateText (11," ")
settextsize (11,2)
settextx (11,1)
settexty (11,3)
// SetTextColor( 10, 0,100,0,255)
SetPhysicsGravity(0,0)
spr = createSprite(0)
//setSpritePositionByOffset(spr,320,120)
setSpritePositionByOffset(spr,50,50)
setSpriteSize(spr,10,1)
setSpritePhysicsOn(spr,2)
type sparkType
spr as integer
die as float
endtype
dim spark[0] as sparkType
spark[0].spr = 0
global time as float
for i=6 to 35
redrocksnum=40+i
CreateSprite ( redrocksnum,0 )
setspritesize(redrocksnum,random(2,8),-1)
setspritex(redrocksnum,random(1,90))
setspritey(redrocksnum,random(1,60))
SetSpritePhysicsOn (redrocksnum,2)
SetSpritePhysicsRestitution ( redrocksnum, 1.0 )
setspriteangle(redrocksnum,random(1,360))
SetSpriteColor(redrocksnum, 0,0,random(150,255),255)
//setSpritePhysicsAngularImpulse(redrocksnum,random(-3,3))
setSpritePhysicsImpulse(redrocksnum,getSpriteXbyOffset(spr),getSpriteybyOffset(spr),random(-5,5),random(-5,5))
next
do
// space key then end
keypressb=GetRawKeyPressed(32)
if keypressb=1
end
endif
time = timer()
rem get sprite data
sa# = getSpriteAngle(spr)
sx# = getSpriteXbyOffset(spr)
sy# = getSpriteYbyOffset(spr)
rem apply angular impulse
setSpritePhysicsAngularImpulse(spr,0.3)
rem apply linear impulse
vx# = cos(sa#)*0.1
vy# = -sin(sa#)*0.1
setSpritePhysicsImpulse(spr,sx#,sy#,vx#,vy#)
rem sparks
createSpark(sx#,sy#,-vx#,vy#)
updateSparks()
//vartsta$="mass=" + str(mass#)
//settextstring(11,vartsta$)
sync()
loop
function createSpark(x#,y#,vx#,vy#)
spr = createSprite(0)
setSpriteSize(spr,0.8,-1)
setSpritePositionByOffset(spr,x#+vx#*0.5,y#+vy#*0.5)
setSpritePhysicsOn(spr,2)
setSpritePhysicsVelocity(spr,vx#*2,vy#*2)
setspritephysicsmass(spr,0.009)
n = spark[0].spr + 1
dim spark[n] as sparkType
spark[0].spr = n
spark[n].spr = spr
spark[n].die = time + 2.0
endfunction
function updateSparks()
n = spark[0].spr
for i=1 to n
die# = spark[i].die
spr = spark[i].spr
if die#-time>0
f# = (die#-time)*0.5
if i=1 then print(str(f#))
c# = f#*255.0
setSpriteColor(spr,c#,255.0-c#,0,c#)
else
deleteSprite(spr)
spark[i].spr = spark[n].spr
spark[i].die = spark[n].die
dec n
dec i
dim spark[n] as sparkType
spark[0].spr = n
endif
next
endfunction