so I went on and started creationg game as usual. Except this time I got an error O.o. I was trying to find an answer, but non of the ones I thought maybe here I can get a good Answer! Heres the error:
Description Resource Path Location Type Cannot make a static reference to the non-static field image Game.java /POGA/src/packagehere line 71 Java Problem
Description Resource Path Location Type Cannot make a static reference to the non-static method createBufferStrategy(int) from the type Canvas Game.java /POGA/src/packagehere line 66 Java Problem
I get more of these type, but I guess If you show me and viewers of this question how to fix these errors we would be able to fix the rest of the "same" ones...
package packagehere;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
public class Game extends Canvas implements Runnable{
private static final long serialVersionUID = 1L;
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
public static boolean running = false;
JFrame frame;
public static String title = "POGA game thingy - 0.1 Aplha";
public static final int WIDTH = 800;
public static final int HEIGHT = 600;
public static final Dimension gameDim = new Dimension(WIDTH, HEIGHT);
synchronized void start() {
Thread thread = new Thread();
thread.start();
running = true;
}
public void run() {
while(running) {
tick();
render();
}
}
synchronized void stop() {
running = false;
System.exit(0);
}
public Game() {
setMaximumSize(gameDim);
setMinimumSize(gameDim);
setPreferredSize(gameDim);
frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
frame.requestFocus();
}
public static void tick() {
}
public static void render() {
BufferStrategy bs = getBufferStrategy();
if(bs == null) {
bs = createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
g.dispose();
bs.show();
}
}