> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://cst1101.sketchpad.cc/sp/pad/view/ro.ZGtIl6YIIM5/rev.162
 * 
 * authors: 
 *   Suly Paredes
 *   Corey Ausby

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



/* @pjs preload="/static/uploaded_resources/p.3297/cloud.png,"
/static/uploaded_resources/p.3297/fireball.png",
/static/uploaded_resources/p.3297/plane.png";*/

PImage plane = loadImage("/static/uploaded_resources/p.3297/plane.png");
PImage fireball = loadImage("/static/uploaded_resources/p.3297/fireball.png");
PImage cloud = loadImage("/static/uploaded_resources/p.3297/cloud.png");

_Dodge [] fire1;
int []fireBall;
int fireTime = 0;

void setup() {
  size(800, 400);
  fire1 = new _Dodge[20];
  for (int i = 0; i < fire1.length; i++) {
    fire1[i] = new _Dodge(int(random(0, width)), i*30, i/1, 20);
  }
}

void draw() {
  background(114, 166, 227);
  fill(255);
  for (int i = 0; i < fire1.length; i++) {
    fire1[i].displayFire();
    fire1[i].flyBalls();
    fire1[i].displayClouds();
  }
  
  int X =fireTime;
  image(plane, 670, pmouseY, 115, 50);
  fireTime = fireTime + 20;
  fill(255, 0, 0);
  textSize(32);
  text("Score: " + X, 10, 30);
}

class _Dodge {
  int fireX;
  int fireY;
  int fireSpeed;
  int fireSize;

  _Dodge(int fireX_, int fireY_, int fireSpeed_, int fireSize_) { // constructor
    fireX = fireX_;
    fireY = fireY_;
    fireSpeed = fireSpeed_;
    fireSize = fireSize_;
  }

  void flyBalls() { // methods
    fireX = fireX + fireSpeed;
    if (fireX > width) {
      fireX = 0;
    }
  }

  void displayFire() { // methods
    //ellipse(fireX, fireY, fireSize, fireSize/2);
    image(fireball, fireX, fireY, 50, 25);
  }

  void displayClouds() { // methods
    //ellipse(fireX, fireY, fireSize, fireSize/2);
    image(cloud, fireX, fireY, 200, 115);
  }
}