If we make the game a Web Start application, how do you measure the size of the jar? What’s the deal with manifests and signing?
take a peek at last year’s rules
at the end of the contest, I have a small program that downloads all JNLPs, reads them, and downloads all the resources onto my harddrives into individual folders for each game. I then can see the size at the click of a button. A signed jar that is greater than 4096 bytes is allowed only if you provide the exact same jar unsigned that is <= 4096 bytes. you are able to provide both webstart and unsigned jar file on the submission page.
Don’t forget you only need to sign the jar if you are going to use fullscreen. Otherwise it will work unsigned.
Really?! For the Web Start version, do we need a manifest?
nope. be sure pass the “M” (uppercase) to the jar command to avoid creating a manifest. the JNLP allows you to specify what the main class is.
with this in mind, sometimes distributing with webstart is smaller than distributing standalone JARs.
in addition to fullscreen, most people prefer to sign to get rid of the “Java Application Window” message, which can get in the way of some game graphics if they’re drawing directly to the JFrame. (also some classes such as Robot need signing to use)
standalone JARs never ever have the “Java Application Window” message, and never need to be signed to use any classes. so the balance typically is: “I don’t need a manifest, but I might need to sign.” (webstart) and “I don’t need to sign, but I do need a manifest for it to run” (standalone jar)
By drawing directly to the JFrame, do you mean calling createBufferStrategy() and flipping those buffers vs. drawing to a BufferedImage and displaying that image on the content pane?
Why would you use the Robot class in a game?
BufferStrategy (from the JFrame as opposed to a Canvas) would be drawing directly to the JFrame, as well as calling JFrame.getGraphics().drawImage(buffer,0,0,null);
I usually shove a JPanel onto the JFrame and use the JPanel’s graphics to render. (well that’s what I do in 4K, anyway :P)
to trap the mouse. (think of an FPS: you should be able to move the mouse inifinitely in any direction to move the camera around. by using Robot, you can wrap the mouse back to the original location so it can continue to freely move)
[quote]I usually shove a JPanel onto the JFrame and use the JPanel’s graphics to render. (well that’s what I do in 4K, anyway )
[/quote]
By that, do you mean you render to a BufferedImage and then draw that image to the JPanel? Is it better to extract the content pane and cast it to a JPanel or to create a new JPanel and make that the content pane?
blink
I do it like this (I only do it this way for 4K, as it is bad design)
public class Game {
public static void main(String args[]) {
JFrame f = new JFrame();
JPanel p = new JPanel();
// size of the game, regardless of
// any "java application window" messages
p.setPreferredSize(new Dimension(640,480));
f.getContentPane().add(p,BorderLayout.CENTER);
f.pack();
f.show();
BufferedImage b = new BufferedImage(640,480,BufferedImage.TYPE_INT_ARGB);
while (true) { // game loop
// update stuff
// ...
Graphics gfx = b.createGraphics();
// draw stuff to buffer
// ...
// render to screen
Graphics g = getGraphics();
if (g != null) g.drawImage(b,0,0,null);
g.dispose();
gfx.dispose();
}
}
}
… or something like that (that’s off the top of my head, uncompiled). take a look at the Goomba4K source for a better idea of how I do it.
Cool.