We just finished our talk here at Devoxx called “Gaming JavaFX”. The talk was scheduled for Friday morning and we wanted to do something really fun and a bit lighthearted, but also really practical. Earlier this week James Gosling had a talk about the Java Store, and we wanted to provide some momentum to the idea that you can write really fun and interesting games in JavaFX and then load these up into the store.
Jasper posted a preview teaser earlier in the week of our Dude with a bomb. You’ll appreciate watching the talk at Parley’s when they have it posted (or you can pay Parley’s a few quid and see the talk even earlier).
The game we wrote is called “Dueling Dudes”. Its a non-scrolling side shooter, not unlike some other popular games like Scorched Earth or iShoot. Except we decided to replace the tanks and earth with dudes and boxes. We placed it in a warehouse and gave each box & barrel physical properties, and gave our dudes weapons and the ability to bash the terrain around. It was tremendous fun. I once read that every programmer should write a game at least once a year just for fun and to keep that youthful exuberance. I couldn’t agree more.
Technically it was a very pleasant and fun thing to work on as well. Integrating the physics engine was not very much work, and using a scenegraph to model things was very natural. We drove things mostly from the engine and a few well placed binds and a single Timeline which drove the world. Jasper pretty well wrote the whole thing over 3 days. Here was our secret equation for success:
We’ve hosted the game here at FXExperience, hope you enjoy playing it (and if you have troubles on your machine configuration we’d like to know that too!).
Excellent! … and great talk.
Awesome talk ! Finally an interesting one about JFX !
It uses full DualCode CPU power even when idle. It’s terrifying me.
Would you mind sharing some stats? What machine you are running on, if it was using full CPU immediately or if it took a few games to get there, that sort of thing?
Cool demo and talk at the Devoxx, too bad I hadn’t my laptop with me during the JavaFX BOF.
During second( or third) game it took almost 100% of CPU on my Mac 10.6.1
Let me know what data you need to profile it π
I have had the same experience — a few games in and things go real slow. Not sure if this is due to game state (maybe the physics world? Maybe the scenegraph?) not releasing objects. If I had to guess I’d guess it was a problem with the World having objects in it still when a new game is created.
I tried adding a reset function to PhysicalScene that creates a new world.
/** Create new world and repopulate. This does not effect scenegraph */
public function resetWorld():Void {
world = new World(gravity, 100);
for (obj in allPhysicalObjects) world.add(obj.body);
}
Then call this on each new game, that seems to help and the first 5..10 games are fine but after 10..20 or so new games it still seems to get stuck at 100% CPU and be slow. Nothing obvious is showing up in profiler. It will need more digging.
I pressed New Game many times to get a game field that I wanted, and I think each time I pressed New Game it slowed my computer down. It got so slow that I could barely move the mouse to close the window. Once I closed the window the computer ran at normal speed again. It’s an AMD Turion 64 2ghz with 2gb memory, windows vista sp2. JDK 1.6 update 16 (I think)
I restarted the game, and this time played with the game field it provided the first time. It played well, and the physics was cool.
Hey Ryan, thanks for the Report. Jasper and Stephen Chin did some profiling today and it looks like somehow the physics model was leaking really badly. It might have been a listener that we didn’t release or something deeper in the engine, not sure. But it seems if we chuck everything and rebuild everything on New Game the issue goes away. Maybe Jasper will have a new version up tomorrow.
Done, I have uploaded new version with leek fixed I hope. It recreates the physical world and all physical objects on each new game now. Some how it was leaking huge amounts of Vector2f objects, like 300 million after 10 games or so. Now we throw away the complete tree which lets GC clean it all up easily. If we had time to rewrite physics library avoiding all object creation on something that needs to run at 60 times a second seems to make sense.
I’m having the same problem after pressing New Game many many times. Does Java Web Start cache the jars so I did not get the fixed version?
It does seem to cache them, I am not sure how to force them to update. I would have assumed a new file with new timestamp would have done it. I will have to investigate. You can clear the cache in Java Preferences on Mac and Java control panel on windows.
Tried to load the game and got this error:
Java Web Start 1.6.0_13
Using JRE version 1.6.0_13 Java HotSpot(TM) Client VM
User home directory = C:\Users\mdonahue
—————————————————-
…
—————————————————-
java.lang.NoSuchMethodError: com.sun.javafx.runtime.location.SBECL.(ILjava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;Z)V
at game.Game$_SBECL.(Game.fx:195)
at game.Game$_SBECL.(Game.fx:195)
at game.Game.(Game.fx:21)
at game.Main.javafx$run$(Main.fx:17)
Haven’t read any comments so dont know if anyone else has seen this, but thought you’d like to get the report
Fixed, see comment below
The window never opens and I get a “java.lang.NoSuchMethodError: com.sun.javafx.runtime.location.SBECL.init” in the log file (Vista Java 6 update 15)
Sorry I uploaded new Jar and broke things. It was compiled against the wrong JavaFX version. It is now fixed and should work. I had to clear my webstart cache for some annoying reason to get it to pickup the new jar.
awesome π
Hi, is it possible to share also the resources? Like the png’s so i can show it in a presentation to our group of developers….thnks
Hello there!
How about to add some professional graphic into your application? I am graphic designer and find out javafx really cool new technology for me… since long time a have a dream of creating a game like this π