xxxxxxxxxx
function preload() {
//rawJSON = loadJSON("https://www.openprocessing.org/api/sketch/908635/true");
}
function plat (x2,y2,w2,h2) {
t3++
strokeWeight (0)
fill (255,255,255)
//rect (x2,y2,w2,h2);
ellipse(x2+75,y2+5,150,40)
if (xg>x2&&xg<x2+w2&&yg>y2-20&&yg<y2+h2) {xg-=speed;if (keyIsDown(38)){yspeed=-15}else{yspeed=0;yg=y2-20} }else {yspeed+=0.1}
}
var highscore
function setup() {
createCanvas(windowWidth, windowHeight);
highscore = getItem('highscore')
background(999);
poo=-100
plats.push(new Plat2())
poo=450
plats.push(new Plat2())
poo+=450
plats.push(new Plat2())
poo+=450
plats.push(new Plat2())
poo+=450
plats.push(new Plat2())
}
var x=600
var y=600
var yspeed=0
var xspeed=0
var t3=0
var maxspeed=13
var canmove=1
var canjump=0
var r=0
var poo=0
var stop=0
var xg=500
var yg=200
var score=0
var speed=3
var plats=[]
function draw() {
background(0, 221, 255);
if (highscore==null) {highscore=0}
if (score>highscore) {highscore=score}
for (var i=0; i< plats.length;i++){
plats[i].move();
}
textSize(20)
fill (0)
text("score: "+score+" "+"highscore: "+highscore,30,30)
textSize(70)
//text("Cloud Jumper",400,350)
if (xg<-10) {end()}
if (yg>height+10) {end()}
fill (21, 199, 8)
ellipse(xg, yg, 35, 35);
yg+=yspeed
// if (!keyIsPressed) {xg-=3}
xg+=xspeed
// plat (x,y,200,40)
r+=0.02
if (speed<=8){speed+=0.0007}
if (xspeed<0) {xspeed+=0.5}
else {if (xspeed>0){xspeed-=0.5}}
if (keyIsDown(37)) {if (abs(xspeed)>maxspeed||abs(xspeed)==maxspeed)
{} else {if (canmove==1){xspeed-=1}}}
if (keyIsDown(39)) {if (abs(xspeed)>maxspeed||abs(xspeed)==maxspeed)
{} else {if (canmove==1){xspeed+=1}}}
strokeWeight(0)
push()
textSize(20)
textAlign(CENTER);
if(mouseY>height-50){fill(999)
rect(0,height-50,width,50)
fill(0)
text("?️ " +rawJSON.sketch.numberOfViews+" ♡"+rawJSON.sketch.hearts.length+" ?"+rawJSON.sketch.comments.length,width/2,height-20)
}
pop()
}
function Plat2 () {
this.x=poo
this.y=height/2
this.yspeed=0
this.t=0
this.move=function(){
this.x-=speed
plat(this.x,this.y,150,40)
if (this.x<-150) {score++;this.x=width+random(150,250);this.y=noise(r-0.4)*height}
}
}
function end () {
background(999)
fill (0)
textSize(40)
textAlign(CENTER,CENTER)
text ("Game over",width/2,height/2)
storeItem ('highscore', highscore)
textSize(30)
text("score: "+score+" "+"highscore: "+highscore,width/2,height/2+50)
noLoop()
}