Hello again, dear readers.
I have created a short game that is called K.U.
Here is the code for it.
_________________________________________________________________________________
var lives=1;
var start=false;
var strt=false;
var stage=1;
//borders
var bord1=60;
var bord2=-70;
//liquids
var lava=-20;
var lavcol='red';
var water=240;
var watcol='turquoise';
var player={
x:30,
y:210,
width:30,
height:30,
}
conscls();
conssay('Please use game() to start game.');
game=function() {
conscls();
start=true;
conssay('Your mission is to kill the red block.');
}
update=function() {
if(start==true && stage==1) {
cngCol('beige');
rect(0,0,WIDTH,HEIGHT);
cngCol('tan');
rect(0,240,WIDTH,120);
cngCol('white');
rect(60,0,230,100);
rect(90,240,170,120);
cngCol('tan');
rect(60,0,30,100);
rect(260,0,30,100);
rect(bord1,70,200,30);
rect(bord2,330,360,30);
if(watcol=='turquoise') {
cngCol(lavcol);
rect(90,lava,170,90);
}
cngCol(watcol);
rect(90,water,170,90);
}
if(start==true && stage==1 && lives==1) {
cngCol('red');
rect(player.x,player.y,player.width,player.height);
}
if(pressingRight==true && start==true) {
player.x+=5;
}
if(pressingLeft==true && start==true) {
player.x-=5;
}
if(pressingA==true && start==true) {
bord1-=5;
}
if(pressingB==true && start==true) {
bord2-=5;
}
if(pressingC==true && start==true) {
bord2+=5;
}
if(pressingUp==true && start==true) {
player.y-=7.5;
}
if(pressingUp==false && player.y<210) {
player.y+=5;
}
if(stage==1) {
if(player.x>90 && player.x<230 && player.y<300 && bord2>-140) {
player.y+=5;
}
if(player.x>90 && player.x<230 && player.y>=300 && bord2<=-140) {
player.y+=5;
}
if(lava<240 && bord1<=-140) {
lava+=5;
}
if(water>=240 && bord2<=-140) {
water+=5;
}
if(water>=240 && bord2<=-140 && watcol=='black') {
water+=5;
lava+=5;
}
if(lava==240 && water==240 && bord1<=-140) {
lava+=5;
watcol='black';
}
if(lava>=240 && bord2<=-140) {
lava+=5;
}
if(player.x>90 && player.x<230 && player.y>360) {
conssay('SUCCESS!');
lives=0;
strt=true;
stage=2;
}
if(player.x>90 && player.x<230 && player.y<=300 && lava==240 && water>240) {
conssay('SUCCESS!');
lives=0;
strt=true;
stage=2;
}
if(watcol=='black') {
conssay('FAIL');
}
}
if(stage==2 && strt==true) {
lives=1;
player.x=30;
player.y=210;
strt=false;
}
if(stage==2) {
}
//border
if(player.x<0) {
player.x=0;
}
if(player.x>330) {
player.x=330;
}
if(player.y<0) {
player.y=0;
}
}
setInterval(update,15);
_________________________________________________________________________________
Oh, and
A is for the border above open
B is for the border below open
C is for the border below close
You can save this code in Program Test.
Unfortunately, this game only has one level. (CURRENTLY)
You can help by expanding (creating new levels) or upgrading my level.
Thanks.
21-04-2017
No comments:
Post a Comment