Need desperate help figuring out this game!!

edited January 2017 in Questions about Code

this is a school project i'm working on...but i'm not much of a computer person so...i need someone's help. this is basically a shooting game but i just can't figure out how to get it to work. i want the cannon to shoot at the round pointing board with bombs and i also want the scoring board. the red centre is 100 and as it gets further away from the red centre point gets minused by 10point.

float cannonX, cannonY; 
float cannonLength = 40;  // How long the cannon on the tank extends
float cannonAngle = PI*3/4;
float cannonAngleStep = 0.005; // step to change cannonAngle

float gravity = 0.01;      // Strength of gravity
float time;  // calculate time for the gravity component
float wind = 0; // Strength of wind
float explodePositionX; 
float explodePositionY;
boolean  explode = false;
float explosionStrength = 1;

boolean objectInMotion = false;
float targetDistance = 50; // distance from left boundary the target is positioned
boolean targetHit = false;
int score = 0;
int total = 0;

float[] groundLevel;  // Y coordinate of the ground for each X coordinate
float x,y; // position of the projectile
float r = 10;   // radius of the projectile
float speed =20.0; // speed of projectile 

void  setup (){
  size (1000,600);
  cannonX = width-20;
  cannonY = height/2;

    // Initialize the ground level
    // Implement random surface of the ground
  groundLevel = new float[width];
  for(float i = 0; i < width; i++) {
   groundLevel[(int)i] = height/3;
  }

  // Load font

}

void draw(){
  background(200);
  drawGround();
  drawTarget();
  drawCannon();
  aimCannon();
  shootCannon();
  drawProjectile();
  drawScore(); 
}

void drawGround(){
    // See the groundLevel[] variable to know where to draw the ground
  // Ground should be drawn in a dark gray
   stroke(118,57,40); // set dark brown
   for(int x = 0; x < width; x++) {
    line (x,height, x,height-groundLevel[x]); // draw in loop a vertikal line at lokation x
  }
}

void drawTarget(){
 ellipseMode(RADIUS);
for (int i = 10; i >0; i--){
    if (i<4) {
     fill(0);
     stroke(255);
    }
    else{
     fill(255);
     stroke(0);
    }
  ellipse(targetDistance,height/2, 10*i, height/2/11*i);

}
stroke(2555,0,0);
line(targetDistance,height/11/2, targetDistance,height-height/11/2); 
}

void drawCannon(){
  stroke(85,107,47); // set darkolivegreen color to draw the cannon
  fill(85,107,47);
  smooth();
  strokeWeight(8);
  // invert the sign of the angle in order to point the cannon upwards (and not downwards)
  line(cannonX, cannonY, cannonX+cannonLength*cos(-cannonAngle), cannonY+cannonLength*sin(-cannonAngle));
  strokeWeight(1); // reset to default widht
  arc(cannonX, cannonY, cannonLength*3/4, cannonLength/2, -PI-PI/6, PI/6);
}

void aimCannon(){
  fill(100);
  ellipse(mouseX, mouseY,1, 1);
}


void shootCannon(){
// Implementation
}

void drawProjectile(){
// Implementation
//  drawExplosion(); 
}

void drawScore(){
  // Display score 
// Implementation
}

// Draw esplosion, if collision with target is detected
void drawExplosion() {
if(explode){
    noStroke();
    fill(255, explosionStrength*2, 0); 
    ellipse(explodePositionX, explodePositionY, explosionStrength, explosionStrength);
    explosionStrength+=5;
 //   delay(2);
    if (explosionStrength>100){
     explode=false; 
      explosionStrength=1;
      }
    } 
}

Answers

Sign In or Register to comment.