I get a null pointer exception error message and all i am trying to do is apply text to the programe with an int for the player score... However when i call upon the function of the ScoreUp class in draw, i get the error. Seems silly for such a simple thing!!!
Any hep appreciatted, ill just pop the code up....
//Main class
Star [] star = new Star [50];//Declare as a collection/array of stars and the size - 50.
Enemy [] enemy = new Enemy[3];//Declare classes
Planet [] planet = new Planet[6];
minim = new Minim(this);
player = minim.loadFile("theme.mp3");
//player.play();
crash = minim.loadSample("crash.mp3");
bulletCollection = new ArrayList();
for (int i = 0; i < 6; i ++) {
planet [i] = new Planet(random(0, width), random(0, height), 15, 15);
}
for (int i = 0; i < enemy.length; i ++) {
enemy [i] = new Enemy(1050, random(100, 600), 50, 50);//initialize parameters in here
}
PImage simg = loadImage("ship.jpg");
user = new User(75, 350, simg);
for (int i = 0; i < 50; i ++) {
star [i] = new Star(random (0, width), random(0, height), 5, 5);
}
}
void draw() {
background(0);
noStroke();
score.displayScore();
for (int i = 0; i < bulletCollection.size() ; i ++) {
Bullets bullets = (Bullets) bulletCollection.get(i);
bullets.run();
}
for (int i = 0; i < 50; i ++) {
star[i].run();//call upon all elements of the array. If i was a 0 itwould call one star
star[i].move();
if (star[i].x < 0) {
star [i] = new Star( width, random(0, height), 5, 5);
}
}
for (int i = 0; i < enemy.length; i ++) {
enemy[i].run();
}
for (int i = 0; i < 6; i ++) {
planet[i].display();
planet[i].move();
if (planet[i].x < 0) {
planet [i] = new Planet(random(1000, 1200), random(0, height), 15, 15);
}
}
I am new to Processing and was wondering if anyone would be so kind as to help me with this puzzler. The bullets start to fire with the mousePressed option..... however when they do the spaceship will not respond to movements with the left right keys... Any ideas would be appreciatted...
Many thanks..
Star [] star = new Star [50];//Declare as a collection/array of stars and the size - 50.
Enemy [] enemy = new Enemy[3];//Declare classes
Planet [] planet = new Planet[6];
minim = new Minim(this);
player = minim.loadFile("theme.mp3");
player.play();
crash = minim.loadSample("crash.mp3");
bulletCollection = new ArrayList();
//for (int i = 0; i < 20; i ++) {
//Bullets bullets = new Bullets(200, 200, 40, 40);
//bulletCollection.add(bullets);
//}
for (int i = 0; i < 6; i ++) {
planet [i] = new Planet(random(0, width), random(0, height), 15, 15);
}
for (int i = 0; i < 2; i ++) {
enemy [i] = new Enemy(1050, random(100, 600), 50, 50);//initialize parameters in here
}
PImage simg = loadImage("ship.jpg");
user = new User(75, 350, simg);
for (int i = 0; i < 50; i ++) {
star [i] = new Star(random (0, width), random(0, height), 5, 5);
}
}
void draw() {
background(0);
noStroke();
for (int i = 0; i < bulletCollection.size() ; i ++) {
Bullets bullets = (Bullets) bulletCollection.get(i);
bullets.run();
}
for (int i = 0; i < 50; i ++) {
star[i].run();//call upon all elements of the array. If i was a 0 itwould call one star
star[i].move();
if (star[i].x < 0) {
star [i] = new Star( width, random(0, height), 5, 5);
}
}
for (int i = 0; i < 2; i ++) {
enemy[i].run();
}
for (int i = 0; i < 6; i ++) {
planet[i].display();
planet[i].move();
if (planet[i].x < 0) {
planet [i] = new Planet(random(1000, 1200), random(0, height), 15, 15);
}
}