my broken 4hr game

Hello all,

Me and a buddy had a race to remake this game in 4 hours and all went well and that is done, problem is that I have converted the game to an applet when it was originaly an application and I am now loading the applet from a jar using archive="blah" code="blah", and this all works good except for one image is messed up when I do it this way. I have another version of the applet which loads the applet from outside of a jar and it works fine, here are the two applets:

Loading without jar (works fine): http://www.cyntaks.com/spikeattack

Loading with jar (background image is messed up): http://www.cyntaks.com/spikeattack2

Please give me your opinions on the game as well, I believe this is the first animated game I have completed... completely (well, almost).

Here is how I am loading/creating the image that is having trouble

VolatileImage bg = gc.createCompatibleVolatileImage(285, 380);

BufferedImage src = ImageIO.read(getClass().getResource("bg.gif"));

Graphics2D g2 = bg.createGrapics();

g2.drawImage(src, 0, 0, 285, 380,null);

//in another part of the program

Graphics2D g2 = (Graphics2D)strategy.getDrawGraphics();

g2.drawImage(bg, 0, 0, 285, 380,null);

my drawing surface is a Canvas by the way.

I'm not sure how to describe whats happening to my background when I use the jar, so it would be best to just check out both versions. Also, I forgot to say that all the other sounds/images in the program work just fine with the jar.

Thanks for any opinions and possibly a fix!

[1741 byte] By [westonbeecroft] at [2007-9-30 10:20:50]
# 1
I like the game! But as I played for a minute I found that my rockets didn't reload fast enough to keep up with the bombs and I had no way to stop them
Malohkan at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 2
That may be a problem but perhaps its just tough, I have only been to level 10 and therefore have been unable to test higher levels to see if they are possible, any chance you could tell me what level you made it to?
westonbeecroft at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 3
around level 4 and 5 it gets hard to clear things before they're like 15 pixels above the characters. Some bombs I simply never get enough missiles to clear. I never miss, but I just can't get them all.
Malohkan at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 4

Hmm well you can definitely get to higher levels - there is only one rocket available on screen, so if you miss you'll have to wait for the rocket to clear out of the screen before you can fire again. Quick firing is possible if it blew up as close to the ground as possible. So a lot of mines can be cleared if they're close to the ground. I've gotten to lvl 7 for my 2nd try. Dunno why I'm posting something so irrelevant to programming though...

Its a good simple game design. Though the one rocket limit can get things really frantic.

Daisuke_J at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 5
ok on mine it takes close to 2 seconds after a rocket has finished its explosion animation to fire another. I've also noticed if you drag the mouse at all when you click it doesn't fire a rocket. Perhaps you could handle the mouseDragged() method as well?
Malohkan at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 6

Perhaps handling the mouseReleased event would work well for that so when you finish dragging it fires one. As for it taking 2 seconds, yeah that would make it unplayable, but I have no idea how that could happen... I have tried it on a couple different computers myself and had friends try it and I always got replies that it worked fine. Are you using a 14 year old computer with a .2mhz processor? jk.

westonbeecroft at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 7

To Westonbeecroft,

I don't know if this is the problem

since you're using a VolatileImage object, the data stored may disappear since it is "volatile" in nature, maybe you can try to test if the data is still there before displaying (and redraw the graphics when they are lost)

VolatileImage vImg = gc.createVolatileImage (800, 600);

if (!vImg.contentsLost) {

Graphics2D g2 = vImg.createGraphics ();

// draw something with g2

g2.dispose ();

} else {

// recreate the VolatileImage and redraw operations (if any)

}

From Jason (Kusanagihk)

kusanagihk at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...
# 8

I actualy considered the fact that it was a VolatileImage to be the problem since it is the only one I am using, but I have actualy tried converting it to a BufferedImage and got the same results. Plus I only have problems with it when I am loading my applet from a jar, I don't think if it was an issue with it being a VolatileImage then the fact that it is in a jar would change anything. If no one as a solution to this, has anyone at least seen something similar to this before?

westonbeecroft at 2007-7-3 18:23:05 > top of Java-index,Other Topics,Java Game Development...