Reputation: 53
I'm not sure whats going on here I keep getting an unexpected identifier return on my first line of code but I can't tell whats going on is there something wrong with my code or is it my compiler?
private static final float IDEAL_FRAME_RATE = 100;
KeyInput currentKeyInput;
GameSystem system;
PFont smallFont, largeFont;
boolean paused;
void setup() {
size(1360, 640, P2D);
frameRate(IDEAL_FRAME_RATE);
// Prepare font
final String fontFilePath = "Lato-Regular.ttf";
smallFont = createFont(fontFilePath, 20f, true);
largeFont = createFont(fontFilePath, 96f, true);
textFont(largeFont, 96f);
textAlign(CENTER, CENTER);
rectMode(CENTER);
ellipseMode(CENTER);
currentKeyInput = new KeyInput();
newGame(true, true); // demo play (computer vs computer), shows instruction window
}
void draw() {
if(keyIsDown(72))
println("H");
background(255f);
background(random(255), random(255), random(255));
system.run();
}
void newGame(boolean demo, boolean instruction) {
system = new GameSystem(demo, instruction);
}
void mousePressed() {
system.showsInstructionWindow = !system.showsInstructionWindow;
}
There are six other classes that go with this one if there is nothing wrong with this one could it be due to another lass? If I need to link then I will gladly cause I'm stuck and really want to get this done
Upvotes: 1
Views: 75
Reputation: 2930
Since you've now mentioned that this is in Processing, see https://en.wikipedia.org/wiki/Processing_(programming_language) where it mentions that "static" is not allowed (you have it at IDEAL_FRAME_RATE at the 1st line, which would explain the error message you were getting)
Every Processing sketch is actually a subclass of the PApplet[3] Java class (formerly a subclass of Java's built-in Applet) which implements most of the Processing language's features.
When programming in Processing, all additional classes defined will be treated as inner classes when the code is translated into pure Java before compiling. This means that the use of static variables and methods in classes is prohibited unless Processing is explicitly told to code in pure Java mode.
Processing also allows for users to create their own classes within the PApplet sketch. This allows for complex data types that can include any number of arguments and avoids the limitations of solely using standard data types such as: int (integer), char (character), float (real number), and color (RGB, ARGB, hex).
Upvotes: 1
Reputation: 2930
Java doesn't have modules like VB does (at least last time I checked). So you're missing a class statement to wrap your code I guess.
public class SomeClass {
//...
}
See https://docs.oracle.com/javase/tutorial/java/javaOO/classes.html
Upvotes: 0