I just made a video for the boing without overlap script (…
I just made a video for the boing without overlap script ( http://www.pierrox.net/android/applications/lightning_launcher/wiki/doku.php?id=script_llxperiment_boing_no_overlap)
It’s just for fun, but it looks hilarious 😉
Thanks to TrianguloY for the basic script.
]]>« Hi, how can I get a notifications on screen lock? (Previous Post)
(Next Post) Scroll animation: Shrink »
< ![CDATA[
Awesome. It’s funny to see how they ‘jump’ when there is no space.
Perhaps I should upload my screen with 38 items? Haha, just joking. (It works laggy, but it still is incredible how you managed to get it working. 🙂
]]>
< ![CDATA[
You could upload your screen, but please speed up until you have at least 30 fps 😉
]]>
< ![CDATA[
Not a bad idea. I’ll try when possible (which not necessarily mean soon)
]]>
< ![CDATA[
Btw: i had an idea how to reduce jumps!
In the video it’s the old version.
var bounciness = 1;//Reduction every tick, between 0 (only one tick) and 1 (always bouncing) [Recommended 0.95]
var inVel = 0.02 //initial velocity. set it to 0 for random one [recommended 0.5]
var frecuency = 1000;//ticks per second [Recommended 60]
var event = LL.getEvent();
var cont = event.getContainer();
var items;
items=cont.getItems();
for(var i=items.getLength()-1; i>=0;–i){
var item=items.getAt(i);
if(item.getType()==”StopPoint”)continue;
var ang = Math.random()*2*Math.PI;
var invel=inVel; if(invel< =0)invel=Math.random();
invel*=(cont.getHeight()+cont.getWidth())/2;
//saving item specific data in the tag
var data=new Object();
data.vel = [ Math.cos(ang)*invel , Math.sin(ang)*invel ];
data.size = [ item.getWidth()*item.getScaleX() , item.getHeight()*item.getScaleY() ];
item.setTag(JSON.stringify(data));
}
tick();
function tick(){
var changed=false;//value if something changed
for(var a=items.getLength()-1; a>=0;–a){
var i=items.getAt(a); if(i.getType()==”StopPoint”)continue;
var data=JSON.parse(i.getTag());
//continue statement
if((Math.abs(data.vel[0])<0.2 && Math.abs( data.vel[1])<0.2)||LL.isPaused()) continue;
var changed=true;
//Reduction
data.vel=[ data.vel[0]*bounciness , data.vel[1]*bounciness ];
var newpos = [ i.getPositionX()+ data.vel[0] , i.getPositionY()+ data.vel[1] ];
//checking all other items after the current for overlap
for(var b=a-1; b>=0;–b){
var i2=items.getAt(b); if(i2.getType()==”StopPoint”)continue;
var data2=JSON.parse(i2.getTag());
var newpos2 = [ i2.getPositionX()+ data2.vel[0] , i2.getPositionY()+ data2.vel[1] ];
var p;//new position of the item with the smaller width/height
var p2;//higher width/height
var s;//size of the item with the smaller width/height
var s2; //higher width/height
//horizonatal:
if(data.size[0]
{
//the first item is smaller
p=newpos[0]
p2=newpos2[0];
s=data.size[0];
s2= data2.size[0];
}
else
{
//the second item is smaller
p=newpos2[0]
p2=newpos[0];
s=data2.size[0];
s2= data.size[0];
}
var overx= ((p2
//the same again, but for vertical
if(data.size[1]
{
p=newpos[1];
p2=newpos2[1];
s=data.size[1];
s2= data2.size[1];
}
else
{
p=newpos2[1];
p2=newpos[1];
s=data2.size[1];
s2= data.size[1];
}
var overy= ((p2
if(overx && overy){
//the distances on the sides of the first items, how far it overlaps
distl=newpos2[0]+data2.size[0]-newpos[0];
distr=newpos[0]+data.size[0]-newpos2[0];
distt=newpos2[1]+data2.size[1]-newpos[1];
distb=newpos[1]+data.size[1]-newpos2[1];
if(distr
{
newpos[0]-=2*distr;
data.vel[0]=-data.vel[0];
data2.vel[0]=-data.vel[0];
}
else if(distb
{
newpos[1]-=2*distb;
data.vel[1]=-data.vel[1];
data2.vel[1]=-data.vel[1];
}
else if(distt
{
newpos[1]+=2*distt;
data.vel[1]=-data.vel[1];
data2.vel[1]=-data.vel[1];
}
else //overlapping left
{
newpos[0]+=2*distl;
data.vel[0]=-data.vel[0];
data2.vel[0]=-data.vel[0];
}
}
i2.setTag(JSON.stringify(data2));
}
var t;
//right
t=(newpos[0]+ data.size[0])-( cont.getPositionX()+cont.getWidth()/cont.getPositionScale() ) ;
if(t>0){newpos[0]-=2*t; data.vel[0]=-data.vel[0];}
//bottom
t=(newpos[1]+ data.size[1])-( cont.getPositionY()+cont.getHeight()/cont.getPositionScale() ) ;
if(t>0){newpos[1]-=2*t; data.vel[1]=-data.vel[1];}
//left
t= newpos[0]- cont.getPositionX();
if(t<0){newpos[0]-=2*t; data.vel[0]=-data.vel[0];}
//top
t= newpos[1]- cont.getPositionY();
if(t<0){newpos[1]-=2*t; data.vel[1]=-data.vel[1];}
//set
i.setPosition(newpos[0] , newpos[1] );
i.setTag(JSON.stringify(data));
}
if(!changed)return;
//repeat
setTimeout(tick,1000/frecuency);
}
]]>