確率でオブジェクトを出現させる - hoge1e3/Tonyu2 GitHub Wiki
確率でオブジェクトを出現させる
毎フレーム0~99の値をランダムに決めて、それが5未満(5%の確率)ならば画面の上部にオブジェクトが生成されます.
Main
while(true){
if(rnd(100)<5){
new Enemy{x:rnd($screenWidth),y:0,p:1};
}
update();
}
Enemy
while(true){
y+=4;
if(screenOut(0) ){
die();
}
update();
}
参考
.