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/26 14:50:52

MixJuice GET URL : kidspod.club/mj/369

068

  • No registered tag exist.

SOURCE CODE

var gun_y;
var key;
var beam_x;
var beam_y;
var target;
var flag;
var score;


gun_y = 12;
beam_x = 0;
beam_y = 0;
target = 0;
flag = 0;
score = 0;

while(1){
 key = inkey();
 if((key == 30) * (gun_y > 1)){
  gun_y = gun_y - 1;
 }
 if((key == 31) * (gun_y < 22)){
  gun_y = gun_y + 1;
 }

 if((key == 32) * (beam_x == 0)){
  beam_x = 1;
  beam_y = gun_y;
 }
 if(beam_x != 0){
  beam_x = beam_x + 4;
 }
 if((beam_x > 30) * (beam_y == target)){
  flag = 0;
  score = score + 1;
 }
 if(beam_x > 31){
  beam_x = 0;
 }
 
 if(flag == 0){
  target = rnd(22);
  target = target + 1;
  flag = 1;
 }
 
 cls();
 lc(0, gun_y);
 log("}")
 if(beam_x != 0){
  lc(beam_x, beam_y);
  log("-");
 }
 if(flag == 1){
  lc(31, target);
  log("X");
 }
 lc(0, 0);
 log("SCORE: ");
 log(score);
 
 sleep(30);
}

COMMENT