Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Dynamic class loading  (Read 2514 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2003-02-15 12:25:59 »

I honestly have no idea where this topic belongs Embarrassed but by an extremly tenuous link i', placing it here Tongue

I'm experimenting with dynamic class loading for game objects to avoid having to hard-code all the classes etc. and get the main core of the engine nicely abstracted from the game-specific stuff. So the idea is that i have a couple of base classes (DynamicObject and SpawnPoint) which are used as the interface, and things like player character, bullets, opponents extend from this. Then each one has a corresponding SpawnPoint which is used in the editor for setting position, properties etc.
The idea being that I should be able to write an extra pair of classes, drop the .class files into the correct directory, and have the editor load and use them without any modification Smiley

Has anyone round here tried anything similar? It seems like it should work quite nicely, but I wonder if people had used different methods to solve a similar problem?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Chman

Junior Devvie




Nothing more that... Java games are cool !


« Reply #1 - Posted 2003-02-15 12:40:19 »

I use this system in the game i'm currently programming. It's like a "mod" system (like Half-life, quake 3 etc...). Whan the game is launched, it lists all directories an class file in these directories, then it loads class it needs. To load a class dynamicly, use a ClassLoader :

1  
2  
ClassLoader loader = this.getClass().getClassLoader();
Player player = (Player)loader.loadClass(classPath).newInstance();


where classPath is the class filename & location.

I don't know if i've correctly answered your question...

++
Chman
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #2 - Posted 2003-02-15 12:45:53 »

Well I've never used dynamic class loading for game entities before, but for loads of other stuff. It really gives a great deal of flexibility, but at the cost of performance (mo interfaces/objects).

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gregorypierce

Senior Devvie




I come upon thee like the blue screen of death....


« Reply #3 - Posted 2003-02-15 14:02:02 »

Maton, how much performance loss had you been seeing? I dynamic bind juat about everything (just about all of my configuration is in an XML file) through ObjectFactories and store everything in WeakObjectCaches and hadn't been able to measure the class load process during benchmarking. My applications spends most of its time in native code drawing.


http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #4 - Posted 2003-02-15 15:34:21 »

The biggest problem I've had was the fact that much of what we did was interface based, such that our applications could be reused on other platforms (desktop, handheld and so forth), which meant that we had an awfull lot of interfaces, which took up a considerable size. I have no numbers for you regarding speed issues. But I don't think that it will be that big a problem since hotspot should take care of inheritance issues. You could however mark the entities as final.

Having the configuration and such being really dynamic, shouldn't cause any problems - the problem only comes when you have classes which are used in the rendering loop, but you'll have to benchmark that to see if there is any loss of cycles - I doubt that it is noticable...

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2003-02-15 16:15:26 »

I was idlely wondering about speed issues, but since most (all?) of the dynamic loading should be done on level loading it shouldn't be a problem hopefully.

On the other hand, it will happen quite alot in the level editor, and thats starting to chug slightly on large levels already Shocked Although thats probably my lazy rendering methods at the moment (almost everything in immediate mode Embarrassed )

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (33 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (65 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!