I read the site quite regularly but don’t post that much. I thought I’d post link to the project I’ve been working on, since recently it’s started to take shape.
It’s an open source game inspired by the old game railroad tycoon.
It is beginning to get playable; although at this stage one could still say it’s a poor parody of the original
I’ve used swing and active rendering and it runs in full-screen and windowed mode.
I got 9 FPS on Win XP/Athlon XP 2000+ (1,6Ghz)/GeForce256 SDR.
After building a track, two stations and a trains it dropped to 4.
Even the rates are not very good I think you are doing a good job. It is always a pleasure to see remakes of classical computer games (especially good old Amiga games!) on the Java plattform.
New features:
Better train schedule dialogue box.
You can start several client windows (the first step to becoming multiplayer).
Option to run in fullscreen and select the display mode.
I’m still not sure what’s causing the poor performance on some machines.
I tested the new version and its frame rate did not change in windowed mode. In fullscreen mode I have now around 11 FPS.
strange: after letting the game a few minutes alone the rate dropped to 1 frame per second.
Its a riddle to me why my system performs so bad. Do you know the JADE library? (http://jade.pautrot.com)
It is meant for fast 2d games and may be an option to you. It is written in pure java and performs very well. The only drawback: its documentation and tutorials are written in french
How do you paint the map? Do you repaint the whole map, or only the part that is visible? I think that’s the first point i would look at. Or you could look at http://j2da.sf.net and rip the OpenGL part out of it
Only the exposed part is painted and the background is painted to a buffer, which is then drawn to the screen. I’m getting ~70FPS at 1024*768 * 16bit on a P4 1.6Ghz in windowed mode. I might look at an alternative to java2d at some stage, but I’d rather concentrate on playability first.
I only spent about 5 minutes playing with it, and I’m pretty tired at the moment, so take this with a pinch of salt… I think you ought to be aiming for 0 fps most of the time, unless there are animations on screen: you have a game that doesn’t need to repaint the screen a lot of the time! Even with animations, only the animation needs painting, so you should expect fps = 0 unless the mouse moves over the main panel, and even then you should get whatever speed j2d is blitting your cached buffer at (very fast) assuming no complex computations going on in the background.
On my 1ghz machine I’m getting 19 fps if I leave the window at normal size. If i maximize it (1400x1050) then FPS drops to 9 - this is with nothing happneing on screen! In that situation, you shouldn’t be re-rendering at all; just wait until something changes. The big drop suggests that it’s being limited by your rendering rather than game logic.
One thing you might want to try is not using a gigantic scroll pane for the main window; there are things in swing to optimize such huge scrollpanes, but IIRC they are quite tricky to get right. You ould try replacing it with a fixed-size window (just for testing), with buttons that scroll one square left/right/up/down you might find an interesting difference in performance - in which case, you know you aren’t using the scrollpane “properly” for your gigantic area, and you can keep fine-tuning it until you get the same speed when using the scrollpane.
PS it looks good already, looking forward to more updates
I have updated the game I am working on, freerails. There have been many changes since I last posted a link here. The one I am most pleased with is the new track build system that uses A* pathfinding.
if you’re clicking and dragging in the main pane, how bout letting that scroll the screen if your mouse moves past the edge? Like, I knew a city was down and right off the screen, so I clicked from the city I could see and I wanted to drag the track down to it, but it wouldn’t let me because the screen didn’t scroll as I was dragging the track down.