Expecting EOF when attempting to use Processing in Eclipse
in
Integration and Hardware
•
5 months ago
I can't seem to get Eclipse/Processing to cooperate. I'm getting "expecting EOF, found 'PImage'" on line 17... which I can't figure out. I know getting an EOF usually means you're missing a brace there, but I've not even gotten past class variables.
Deleting everything above changes nothing (meaning there isn't a stray curly brace in there), and if I delete that line it throws the same error message on the next all the way down the file.
Yet when I ran this same code in Processing, I didn't have any issues. I really would rather work in Eclipse, but I'm stumped.
- import ddf.minim.*;
- final static int xResolution = 1280;
- final static int yResolution = 720;
- final static float ground = 40;
- final static int baseFrameRate = 60;
- static Player player;
- static LevelData levelData;
- static Camera camera;
- static IntroductionScreen introductionScreen;
- static InstructionScreen instructionScreen;
- static WinScreen winScreen;
- static LoseScreen loseScreen;
- static int backgroundColor = 255;
- PImage backgroundImg;
- PImage playerImg;
- PImage monsterImg;
- PImage flyingImg;
- PImage bulletImg;
- Sprite playerSprite;
- Sprite monsterSprite;
- Sprite flyingSprite;
- Sprite bulletSprite;
- Minim minim;
- AudioPlayer lub;
- AudioPlayer dub;
- AudioPlayer hit;
- AudioPlayer music;
- MonsterSpawner monsterSpawner;
- Renderer renderer;
- // Main setup method that is called on game load.
- void setup() {
- loadMusic();
- size(1280, 720, P2D);
- frameRate(baseFrameRate);
- background(backgroundColor);
- smooth();
- SplashScreen splashScreen = new SplashScreen();
- splashScreen.drawSplashScreen();
- loadImagesAndSprites();
- createScreens();
- monsterSpawner = new MonsterSpawner();
- player = new Player(xResolution/2, yResolution/2, playerSprite);
- Physics.addPlayerEntity(player);
- levelData = new LevelData();
- levelData.createLevelOneGroundHeights();
- camera = new Camera();
- renderer = new Renderer();
- textSize(32);
- randomSeed(234234324);
- music.play();
- }
- void createScreens(){
- introductionScreen = new IntroductionScreen(true);
- instructionScreen = new InstructionScreen();
- winScreen = new WinScreen();
- loseScreen = new LoseScreen();
- }
- void loadImagesAndSprites(){
- backgroundImg = loadImage("bg_full_Background.png");
- playerImg = loadImage("commando_jump_scale.png");
- playerSprite = new Sprite(playerImg);
- monsterImg = loadImage("zombie_scale.png");
- monsterSprite = new Sprite(monsterImg);
- flyingImg = loadImage("eye1-scale.png");
- flyingSprite = new Sprite(flyingImg, 100, 100, 0,50);
- bulletImg = loadImage("Bullet.png");
- bulletSprite = new Sprite(bulletImg);
- }
- void loadMusic(){
- minim = new Minim(this);
- lub = minim.loadFile("Lub.wav");
- dub = minim.loadFile("Dub.wav");
- hit = minim.loadFile("Hit.wav");
- music = minim.loadFile("Jeff_Game.wav");
- music.loop();
- }
- // Automatically called as frequently as possible.
- void draw(){
- if (introductionScreen.introductionScreenActive){
- introductionScreen.drawIntroductionScreen();
- } else if (winScreen.winScreenActive){
- winScreen.drawWinScreen();
- } else if (loseScreen.loseScreenActive){
- loseScreen.drawLoseScreen();
- } else if (instructionScreen.instructionScreenActive){
- instructionScreen.drawInstructionScreen();
- } else {
- //background(backgroundColor);
- monsterSpawner.update(1/(float)baseFrameRate);
- Physics.updateGameObjects(1/(float)baseFrameRate);
- renderer.drawGameObjects();
- }
- }
- // Handles all keyboard presses
- public void keyPressed(){
- if(introductionScreen.introductionScreenActive || winScreen.winScreenActive || loseScreen.loseScreenActive) { // Prevent the player from moving while screens are active
- } else {
- switch (key) {
- case ('w'):case ('W'):player.goUp = true;break;
- case ('a'):case ('A'):player.goLeft = true;break;
- case ('s'):case ('S'):player.goDown = true;break;
- case ('d'):case ('D'):player.goRight = true;break;
- case ('i'):case ('I'):instructionScreen.instructionScreenActive = true;break;
- }
- }
- }
- // Handles all keyboard releases
- public void keyReleased(){
- if(introductionScreen.introductionScreenActive) // If the introduction screen is up, allow the player to press any key to begin
- {
- introductionScreen.introductionScreenActive = false;
- } if (winScreen.winScreenActive) // if the win screen is up, allow the player to press spacebar to restart the game
- {
- if (key == ' ')
- {
- clearGameObjectArrays();
- addPlayerToStart();
- winScreen.winScreenActive = false;
- }
- } else if (loseScreen.loseScreenActive){ // if the lose screen is up, allow the player to press spacebar to restart the game
- if (key == ' '){
- clearGameObjectArrays();
- addPlayerToStart();
- loseScreen.loseScreenActive = false;
- }
- } else // no screen active, player is actually playing the game
- {
- switch (key) {
- case ('w'):case ('W'):player.goUp = false;break;
- case ('a'):case ('A'):player.goLeft = false;break;
- case ('s'):case ('S'):player.goDown = false;break;
- case ('d'):case ('D'):player.goRight = false;break;
- case ('i'):case ('I'):instructionScreen.instructionScreenActive = false;break;
- }
- }
- }
- // Clears all of the game object arrays (player, npcs, bullets)
- public void clearGameObjectArrays(){
- Physics.playerEntities.clear();
- Physics.gameEntities.clear();
- Physics.playerBullets.clear();
- Physics.enemyBullets.clear();
- }
- // Adds the player to the start of the map and adds them to the physics handler
- public void addPlayerToStart(){
- player = new Player(xResolution/2, yResolution/2, playerSprite);
- Physics.addPlayerEntity(player);
- }
- // Used to stop the music
- public void stop(){
- lub.close();
- dub.close();
- minim.stop();
- }
1