Enjoy programming more!
Kidspod is a post site which supports young programmers.
First step to join us.
Register as a member
For members

2017/09/07 12:57:30

MixJuice GET URL : kidspod.club/mj/277

フローティング・ゴースト・スタイル

画面をタップ(クリック)すると幽霊が浮き上がるから、
左右から流れてくるアイテムをゲットしよう。
5点集めるまでのタイムアタックだ。
IchigoLatteで遊ぶときは、ボタンを押そう。


"Floating Ghost Style"
When you tap (click) the screen, ghosts will float,
so let's get items flowing from the left and right.
It is a time attack until 5 points are gathered.
When playing with IchigoLatte, press the button.

SOURCE CODE

var fx,fy,fv;
var score,norma,start;
var iNum=3;
var iPos=new Array(iNum*3);

function resetI(i){
  if(rnd(2)==0){
    iPos[i]=1;
    iPos[i+2]=1;
  }else{
    iPos[i]=30;
    iPos[i+2]=-1;
  }
  iPos[i+1]=rnd(22)+1;
}

function init(){
  cls();

  fx=15;
  fy=10;
  fv=0;

  score=0;
  norma=5;
  start=tick();
 
  var i=0;
  while(i<iPos.length){
    resetI(i);
    i=i+3;
  }
}

function main(){
  // draw items
  var i=0;
  while(i<iPos.length){
    lc(iPos[i],iPos[i+1]);log(" ");

    if((iPos[i]==fx)*(iPos[i+1]==fy)){
      resetI(i);
      score=score+1;
    }

    if((0<iPos[i])*(iPos[i]<31)){
      iPos[i]=iPos[i]+iPos[i+2];
    }else{
      resetI(i);
    }

    lc(iPos[i],iPos[i+1]);log(chr(246));
    i=i+3;
  }

  // update score and time
  lc(0,0);log("score:",score);
  lc(10,0);log("time:",(tick()-start)/100);

  // game clear
  if(score>=norma){
    lc(11,11);log("Game Clear!");
    lc(fx,fy);log(chr(239));  
    exit();
  }

  // draw player
  lc(fx,fy);log(" ");
  if(fv<0) fv=fv+1;
  fy=fy+1+fv;
  if(fy<1) fy=1;
  if(fy>22) fy=22;
  lc(fx,fy);log(chr(236));

  setTout(main,100);
}

function bf(b){
  if(b==1){
    if(fy>=22) fv=0;
    fv=fv-3;
  }
}

init();
setBprs(bf);
main();

COMMENT