I don’t know the OSX code – however, it looks to be that you have this:
Graphics g = bs.getDrawGraphics();
g.drawImage(img, 0, 0, WIDTH, HEIGHT, null);
g.dispose();
bs.show();
.. sitting outside any method – it doesn’t appear to be wrapped in anything…
I would advise that you start from the top and make sure you have matching {
and }
braces – that is to say that where you have one open {
you also have a closed one }
– when you identify the one that doesn’t have an end (or start) then you will find the error in your code.
I THINK
You need to change this:
private void render() {
BufferStrategy bs = this.getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
for (int i = 0; i<(WIDTH*HEIGHT); i++);
pixels[i] = screen.pixels[i];
}
Graphics g = bs.getDrawGraphics();
g.drawImage(img, 0, 0, WIDTH, HEIGHT, null);
g.dispose();
bs.show();
To This – notice its now wrapped in {
}
ok 🙂
Again – i do not know OSX, though the syntax below looks correct
private void render() {
BufferStrategy bs = this.getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
for (int i = 0; i<(WIDTH*HEIGHT); i++){ // changed ; for {
pixels[i] = screen.pixels[i];
}
Graphics g = bs.getDrawGraphics();
g.drawImage(img, 0, 0, WIDTH, HEIGHT, null);
g.dispose();
bs.show();
} // added this here
8
solved Can anyone help fix my code [closed]