My first game ever

33 views
Skip to first unread message

le ly

unread,
Aug 29, 2018, 1:00:06 AM8/29/18
to Processing.js
I'm 13 and was wondering if you could give me some tips on my code or what to add?

float score;
int x;
int y;
float v;
PImage img;
PImage imgg;
float scoreR = 20;
void setup() {
  size(500, 500);
  score = 0;
  x = 200;
  y = 100;
  v = 1;
  img = loadImage("banana.jpg");
  imgg = loadImage("background.jpg");
}
void draw() {
  background(255);
  image(imgg, 0, 0, width, height);
  image(img, x-25, y-20, 150, 150);
  fill(0, 0, 255);
  textSize(20);
  text(score, 20, 20);
  text("upgrades", 350, 20);
  fill(0, 255, 0);
  text("20", 375, 40);
  text("80", 375, 60);
  text("320", 375, 80);
  text("1280", 375, 100);
  text("10240", 375, 120);
  text("81920", 375, 140);
  if (score>20) {
     if (score>scoreR) {
    scoreR = scoreR * 4;
    v=v*2;
    }  
    if (score>scoreR) {
    scoreR = scoreR * 4;
    v=v*2;
    }  
    if (score>scoreR) {
    scoreR = scoreR * 4;
    v=v*2;
    }  
    if (score>scoreR) {
    scoreR = scoreR * 4;
    v=v*2;
    }  
    if (score>scoreR) {
    scoreR = scoreR * 4;
    v=v*2;
    }  
    if (score>scoreR) {
    scoreR = scoreR * 4;
    v=v*2;
    }  
  }
 
    

}

void sap () {
  score = score+v;
}

void mouseReleased() {
  if (mouseY>y && mouseX>x && mouseY<y+100 && mouseX<x+100) {
    sap();
  }

}
Reply all
Reply to author
Forward
0 new messages