Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  my java world project  (Read 992 times)
0 Members and 1 Guest are viewing this topic.
Offline SwampChicken
« Posted 2008-01-24 02:28:21 »

Hello,

I'm not very articulate but I will try my best to describe what I'm trying to do.

I'm trying to build a world in java, a world where I can work on pieces/objects (by coding on underlying attributes and/or behaviour) and plug them in (at any time) and watch their interactions which each other.

I intend for my movable "objects" to need only the most basic underlying properties like position / speed / health & temperment.
(temperment being the thing I would adjust differently with different object types)

Once created, I don't want to 'stop' the world (ie: recompile etc), but I want the ability to work on new objects at a later date and introduce them when I want. I want to leave my world on always (24/7) and in the meantime, when I code up new 'things' I can introduce them somehow to the world and let them roam free...

I don't want fancy graphics.
No intention for any network stuff or anything like that. (actual intention is more of a personal petri-dish. Wink )
The 'world' can be a simple black jframe/jpanel.
Object will be a represented graphicly by a single moving pixel. (different object types to be different colours)
I want  it to be turn-based, so an engine/heartbeart simply lets each 'object' take it's turn.
I also need some type of textfield or flat-file that logs events... (for when interactions occur when I'm asleep)
Other than the 'world' panel, I need some open-file dialog? or some component as a facility to 'introduce new objects... (or maybe just use a menuitem to a dialog?)

Anyway... that above isn't too hard to figure out...

...which brings me to the crux of my problem:

What I don't understand is how I would design the infrastructure to 'load' new obejcts into my 'world' once the world is running... I don't know how, or even if I can do this??


Offline Noya

Senior Newbie





« Reply #1 - Posted 2008-01-24 13:41:46 »

If I get you right, you want to dynamicly load java-code / classes at runtime? I'm not into that, but I think I can give you some pointers: The java ClassLoader provides methods for loading classes at runtime. After loading a class you use a concept called reflection to access members and methods of the loaded class. I'd suggest to write an interface that all objects implement, so you can load them, cast them to that interface and call the interface-methods to move / place / whatever the object.

If I got you wrong and you just want to load objects with different properties (not behaviour), then you should just write conifg-files for those objects and load these.

What you also could do is to make a regular backup of the complete world state. To introduce new objects you would just save the world-state, recompile and restart your project, and reload the world-state again. Even if you don't want to introduce objects this way, a regular backup is important, as you don't want to loose the evolution of your 24/7 world just because of a bug in the code or something Smiley
Offline SwampChicken
« Reply #2 - Posted 2008-01-30 02:13:13 »

Ok, thanks for the tip Noya.
I will look into some examples on 'Reflection' and try to code something up.
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.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (72 views)
2014-09-10 06:39:09

Tekkerue (37 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (43 views)
2014-09-07 01:13:42

Longarmx (27 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (34 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!