I am trying to make a java version of the very cool and addictive game Transport Tycoon (Deluxe)
But I am having trouble with the graphics as i dont get a high fps
so I look for ppl who want to help with me with the graphics engine bcz mine isnt so performant
If you would like to help you can post it here or send me a private message
thx alot
PS: if u dont know transport tycoon go to http://openttd.org for some screens and more
Wow! I liked TT very much. I was addicted to it.
What are you comparing your code with when you say your graphics engine isn’t so performant?
Are you using Java2D, or some openGL bindings?
I have really little time nowdays, but maybe I could help with some issues.
cheers!
I am using full-screen exclusive awt mode at the moment but with that comes i have to redraw
my whole screen each frame. It can contain 1000 tiles ( at 1024*768) so this takes so much time
the game is beginning to run really slow and get only 30 fps orso.
as i explained in another topic i tried using xith3d to opengl accelerate it but my images get screwed up
so my map looks so ugly. Java2d gives the best graphical result but it is very slow
I didnt suggest that it was. but is Xith3D really suitable for what hes trying to do? just using ogl on its own would be simpler and probly faster i think.
I run the test.jar and I think Java2D is capable of rendering many more sprites per frame.
There are some important points to note however, so for example to make them hardware accelerated by Java.
Many of these notes have been discuessed in the forum’s 2D threads. I’m pretty sure some Java2D experts read so please: comment. Thanks.
Kevin’s currently moving, so we’ll have to wait for his comments. Still his (?) FAQ is nice and helpful IMO: http://wiki.java.net/bin/view/Games/FAQ#2D_Rendering
Just in case the correct way to use Java2D doesn’t bring the performance you need then I’d go the OpenGL route. However, I can’t imagine you’d need the direct metal OpenGL way to do a isometric simulation.
P.S. Chris Sawyer rules. Together with D. Braben one of the - if not the - brightest minds in the entire video gaming industry. Man, he wrote the entire Rollercoaster Tycoon in Assembler. A real Scottish braveheart.
I have made some small apps with jogl before so i should try and do that then?
For what is worth the following code is used to make a tile texture i did in xith3d (maybe then you why its complety different output):
private Shape3D createTile (Point3f[] coords)
{
return new Shape3D(getGeometry(coords), getAppearance());
}
private Geometry getGeometry(Point3f[] coords)
{
// Define Texture coords for a square shape
TexCoord2f[] texCoords = new TexCoord2f[] {
new TexCoord2f(0f, 0f),
new TexCoord2f(1f, 0f),
new TexCoord2f(1f, 1f),
new TexCoord2f(0f, 1f)
};
QuadArray g = new QuadArray(coords.length, GeometryArray.COORDINATES |
GeometryArray.TEXTURE_COORDINATE_2);
g.setCoordinates(0, coords);
g.setTextureCoordinates(0, 0, texCoords);
return g;
}
private Appearance getAppearance()
{
BufferedImage bi = null;
try {
bi = ImageIO.read( new File( "./Images/tile3.png" ));
}
catch (java.io.IOException ioe) { ioe.printStackTrace(); }
Texture2D texture = (Texture2D)TextureLoader.getInstance().createTexture(bi, false);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setTransparencyMode(transparencyAttributes.BLENDED);
transparencyAttributes.setDstBlendFunction(transparencyAttributes.BLEND_ONE);
transparencyAttributes.setSrcBlendFunction(transparencyAttributes.BLEND_SRC_ALPHA);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setDepthBufferEnable(false);
TextureAttributes textureAttributes = new TextureAttributes();
textureAttributes.setTextureMode(textureAttributes.MODULATE);
textureAttributes.setPerspectiveCorrectionMode(textureAttributes.NICEST);
Appearance texturedAppearance = new Appearance();
texturedAppearance.setTexture(texture);
texturedAppearance.setTextureAttributes(textureAttributes);
texturedAppearance.setRenderingAttributes(renderingAttributes);
texturedAppearance.setTransparencyAttributes(transparencyAttributes);
return texturedAppearance;
}
@ Chris Sawyer rules. Together with D. Braben one of the - if not the - brightest minds in the entire video gaming industry. Man, he wrote the entire Rollercoaster Tycoon in Assembler. A real Scottish braveheart.
TT was completely written in assembler, dont know about rt but it is true he roels
I’ve tested the newer benchmarks and still think it’s somewhat slow, but well, I’m no Java2D expert.
From what I’ve seen from Kevin’s and other’s Java2D examplesI think it should go much faster. Could any Java2D expert please comment?
My own hobby 2d project (a parallax side scroller) is being done in OpenGL (JOGL) with an 1:1 orthogonal view (so no scaling of the bitmap textures) but just because the game’s main task (> 75%) is to move textures around on the screen and the whole point is smoothly moving tons of large sprites.
This won’t be the case for your Tycoon game, where just a small amount of the game’s performance goes into drawing the graphics (25% maybe?).
So I wouldn’t worry too much about graphics speed. Because by the time you finish the other parts of your game in Java you’ll have evaluated a fast and neat way to plot them in Java2D.
And… of course it’s a good idea to encapsulate your internal graphics system so that you can always decide to change the final plotting class(es) of the sprites.
Good luck with your project! There are many Tycoon fans out there.
Btw, I suggest to open another thread on the Java2D sub-forum here: http://www.java-gaming.org/forums/index.php?board=15.0
Not linked to the exact type of the game, but “just” something like: how to do fast isometric plotting with Java2D or such…
Had a look at the source to the first example, and have to say you are doing some things in very peculiar ways.
Your fps counting for starters is totally crazy, and inaccurate.
Creation of your images is odd too (Transparency class)
why not just load the images with ImageIO, and copy them to a BufferedImage [managed] returned from GraphicsConfiguration.createCompatibleImage.
You shouldn’t need to use Toolkit.createImage(ImageProducer) ever.
your VolatileImages class is also fundamentally flawed, and quite useless.
now for something different…
TTD is indeed awesome! My friends and me play OpenTTD almost every evening on the Internet. So I find the idea to port it Java pretty cool and I would be happy to help you concerning the GUI, which makes a pretty big part of TTD. I could provide the in-game window frames, Widgets like tables, text fields, buttons etc.
However, OpenTTD is constantly enhanced and the OpenTTD-Guys drop builds like I change my shorts. Which is why I would like to ask on which version of OpenTTD you rely. And how do you intend to keep up with the enhancements? Or do you just fork from an old version?