var b1,afloor:element
i,c : integer lt:integer
procedure Newthing var cc:integer begin cc = Rand(1,8) // pick a sprite at randon b1=loadSprite('shape'+cc+'.png') // load it up
// load it's hull SpriteLoadHulls(b1,'shape'+cc+'.hull')
// place it at a Random position PositionSprite(b1,400+rand(-350,350),32)
// link sprite to physics engine, with defaults // for mass, friction and restitution // (can be overriden in the hull definition) D2DLinkPhysics(b1,1,0.3,0.2) end begin openscreen // Freeze the timers so the physics // doesn't jump at the start Freeze // set up the physics world D2DWorldCreate(-100,-100,100,100,0,10,true) D2DSetScaling(0,0,10,10) // and an invisible Floor for things to land on afloor = d2daddbox(200,5,0,0.5,0,0,60,0) // start off with one thing newthing c=1 UnFreeze // release the timer lt = millisecs while not keydown(vk_escape)
// create new sprites every half second if (c<80) and (millisecs-lt > 500) then newthing lt = millisecs inc(c) endif flip wend closescreen end
|