I’ve put together a distribution of my tank action game. Please try it and see if it works (and how well). It’s still very early. I’m using xith3d and lwjgl (so easy to webstart).
On my computer it runs smoothly at 130-200 fps almost always, but it is a new gaming computer. I would like to know how good it runs on an older machine.
Controls:
WS - accelerate and brake.
AD - turn left and right.
F - Flush coolant if a gun is jammed.
Mouse - aim the turret.
M - Link to a sattelite and get a top-down view of what is happening.
Mouse left click - fire primary gun (at the moment, the only gun).
Mouse wheel - zoom (only two levels at the moment).
BACKSPACE - reverse speed.
1 = brake until complete halt.
0 = accelerate to full speed.
Y - invert mouse Y.
ESC - pause and unpause.
Q - Quit when paused.
Drive around and find all the enemies. It you collect credits, you will level up and slowly get a better tank.
Thank you very much, it has been difficult for me to find some examples of games using Xith3D and easily installable with Java Webstart. It works very good, it is quite impressive, I like the tanks.
I have an AMD64, 3400+ with 1.5G RAM and a Radeon x1950pro and your game runs at 60 FPS. At some point the first time, performance degraded to 10 FPS but I have been unable to reproduce this. It seems to have been related to where I was in the map.
I have a technical question: How do you take control of the mouse like that? The cursor disappears and no matter how wildly I move the mouse, your game gets the events. Most of my applications lose track of the mouse as soon as it leaves the window!
Thanks for the info! 60 fps is ok I think. But then again, I want sound, particle effects, pathfinding, collisions and more AI. I will experiment with lower quality of all my bitmaps.
I am not responsible for forcing the mouse cursor to stay inside the game, since I am using the engine Xith3d (http://www.xith3d.org/). But I know how to do it in a 2D app. Take a look at the Robot class. It has methods for moving the mouse cursor back into the middle of the window.
pretty nice for a tech demo. Here’s a couple of observations:
the controls work very well for me. the mouse could be a bit more sensitive for my taste but then again i’m controlling a tank
i forced vsynch off via my nvidia drivers and get between 90 - 127 fps on a geforce 6600gt, 2gb ram, amd athlon 3500+, jre 1.6_0.10. The performance seems to be highly dependent on the number of trees in view so there might be some glitch in your tree rendering code.
i was also watching cpu usage and memory allocations. it uses 100% of my single core machine which is fine, it’s a graphics intensive game after all. However, after playing for around 10 minutes i was up to 220mb ram. It startet at 150mb. I don’t see why it should take up that more ram as the 3d models stay the same, the terrain seems to be paged ( and i didn’t really explore the map that much ). So my guess is that you load the same textures over and over again for all the tanks and trees and don’t reuse them.
the skydome seems to have some problems screenshot
overall it felt good shooting at the other tanks, and the falling trees gave it a nice touch ( even though that seems more like interpolating their rotation angle than true physics ).
It still can be the terrain code, since the deallocation of pages is buggy (read: more or less unimplemented ;)) So if you circle around the same terrain pages forever you’ll get an infinite memory consumption :persecutioncomplex: I will fix it once I get hold of some motivation to work on this again
the launch went well on my ACER Aspire 7730G (Dual-core 2.5GHZ CPU, 3GB RAM, NVIDIA GeForce 9600M GT graphics card) using both Ubuntu 8.10 and Windows Vista Home Premium.
In Vista: At first frame rate was ~60 FPS but after 5 minutes, it went down to 6 FPS and was unplayable.
I liked the idea and implementation, and it was fun although I felt the mouse control too unresponsive when circling my opponents.
Can you provide some details on your terrain generation and culture distribution (trees, stones et al)?
About the controls: Each tank have a turretTurnSpeed. Some tanks have slower turrets and some have faster. This needs to be balanced. It’s not good yet.
About the fps: Ahh… vsync blush thanks… I forgot about that.
About the trees: I don’t see it as a bug, more geometry to render takes more time… ?? Sure, they are super simple, but there are many of them. I hope to replace them with something even more simple when viewed further away and something more detailed closer up. But they work pretty good on a medium distance, especially in groups. And you are right, I only rotate them around either X or Z when they fall, untill they reach PI/2. Since there are so many of them, I keep the code as simple as possible.
About the sky: yep, I know…
About the memory allocation: Hmm, I haden’t noticed that myself. Since this is a very early release (and my first 3d game) I haven’t worked to much on optimization and pooling the little points and vectors and stuff. But the GC should take care of them. It’s probably as Cylab says.
I have Vista home myself, and I have played the game for 30 minutes, so this is strange. If you have any idea if any special behaviour by you caused this, please let me know.
About the mouse control: Different tanks have different turretTurnSpeed. But this needs to be balanced.
About the trees:
As you can see, there are two tree models, the spruce and the… errhhm “tree”. I just have a list of points where a tree should be planted. The Y rotation angle is randem, as is the scale (from 0.7 to 1.3 I think). Each tree have it’s XZ coordinates divided by 50 into integers. All trees with the same such coordinates (divided by 50) are placed in the same group. This makes it fast to check if they are visible and if a bullet comes near or if a tank drives through them.
About the little stones and plants:
I have 400 such objects (randomly selected from 6 different models), placed in a grid. Each item is randomly placed in it’s square (10x10m). So all squares are together 200x200 meters with the player in the middle. Each frame, I check 4 of these objects. If they are more than 100 meters away from the player along X or Z, they are moved exactly 100 meters in that direction. So the field of random decoration follows the player. After 100 frames (about 1 second) all of them are updated. This works unless the player moves very fast. If you zoom in (mousewheel), you can see these objects moving, not very pretty.
The terrain is pure L3DT, made by a program (http://www.bundysoft.com/L3DT/) and loaded by Cylabs code. Nothing I can take credit for.
Very nice work. You even provide a way to invert the y-mouse-axis :).
Maybe I can give you a quick way to improve performance. Since you only have two different tree models you should use shared copies of the same geometry and appearance. Maybe you already do this. And you should use DisplayLists for these static models.
[quote]java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Error: Pixel format not accelerated
at org.xith3d.render.lwjgl.CanvasPeerImplNative.(CanvasPeerImplNative.java:205)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.xith3d.render.Canvas3DFactory.create(Canvas3DFactory.java:124)
at org.xith3d.render.Canvas3DFactory.create(Canvas3DFactory.java:158)
at org.xith3d.render.Canvas3DFactory.create(Canvas3DFactory.java:172)
at org.xith3d.render.Canvas3DFactory.create(Canvas3DFactory.java:268)
at org.xith3d.render.Canvas3DFactory.create(Canvas3DFactory.java:456)
at org.xith3d.render.Canvas3DFactory.createWindowed(Canvas3DFactory.java:750)
at org.xith3d.render.Canvas3DFactory.createWindowed(Canvas3DFactory.java:808)
at org.xith3d.render.Canvas3DFactory.createWindowed(Canvas3DFactory.java:835)
at borb.iron.Game.(Unknown Source)
at borb.iron.Game.main(Unknown Source)
… 9 more
Caused by: org.lwjgl.LWJGLException: Pixel format not accelerated
at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)
at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)
at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:174)
at org.lwjgl.opengl.Display.createWindow(Display.java:308)
at org.lwjgl.opengl.Display.create(Display.java:816)
at org.lwjgl.opengl.Display.create(Display.java:744)
at org.xith3d.render.lwjgl.CanvasPeerImplNative.(CanvasPeerImplNative.java:184)
… 23 more
[/quote]
Not running for me.
Java 6 build 12
Thanks! I hope that I will have some solutions to all your problems soon.
An easy mode where all enemies are scaled to 200%.
An options menu (or at least different jnlp-files) for selecting a lower resolution.
And a lower-res resources-jar. This should speed things up (I imagine).
Most tanks (except for the small APC) consists of two textures of 512*512 pixels.