Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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:

1  
2  
3  
4  
5  
6  
7  
8  
Health
- maxHealth int
- currentHealth int

Position
- x float
- y float
- z float


It would create a Health Component that looked like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
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:

1  
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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!