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

2017/11/22 21:25:27

MixJuice GET URL : kidspod.club/mj/431

熱的 ver1

タップ(クリック)して数字を止めよう!
全部そろえられるかな?
大きな数をそろえると温度が上がるぞ。
IchigoLatteで遊ぶときはボタンを押そう。

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


"ThermodynamicSlot ver.1"
Tap (click) to stop the numbers!
Can you have all of them?
Temperature rises when a large number is aligned.
When playing with IchigoLatte, press the button.

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

SOURCE CODE

var order=3;
var ptc=8;
var aPos=new Array(32);
var t=200;

function prepare(){
  var i=0;
  while(i<ptc){
    aPos[4*i+0]=rnd(32)+1;
    aPos[4*i+1]=rnd(7)+15;
    aPos[4*i+2]=rnd(1)*2-1;
    aPos[4*i+3]=rnd(1)*2-1;
    i=i+1;
  }
}

function thermo(){
  var i=0;
  while(i<ptc){
    move(i);
    i=i+1;
  }

  setTout(thermo, t);
}

function move(i){
  var n=4*i;

  var xdest=aPos[n+0]+aPos[n+2];
  var ydest=aPos[n+1]+aPos[n+3];
  var cdest=scr(xdest,ydest);
  var coll=(cdest!=0)*(cdest!=32);
  var xref=coll+(xdest<=0)+(xdest>=31);
  var yref=coll+(ydest<=0)+(ydest>=22);

  if(xref==1) aPos[n+2]=aPos[n+2]*-1;
  if(yref==1) aPos[n+3]=aPos[n+3]*-1;

  if((xref==1)+(yref==1)) return;


  lc(aPos[n+0],aPos[n+1]);log(" ");
  aPos[n+0]=aPos[n+0]+aPos[n+2];
  aPos[n+1]=aPos[n+1]+aPos[n+3];
  lc(aPos[n+0],aPos[n+1]);log(chr(245));
}

var i=0;
var x=14,y=10,num=0;

cls();
while(i<order){
  lc(x+i,y);log(num);
  num=(num+1)%10;

  if(btn()==1){
    i=i+1;
    sleep(500);
  }

  sleep(50);
}

i=0;
var crct=1;
while(i<order){
  crct=crct*(scr(x,y)==scr(x+i,y));
  i=i+1;
}

if(crct==1){
  if(scr(x,y)<=52){
    lc(x,y+2);log("hot!");
    t=50;
  }else{
    lc(x-4,y+2);log("too hot!!!");
    t=5;
  }
}else{
  lc(x-4,y+2);log("too cold...");
  t=200;
}

prepare();
thermo();

COMMENT