Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
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 2866 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel

Medals: 57
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?

[ - 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 :

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

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.

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: 57
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 )

[ - 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.

Coldstream24 (18 views)
2015-09-03 00:41:28

Andrew_3ds (30 views)
2015-09-01 19:08:10

afikri (20 views)
2015-08-31 09:30:22

afikri (27 views)
2015-08-31 09:30:07

afikri (15 views)
2015-08-31 09:27:24

afikri (17 views)
2015-08-31 09:26:40

Roquen (32 views)
2015-08-29 11:30:54

GamerC4 (39 views)
2015-08-22 20:38:50

GamerC4 (37 views)
2015-08-22 20:37:18

GamerC4 (43 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 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!