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

2017/10/19 11:13:16

MixJuice GET URL : kidspod.club/mj/384

跳べ、ジャンパー、跳べ

ジャンパーがジャンプ台の上に来たら画面をタップ(クリック)しよう。
タップ(クリック)していると、ジャンプ台が力を溜めていくぞ。
タップ(クリック)を放して、大ジャンプ!
どこまでジャンプできるかな?
IchigoLatteで遊ぶときは、ボタンを押そう。

IchigoLatteについてはこちら。
http://ichigolatte.shizentai.jp


"Jump, Jumper, Jump!"
Let's tap (click) the screen when the jumper comes over the jumping base.
If you tap (click), the jumping base will accumulate power.
Release the tap (click), big jump!
How far can you jump?
When playing with IchigoLatte, press the button.

IchigoLatte details here.
http://ichigolatte.shizentai.jp

SOURCE CODE

var c_x=15;
var c_c=128;
var x=0,y=10;

function step(){
  x=x+1;
  var chara=251+x%2;
  lc(x-1,y);log(" ");
  lc(x,y);log(chr(chara));
}

function record(m){
  lc(13,15);log(m," meters\n");
}

function byeEnd(){
  var cata_y=y+1;
  while(cata_y<23){
    cata_y=cata_y+1;
    lc(c_x,cata_y-1);log(" ");
    lc(c_x,cata_y);log(chr(c_c));
    sleep(50);
  }
  lc(c_x,cata_y);log(" ");

  record(0);
  exit(0);
}

function thrEnd(){
  while(x<31){
    step();
    sleep(200);
  }

  record(0);
  exit(0);
}

function bend(){
  var chara=250;
  var down=1;
  var pow=0;

  while(down){
    pow=pow+3;

    y=y+1;
    lc(x,y-1);log(" ");
    lc(x,y);log(chr(chara));
    lc(x,y+1);log(chr(c_c));

    if(y>22){
      down=0;
      pow=0;
    }

    sleep(200);
    down=btn();
  }

  return pow;
}

function extend(pow){
  var chara=249;
  var high=0;
  while(pow>0){
    if(y>10){
      y=y-1;
      lc(x,y);log(chr(chara));
      lc(x,y+1);log(chr(c_c));
      lc(x,y+2);log(" ");
    }else{
      lc(rnd(31),0);log(chr(chara));
      scroll(2);
      lc(x,y);log(chr(chara));
      lc(x,y+1);log(" ");
      pow=pow-(rnd(pow)%3==0);
    }

    high=high+1;
    sleep(50);
  }

  return high;
}

function fall(){
  var chara=249;
  while(y<23){
    y=y+1;
    lc(x,y-1);log(" ");
    lc(x,y);log(chr(chara));
    sleep(100);
  }
  lc(x,y);log(" ");
}

function jumping(){
  var pow=bend();
  var high=extend(pow);
  fall();

  record(high);
  exit(0);
}

function gnd(){
  var g_x=0,g_y=y+1;
  while(g_x<32){
    var g_c=143;
    if(g_x==c_x) g_c=c_c;

    lc(g_x,g_y);log(chr(g_c));
    g_x=g_x+1;
  }
}

cls();
gnd();
while(1){
  step();
  sleep(300);

  if(x<c_x){
    if(btn()==1) byeEnd();
  } // else if
  if(x==c_x){
    if(btn()==1) jumping();
  } // else if
  if(c_x<x){
    thrEnd();
  }
}

COMMENT