Hi there,
I’m currently using this code:
public Game() {
// create a frame to contain our game
JFrame container = new JFrame("Space Invaders by Konect Internet");
// get screen size
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// set screen width
sWidth = (int)screen.getWidth();
sHeight = (int)screen.getHeight();
// get hold the content of the frame and set up the resolution of the game
JPanel panel = (JPanel) container.getContentPane();
panel.setPreferredSize(new Dimension(sWidth,sHeight));
panel.setLayout(null);
// setup our canvas size and put it into the content of the frame
setBounds(0,0,sWidth,sHeight);
panel.add(this);
// Tell AWT not to bother repainting our canvas since we're
// going to do that our self in accelerated mode
setIgnoreRepaint(true);
// finally make the window visible
container.pack();
container.setResizable(true);
container.setVisible(true);
// add a listener to respond to the user closing the window. If they
// do we'd like to exit the game
container.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
// add a key input system (defined below) to our canvas
// so we can respond to key pressed
addKeyListener(new KeyInputHandler());
// request the focus so key events come to us
requestFocus();
// create the buffering strategy which will allow AWT
// to manage our accelerated graphics
createBufferStrategy(2);
strategy = getBufferStrategy();
// initialise the entities in our game so there's something
// to see at startup
initEntities();
// Start the main game loop, note: this method will not
// return until the game has finished running. Hence we are
// using the actual main thread to run the game.
gameLoop();
}
Admittedly most of that isn’t mine. I’m just fiddling around here with an open source game of spave invaders. One of the first things I’d to be able to get it to do is to go fullscreen but I’ve been over alsorts of tutorials and none of them seem to work for me.
I’m very new to Java but not to programming in general. Hopefully somebody can help!
Thanks,
Chris Evans