TBS

This a continuation of the thread found here: http://www.java-gaming.org/topics/applet-to-application/25794/view.html

Simple turned based strategy game, still in development. My goal at the moment is to finish getting the UI sorted out. I’d like the info/dashboard thing at the bottom to be an independent window of the game screen. The would allow the player the ability the scroll around the game screen, which would also allow for any sized map, regardless of the user’s screen size.

So if anyone has any ideas on how to implement this, I’m open to suggestions. I don’t know much about java graphics aside from applets.

Game .jar file updated 2/23/12:
http://www.mediafire.com/?i6mid44e31i3x1m

Editor .jar file updated 2/23/12
http://www.mediafire.com/?ucpwfwukq20a1jc

Editor Controls:


-Click on tile to cycle through terrain types
-Press key of first letter of tile type to fill map(ex, p, f, l, m)
-Space bar to change to base editing mode, allows you to place bases on first and last columns
-Right click to export map (need the 2 bases before you can export)

Good job making a game. Your on your way.

You might use some tools to make your games and get an artist to work with you.

Unity and UDK come to mind if you really want to make games and don’t care about the tools.

If tools is what you really like making with then you need to work many years molding open projects into a tool.

How do you end turn?

Either press “End Turn” or hit your space bar.

I’ve also updated the JAR. Why is it that JFrame size and Applet size do not end up being equal?

So obviously this won’t work since I’m no longer working in an applet:


tank_fire = getAudioClip(getCodeBase(), "tank_fire.wav");
tank_destroyed = getAudioClip(getCodeBase(), "tank_destroyed.wav");

But neither does this:


tank_fire = getAudioClip(Main.class.getClassLoader().getResource("tank_fire.wav"));
tank_destroyed = getAudioClip(Main.class.getClassLoader().getResource("tank_destroyed.wav"));	

I have used System.out.println() to confirm that the code is pointed to the correct file, yet I keep getting a null pointer exception.

Any ideas?

If you use getClassLoader().getResource(), your paths are always from the root of your classpath, i.e. at the root of any dirs in your classpath or at the root of one of your jars. Where are your wav files located now?

Use Class.getResource(String) for paths relative to that Class. Use Class.getClassLoader().getResource(String) for paths relative to the root of the classpath.

No, just use Class.getResource("/absolute/path/to/resource") to get paths relative to the root of the classpath. One API is much more convenient when you start putting resource paths in properties files and don’t have to remember which resource loader method you used.

Is there a reason Java sucks at handling sound files? I have a copy of the sound files in my source folder, in their own source folder, in the package the class is in, and in the general project folder. Yet neither method of retrieving them works.
??? ??? ???


System.out.println(Main.class.getResource("tank_fire.wav"));
System.out.println(Main.class.getClassLoader().getResource("tank_fire.wav"));

//tank_fire = getAudioClip(Main.class.getResource("tank_fire.wav"));
tank_fire = getAudioClip(Main.class.getClassLoader().getResource("tank_fire.wav"));
//both give the same error


file:/H:/Eclipse%20Workspace/TBS/bin/com/rolledback/game/tank_fire.wav
file:/H:/Eclipse%20Workspace/TBS/bin/tank_fire.wav
java.lang.NullPointerException
	at java.applet.Applet.getAppletContext(Unknown Source)
	at java.applet.Applet.getAudioClip(Unknown Source)
	at com.rolledback.game.Main.declareImages(Main.java:102)
	at com.rolledback.game.Main.init(Main.java:62)
	at com.rolledback.game.Game_Frame.main(Game_Frame.java:18)

That’s because there is no AppletContext if you are adding it to the JFrame. Use the static “newAudioClip” method instead.

You so smart! ;D

;D

Well I’m pretty much done with this project. Was a nice way to learn tile map system, packages, image/sound handling, writing custom algorithms, etc. The final jar’s for both the game and the editor have been uploaded, links can be found in the original post. And you now have the option of using a custom map seed, so the editor actually has a purpose now. I’ll only make changes if bugs are found or if I feel like adding something.

If anyone would like to have the source code, for whatever reason, I’ll upload it. Just make sure you give credit where due. :slight_smile:

Thanks for all the help on the final touches. I’ll be starting a new project soon.