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/19 10:12:03

MixJuice GET URL : kidspod.club/mj/427

083

  • No registered tag exist.

SOURCE CODE

var sy;
var key;
var nx;
var flag;
var jflag;
var score;
var r;
var s;

sy = 22;
nx = 0;
flag = 0;
score = 0;
jflag = 0;
s = 100;

while(1){
 r = rnd(10);
 if(r == 9){
  s = s + 18;
 }
 if(r == 8){
  s = s - 16;
 }
 if(r == 7){
  s = s + 14;
 }
 if(r == 6){
  s = s - 12;
 }
 if(r == 5){
  s = s + 10;
 }
 if(r == 4){
  s = s - 8;
 }
 if(r == 3){
  s = s + 6;
 }
 if(r == 2){
  s = s - 4;
 }
 if(r == 1){
  s = s + 2;
 }
 if(r == 0){
  s = s - 30;
 }
 
 if(nx == 15){
  score = score + 10;
 }
 
 key = inkey();
 if((nx == 15) * (sy == 22)){
  break;
 }
 if((key == 32) * (jflag == 0)){
  sy = sy - 5;
  jflag = 1;
 }
 if(sy == 22){
  jflag = 0;
 }
 if(sy < 22){
  sy = sy + 1;
 }
 if(flag == 0){
  if(nx < 30){
   nx = nx + 1;
  }
  else{
   nx = nx - 1;
   flag = 1;
  }
 }
 else{
  if(nx > 0){
   nx = nx - 1;
  }
  else{
   nx = nx + 1;
   flag = 0;
  }
 }
 cls();
 lc(0, 0);
 log("SCORE:");
 log(score);
 lc(15, sy);
 log(chr(0xF9));
 lc(nx, 22);
 log("_");
 sleep(s);
}

COMMENT