Sprite engine Part III - The source code.

Archived discussions related to Transport Empire. Read-only access only.

Moderator: Transport Empire Moderators

Locked
Monti
Engineer
Engineer
Posts: 26
Joined: 06 Feb 2005 12:49
Location: Dresden

Sprite engine Part III - The source code.

Post by Monti »

Hello, finally here is the source code.

Packages:
ts: The Trainsim with the trains, the background, the landscape, the generator and so on. This is the
package which contains 90% of the game. This package is set under the gpl.
tools: Some tools libraries. Output handling, exception handling,
collections, blob handling... Its set under the monti library licence. The code is free like the gpl, but grants some extra rights to me allowing me to distribute the code.
spreng: The grafix engine. Its also set under the monti library licence.


To compile it, you need to put the genericsCollectionsPatch into your bootclasspath. It change some definitions of the collections-getter to make it more robust to bugs. To compile you have to give the java compiler command
javac -bootclasspath D:\m\home\genericCollectionPatch.zip;c:\Programme\Java\jdk1.5.0\jre\lib\rt.jar
....
I don't know if I should remove this, but it has protect me from many bugs. For the execution you do not need this zip. I hope it works with your IDE, with intelliJ you have to add it as library and move it under order/export before the java libraries.

To look into the rendering engine, please start looking into the class spreng.gfx.Renderer. The easiest renderer to understand is the Java2D-Renderer in the package spreng.gfx.j2d.

To look into the game (like a train is moved, and how the ground is created) look into package ts. Package ts.ice contains all the logic for the four moving trains. Package ts.clouds the movings clouds. The whole logic is bound in ts.TrainSim. The ground and the creation is located in ts.landscape, but I think it lacks on documentation a little bit.
The ground informations are stored in GroundTile, which holds the heights and the types of a 128*128 part. Its swappable. GroundImage represents a texture for the background (green, snow, water, rivers). GroundCache represents a 200*200 pixel background image because most of the background (rivers, trees, water) is precompiled.

Your landscape generator is located in ts.landscape.Generator.

In may opion its absolutely necessary to add
(1) one renderer, or at least the image calculations of the awt-renderer
(2) time messurements methods (java dose not allow milliseconds-exact waits)
into a native library.

The native libraries should be easily portable and should be shipped to other developers or the users in a compiled form (.dll and .so) like a normal resource (like an image). On execution the libraries are extracted as temp file and loaded. So most of the developer do not need a C-IDE.
Attachments
genericCollectionPatch.zip
This is a needed file for compilation.
javac -bootclasspath
D:\m\home\genericCollectionPatch.zip;c:\Programme\Java\jdk1.5.0\jre\lib\rt.jar
(429.37 KiB) Downloaded 115 times
ts.zip
Sourcecode
(1.62 MiB) Downloaded 119 times
Hellfire
Transport Empire Developer
Transport Empire Developer
Posts: 699
Joined: 03 Feb 2003 09:30
Location: Back at the office

Post by Hellfire »

Hmmm... Deja vu. ;)

Anyway. I have been sniffing around through your code. I haven't tried to compile it yet, but that will happen soon enough. :)

Please be patient with me. As all other people working on this project, I have to do every part in my own free time.
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code: Select all

+------------Oo.------+
| Transport Empire -> |
+---------------------+
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
ChrisCF
Transport Empire Developer
Transport Empire Developer
Posts: 3608
Joined: 26 Dec 2002 16:39
Location: Over there --->

Post by ChrisCF »

Hellfire wrote:As all other people working on this project, I have to do every part in my own free time.
Free time? What's that all about, eh? ;)
Hellfire
Transport Empire Developer
Transport Empire Developer
Posts: 699
Joined: 03 Feb 2003 09:30
Location: Back at the office

Status update

Post by Hellfire »

Status update:

I've been playing around with JNI. I managed to make a java program that uses a .dll, compiled with gcc, to display "Hello world" to the user.

I'm going to play around with it a bit more, and then I'll try to adapt some of the source code to use native code for some parts of the engine.
Attachments
JNI.zip
Run with "java HelloWorld". The DLL contains the code to display "Hello World". The Java class contains the "Main" function.
(2.19 KiB) Downloaded 113 times
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code: Select all

+------------Oo.------+
| Transport Empire -> |
+---------------------+
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
Locked

Return to “Transport Empire Development Archive”

Who is online

Users browsing this forum: No registered users and 7 guests