Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (686)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Generating Java code from text config files on: 2011-08-06 19:33:12
Thanks for the discussion. I think for things like map data or mission editor data I will use something like either JSON or XML (probably JSON). This is slightly different in that the intent is to allow the programmer to define the Components themselves outside of code. So it isn't about loading data into existing objects so much as defining the objects themselves.

One thing I (stupidly) forgot was that the code wouldn't even compile if it used objects that did not exist until run time. Another option would be to have the program read the text file, generate Java code, and compile it to a jar file that is then imported into the game. The question is, is it worth it?

On the plus side, rather than writing n class files, one for each component, I would only have a single file to deal with. And I could automate the jar generation to make it easy to incorporate when I've made changes I want pushed to the game.

On the down side, it is seems like I may be getting snared in a weaker version of the game engine trap.
2  Game Development / Newbie & Debugging Questions / Generating Java code from text config files on: 2011-08-06 16:23:18
I'd like to know how to turn text config files into Java code.

I am working on a game and am using an Entity/Component approach where the Components are simply data containers (no processing logic). Given that they are so simple, I would like to be able to specify them in a text file and then convert them to classes.

For instance, if my text file looked like this:

- maxHealth int
- currentHealth int

- x float
- y float
- z float

It would create a Health Component that looked like this:
import framework.*;

class Health extends Component {

   public final int maxHealth;
   public final int currentHealth;

   public Health(Entity entity, int maxHealth, int currentHealth) {
       this.entity = entity;
       this.maxHealth = maxHealth;
       this. currentHeath = currentHealth;


It would also create an Enum of component ids for each component. This will make it easier to add new components later.

Converting the text file into something that looks like java code is not difficult, but I am not sure how to get the class instantiated along with the everything else. I have the feeling that involves using the Class Loader but while I have looked up some information on class loaders, I am a bit stuck as where to begin.

Both for the sake of performance and programming convenience, I want these to be actual classes not hashmap based properties. I don't want to end up writing code that looks like:

int a = (Integer)entity.getComponent("health").getProperty("currentHealth");

Any help would be greatly appreciated.

3  Games Center / Archived Projects / Re: Procedural 2d Space Ships on: 2011-07-30 18:12:04
Ships look really good and also look good together as if they were constructed by the same species. Do you have plans to implement other algorithms to simulate ships by other species so they don't all look the same? For instance some ships with a less organic/more angular appearance?
Pages: [1]
Dwinin (69 views)
2015-11-07 13:29:08

Rems19 (78 views)
2015-10-31 01:36:56

Rems19 (71 views)
2015-10-31 01:32:37

williamwoles (105 views)
2015-10-23 10:42:59

williamwoles (92 views)
2015-10-23 10:42:45

Jervac_ (106 views)
2015-10-18 23:29:12

DarkCart (133 views)
2015-10-16 00:58:11

KaiHH (116 views)
2015-10-11 14:10:14

KaiHH (155 views)
2015-10-11 13:26:18

BurntPizza (168 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!