// cat sample
var st1;
sprite(1,"cat",2);
sprite(2,"ball",3);
sndload(1,"catbgm",2);
function init(){
bgcolor("#3533c6");
//-- generate sprites
for(i=0;i<50;i++){
a=1+rand(2);
c=sett(rand(scx),i*8,a,a);
txx[c]=-1-rnd();
tn[c]=rand(2);
ts[c]=1.8;
}
//-- print the text
st1=print(16,16,"Cat sample");
//-- draw background
bgbegin();
box(0,64,scx,scy-128,"#0088bb");
bgend();
setwait(20);
}
function move(i){
switch(t[i]){
// cat
case 1:sx+=sxx*4;
if(sx<-16)sx=scx;
if(sy==tsy[i]&&rand(21)==0)syy=-3-rnd()*4;
sy+=syy;syy+=.5;
if(sy>tsy[i])sy=tsy[i];
ss-=syy/40
if(sy==tsy[i]){ss=1.8;sn=(sn+1)&1;sr=0;}else{sr=(sr-22)%360;sn=0;}
break;
// ball
case 2:sx+=sxx*6;
sr=(sr+sxx*10)%360;
if(sx<-16)sx=scx;
sn=i%3;
break;
// cat(tap)
case 3:sx+=sxx;sy+=syy;
ss+=.05;sr=(sr+20)%360;
w=16*ss;
if(sx<-w||sy<-w||sx>scx+w||sy>scy+w)t[i]=0;
break;
}
}
function update(){
//-- modify the text
if(wa_f)settext(st1,sprintf("Cat sample:%05d",rand(30000)));
}
function mousedown(x,y){
//-- generate a cat when tapped
c=sett(x,y,1,3)
tr[c]=rand(360);
txx[c]=rnd()*10-5;
tyy[c]=rnd()*10-5;
ta[c]=200;
}
function mouseup(x,y){
}
|
2018 N.I