My bolt class is not being recognized. Any suggestions?
import processing.sound.*;
SoundFile myAudio;
SoundFile AudioWin;
//variables
float rectx =100;
float recty =100;
float b=20;
PImage myImageRobot;
PImage myImageBolt;
PImage ImageBackground;
PImage ImageYouWin;
int s;
int score;
int d;
boolean GameOver=false;
boolean hit = false;
Bolts MyBolts1;
Bolts MyBolts2;
Bolts MyBolts3;
void setup() {
size(400,400);
//character
ImageBackground = loadImage("Background.png");
ImageYouWin = loadImage("YouWin.png");
myImageBolt = loadImage("Bolt.jpg");
myImageRobot = loadImage("Robot.png");
//Audio
myAudio = new SoundFile(this, "Coins.mp3");//import soundfile
AudioWin = new SoundFile(this, "YouWin.mp3");
//Characters
MyBolts1 = new Bolts(7,6,1,2,12,15,myImageBolt);
MyBolts2 = new Bolts(6,8,2,4,10,19,myImageBolt);
MyBolts3 = new Bolts(8,10,3,6,15,9,myImageBolt);
noStroke();
}
void draw() {
Background();
MoveRobot();
text("My Score", 340, 20);
text(score, 400, 20);
MyBolts1.BouncingBolt();
MyBolts1.SetDistance(rectx,recty);
MyBolts1.Score();
MyBolts2.BouncingBolt();
MyBolts2.SetDistance(rectx,recty);
MyBolts2.Score();
MyBolts3.BouncingBolt();
MyBolts3.SetDistance(rectx,recty);
MyBolts3.Score();
}
void Background(){
background(ImageBackground);
}
void MoveRobot(){
imageMode(CENTER);
image(myImageRobot, rectx, recty, 60, 60);
if(keyCode==LEFT){
print(LEFT);
rectx=rectx-2;
}
if(keyCode==RIGHT){
print(RIGHT);
rectx=rectx+2;
}
if(keyCode==UP){
print(UP);
recty=recty-2;
}
if(keyCode==DOWN){
print(DOWN);
recty=recty+2;}
if (rectx<20) {
rectx=20;
}
if (rectx>460) {
rectx=460;
}
if (recty<30) {
recty=30;
}
if (recty>400) {
recty=400;
}
}
///Class Bolts
class Bolts {
//class variables
float x;
float y;
PImage myImageBolt;
float d;
float directionY;
float directionX;
float speedX;
float speedY;
float score;
boolean GameOver=false;
boolean hit = false;
float rectx = 200;
float recty = 200;
//Constructor
Bolts(float X, float Y, Float dx, float dy, float sx, float sy, PImage B){
x=X;
y=Y;
directionX=dx;
directionY=dy;
speedX=sx;
speedY=sy;
myImageBolt=B;
}
void BouncingBolt() {
x=x+directionX*speedX;
y=y+directionY*speedY;
imageMode(CENTER);
image(myImageBolt, x, y, 50, 50);
if ((x>width-10)||(x<10)) {
directionX = directionX*-1;//change direction
println(x);
}
if ((y>height-10)||(y<10)) {
directionY =directionY*-1;
println(y);
}
}
void SetDistance(float rectx, float recty) {
d=dist(rectx, recty, x, y);
}
void Score() {
fill(255);
if ((d<30)&&(hit==false)) {
score=score+1;
myAudio.play();
hit = true;
}
if (d>30) {
hit=false;
}
if ((score==5) && (GameOver==false)) {
AudioWin.play();
image(ImageYouWin, 240, 240, 480, 480);
GameOver=true;
noLoop();
}
}
}