expecting EOF, found 'class'
in
Programming Questions
•
2 years ago
Hi,
I'm fairly new to processing, and my only problem is finding and solving errors. If anyone can help, I will be really grateful.
- Ship ship;
- bullet bullet;
- Alien alien0;
- Alien alien1;
- Alien alien2;
- Alien alien3;
- Alien alien4;
- Alien alien5;
- Alien alien6;
- Alien alien7;
- Alien0Bullet alien0bullet;
- Alien1Bullet alien1bullet;
- Alien2Bullet alien2bullet;
- Alien3Bullet alien3bullet;
- Alien4Bullet alien4bullet;
- Alien5Bullet alien5bullet;
- Alien6Bullet alien6bullet;
- Alien7Bullet alien7bullet;
- int score = 0; //inititlises score
- int totalscore; //total score
- boolean gameplay = false;
- void setup () {
- size (1000,600); //size of window
- smooth ();
- //create ship and bullet
- ship = new Ship ();
- bullet = new bullet ();
- //create aliens
- alien0 = new Alien (35, 150);
- alien1 = new Alien (105, 150);
- alien2 = new Alien (175, 150);
- alien3 = new Alien (245, 150);
- alien4 = new Alien (35, 220);
- alien5 = new Alien (105, 220);
- alien6 = new Alien (175, 220);
- alien7 = new Alien (245, 220);
- //create bullets
- alien0bullet = new Alien0Bullet (35,150);
- alien1bullet = new Alien1Bullet (105,150);
- alien2bullet = new Alien2Bullet (175,150);
- alien3bullet = new Alien3Bullet (245,150);
- alien4bullet = new Alien4Bullet (35,220);
- alien5bullet = new Alien5Bullet (105,220);
- alien6bullet = new Alien6Bullet (175,220);
- alien7bullet = new Alien7Bullet (245,220);
- }
- void draw () {
- //fire alien bullets randomly
- float t = random (0,450);
- float r = random (0,450);
- background (0); //black background
- //display title when game is active
- if (ship.GameOver == false); {
- loadFont ("ArialMT-16.vlw");
- fill (255);
- text ("Space Invaders (c) 2011 - Paul Marvell (100088293)",10, 20);
- text ("seconds",500,20);
- text ("health:",950,20);
- fill (0);
- }
- if (ship.AlienCount <= 0) {
- totalscore = totalscore;
- }
- if(spaceship.AlienCount > 0) {
- totalscore=(spaceship.score*100000/millis());
- }
- stroke (255); //white line
- line (0,25,width+1,25); //underline title
- //basic shields
- line(100,500,150,500);
- line(350,500,400,500);
- line(600,500,650,500);
- line(850,500,900,500);
- //display user ship
- ship.display();
- if (ship.ShipHP <= 0) {
- ship.GameOver = true; //if ship HP less than or equal to 0, Game Over
- }
- if (ship.GameOver == true) {
- ship.lose(); //if Game Over true, lose
- }
- if (ship.AlienCount <= 0) {
- if (ship.shipHP > O) {
- ship.win(); //if ship HP more than 0 and 0 aliens on screen, win.
- }
- }
- if (spaceship.GameOver == false) {
- bullet.display ();
- bullet.move (); //if not Game Over display and move user ship
- }
- //display aliens
- alien0.move();
- alien0.display();
- alien1.move();
- alien1.display();
- alien2.move();
- alien2.display();
- alien3.move();
- alien3.display();
- alien4.move();
- alien4.display();
- alien5.move();
- alien5.display();
- alien6.move();
- alien6.display();
- alien7.move();
- alien7.display();
- //if alien has health enable alien bullet display and move
- if (alien0.AlienHealth >0) {
- alien0bullet.display ();
- alien0bullet.move ();
- alien0bullet.fire ();
- }
- if (alien1.AlienHealth >0) {
- alien1bullet.display ();
- alien1bullet.move ();
- alien1bullet.fire ();
- }
- if (alien2.AlienHealth >0) {
- alien2bullet.display ();
- alien2bullet.move ();
- alien2bullet.fire ();
- }
- if (alien3.AlienHealth >0) {
- alien3bullet.display ();
- alien3bullet.move ();
- alien3bullet.fire ();
- }
- if (alien4.AlienHealth >0) {
- alien4bullet.display ();
- alien4bullet.move ();
- alien4bullet.fire ();
- }
- if (alien5.AlienHealth >0) {
- alien5bullet.display ();
- alien5bullet.move ();
- alien5bullet.fire ();
- }
- if (alien6.AlienHealth >0) {
- alien6bullet.display ();
- alien6bullet.move ();
- alien6bullet.fire ();
- }
- if (alien7.AlienHealth >0) {
- alien7bullet.display ();
- alien7bullet.move ();
- alien7bullet.fire ();
- }
- //destroy alien on bullet
- if (alien0.intersect(bullet)) {
- alien0.hp();
- }
- if (alien1.intersect(bullet)) {
- alien1.hp();
- }
- if (alien2.intersect(bullet)) {
- alien2.hp();
- }
- if (alien3.intersect(bullet)) {
- alien3.hp();
- }
- if (alien4.intersect(bullet)) {
- alien4.hp();
- }
- if (alien5.intersect(bullet)) {
- alien5.hp();
- }
- if (alien6.intersect(bullet)) {
- alien6.hp();
- }
- if (alien7.intersect(bullet)) {
- alien7.hp();
- }
- //harm user ship with alien bullet
- if (alien0bullet.intersect (ship)) {
- ship.HP ();
- alien0bullet.bulletfired = false;
- alien0bullet.bullethit = true;
- }
- if (alien1bullet.intersect (ship)) {
- ship.HP ();
- alien1bullet.bulletfired = false;
- alien1bullet.bullethit = true;
- }
- if (alien2bullet.intersect (ship)) {
- ship.HP ();
- alien2bullet.bulletfired = false;
- alien2bullet.bullethit = true;
- }
- if (alien3bullet.intersect (ship)) {
- ship.HP ();
- alien3bullet.bulletfired = false;
- alien3bullet.bullethit = true;
- }
- if (alien4bullet.intersect (ship)) {
- ship.HP ();
- alien4bullet.bulletfired = false;
- alien4bullet.bullethit = true;
- }
- if (alien5bullet.intersect (ship)) {
- ship.HP ();
- alien5bullet.bulletfired = false;
- alien5bullet.bullethit = true;
- }
- if (alien6bullet.intersect (ship)) {
- ship.HP ();
- alien6bullet.bulletfired = false;
- alien6bullet.bullethit = true;
- }
- if (alien7bullet.intersect (ship)) {
- ship.HP ();
- alien7bullet.bulletfired = false;
- alien7bullet.bullethit = true;
- }
- }
- //mouse press fires bullet
- void mousePressed () {
- {
- if ((bullet.bulletHit == true) && (bullet.bulletFired == false));
- {
- bullet.bulletFired = true;
- bullet.bulletHit = flase;
- }
- }
- }
1