Submarine-Game

Hi

This is one of my first games. There are still some errors in it.

You have to shoot the ships at the top. The other ships are shooting back.
Ships with red crosses cannot be destroyed. If you crash them, you will die. You shouldn’t touch any ship at all, because you will lose a live if you do that.
The green bar shows your oxygen. If it gets low you have to go up to the water level and refill your oxygen.
The gray submarine, which is coming, when you don’t have any ammo, gives you ammo and oxygen.

play the game

kuhnibert

I get this error when I click on the link.

com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://smo029.intern.smo.de/~kdo/UBoot.jnlp
	at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
	at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
	at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
	at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
	at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
	at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
	at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
	at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
	at com.sun.javaws.Launcher.launch(Unknown Source)
	at com.sun.javaws.Main.launchApp(Unknown Source)
	at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
	at com.sun.javaws.Main$1.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

I’ve downloaded the JAR. It is fine. But I get this:

Exception in thread “AWT-EventQueue-0” java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at uboot.GamePanel.paintComponent(GamePanel.java:154)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5122)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent._paintImmediately(JComponent.java:5070)
at javax.swing.JComponent.paintImmediately(JComponent.java:4880)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:723)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

I’m trying to find why the JNLP file is wrong.

There is an error in the JNLP file. The codebase is not the good one :-\

Yes. It is:

instead of:

When it is fixed, would you like me to add your game on the Java Game Tome?

Hi

It’s fixed.

What is the Java Game Tome?

kuhnibert

The Java Game Tome is a website that tries to bring together all the games written in Java (except those that are not cross-platform): www.javagametome.com
Your game passed successfully the main part of the JGTPAT, I only need to know if it works under Mac. If you agree with me, I will add it as soon as possible.

It works fine in there :wink:

Works here, fun for a bit too. Needs explosions. After a ran out of ammo I was kinda lost as to what to do to get back in the game also?

Kev

Hi

If you run out of ammo, you have to look for the gray submarine. It appears at the left edge.

After dying there’s no possibility to get back to the game. I will fix it soon.
Currently you have to restart the game.

kuhnibert

Hi

I updated the game. There are no explosions now, but it should be possible to get back in the game after dying.

the game

A screenshot

kuhnibert

Your game has been added into the Tome but please fix it:

Exception in thread “AWT-EventQueue-0” java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at uboot.GamePanel.paintComponent(GamePanel.java:154)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5122)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent._paintImmediately(JComponent.java:5070)
at javax.swing.JComponent.paintImmediately(JComponent.java:4880)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:723)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

It happens when you keep pressed the S button.

Hi

I will try to fix it as fast as possible, but I don’t have to much time currently.

kuhnibert

Ok. I think that you’re using an iterator and you’re calling remove() more than once, maybe this is the root cause of the bug. You can avoid it by adding all the objects that should be removed into a list and by calling removeAll(list) after your loop.

screenshot(s)?

Swampchicken he posted a sshot here: http://www.familie-ost.info/~wg/Java/ubootshot.png
Bugs I found was that oxygen goes down even if you haven’t started the game yet and that I got -1 ammo.
Can take ages for gray submarine to show up. It’s a nice little game but too repetitive for me.

I tried out your game.

It ran fine here. I liked the graphics.
It is good for a first game!

It would be cooler with some sound effects, animated submarines, torpedoes and some explosions.

Crashed on me after about 10-15 seconds.

Using WinXp, core 2 duo processor, java 1.6

Exception in thread “Thread-7” java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at uboot.GamePanel.doLogic(GamePanel.java:260)
at uboot.GamePanel.run(GamePanel.java:115)
at java.lang.Thread.run(Unknown Source)

Cool game, nice and simple. It’s got a lot of potential to expand on too.

Very good for a first game, especially for having collision detection, sprites and smooth movement.

After about 3 minutes I got this error:

It probably happens because you’re changing an ArrayList on the AWT event thread (which the method keyPressed(KeyEvent e) runs on) while that list is being drawn or modified by your game loop thread. What you need to do is have a list which stores events that the AWT event thread puts events in, and the game loop thread takes them out, with both threads synchronizing on the list so there’s no problems.

PS: if you test your game on a single-core computer, you may not see this error as often as on a dual-core computer since it’s related to threading. Thsi computer I’m using is dual-core, winXP, java 6 update 10.

Exception in thread “AWT-EventQueue-0” java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at uboot.GamePanel.paintComponent(GamePanel.java:154)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread “AWT-EventQueue-0” java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at uboot.GamePanel.paintComponent(GamePanel.java:154)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread “Thread-11” java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at uboot.GamePanel.doLogic(GamePanel.java:260)
at uboot.GamePanel.run(GamePanel.java:115)
at java.lang.Thread.run(Unknown Source)

Hi

About the Error:

I fixed it, just have to upload the file.

kuhnibert