Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 3 [4]
  ignore  |  Print  
  Game Object Component System  (Read 25508 times)
0 Members and 1 Guest are viewing this topic.
Offline DzzD
« Reply #90 - Posted 2009-06-18 11:50:45 »

on the way of loving this design (if I can manage to understand it well ...Smiley) but still lost some times on simple cases :

let's say I plan to have two kind of unit : spiders & ants

I want them to walks and have an apperance so they will both have the "CanBeDisplay" component with the right value for each, but what about the walk ?

I mean they walk are differents : what would be better between one components "CanWalkComponent" that handle differents case and two components "CanWalkAsSpiderComponent" + "CanWalkAsAntComponent" ?

how to decide "the deepness" of the components ? and heu... does that question make sense ?

Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #91 - Posted 2009-06-18 13:25:05 »

on the way of loving this design (if I can manage to understand it well ...Smiley) but still lost some times on simple cases :

let's say I plan to have two kind of unit : spiders & ants

I want them to walks and have an apperance so they will both have the "CanBeDisplay" component with the right value for each, but what about the walk ?

I mean they walk are differents : what would be better between one components "CanWalkComponent" that handle differents case and two components "CanWalkAsSpiderComponent" + "CanWalkAsAntComponent" ?

how to decide "the deepness" of the components ? and heu... does that question make sense ?

You mention a complex example.

You could just have a WalkComponent, and then have it contain all sorts of leg combination and movement of those legs. You can contain all this behaviour within one component.


E.g., my WeaponsComponent has Targeters, WeaponControllers, and Weapons.

Each targeter has a list of weaponControllers, and each weaponController has a list of weapons. Each weapon fires a projectile of a certain type.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline DzzD
« Reply #92 - Posted 2009-06-18 13:34:45 »

Quote
You could just have a WalkComponent, and then have it contain all sorts of leg combination and movement of those legs. You can contain all this behaviour within one component.
thanks, that was also my first thought, maybe easier to maintain

EDIT:
just though that maybe the answer can be found in the data, like if I handle same data (let say speed) than == same component but if I handle each legs states as they have not both the same number => then == different components ?

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

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #93 - Posted 2009-06-18 14:27:09 »

Once upon a time in a kingdom far, far away there was a King who was fed up of having his toast burnt every morning by the cook. So he sent far and wide across his land for subjects who might be able to provide him with decent toast. After months of searching, finally two people turned up in his court - a software engineer and a hardware engineer.

"Tell me your solutions!" spake the King. And the hardware engineer said, "My lord, we could have a toasting device rigged to the mains, which has a dial on the side of it. You wind the clockwork dial which unwinds slowly, and that determines the length of time the bread remains in the toasting device, for when the dial stops, the toast pops up. After a couple of goes we'll figure out the perfect point to set the dial for you and draw a mark on the dial face."

"And what of you?" enquired the King of the software engineer. The software engineer replied, "My lord, instead of a simple clockwork timer, we employ a 4-bit microcontroller, which is programmed by tapping two buttons on the side of the toaster to increase or decrease the shade of toast required between 16 shades. The microcontroller uses a lookup table of millisecond times to determine how long to keep the toast in the toaster. We can program the millisecond timer using a simple Bluetooth interface using TCP/IP to send an XML document containing the millisecond values. Just think, my lord! A different shade of toast for any occasion!"

The king wisely had the software engineer executed, and the land lived happily ever after.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 818
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #94 - Posted 2009-06-18 14:55:42 »

It certainly feels like a system that's totally over engineered, but... maybe we first have to head into a dark world before we see the light?

 persecutioncomplex

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #95 - Posted 2009-06-18 15:04:20 »

It'd largely depend how complex your game is I guess, I think I'm *just* this side of it being overengineering - but were I to start adding in network play or game replays then it'd probably be worth it. On the other hand something like <a href="http://www.bay12games.com/dwarves/">Dwarf Fortress</a> would probably be impossible with a traditional Big Entity Hierarchy.

I have no  idea what actually drives DF internally, but it'd be interesting to find out.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline DzzD
« Reply #96 - Posted 2009-06-18 15:07:20 »

hehe pretty fun Smiley, the story doesn't say if the toasts was good ?

I dont really like stuff as XHTML/W3C/Collada/etc... basically all those new standards that claim they handle about everythings and works better, give a lot of promess, and finally make that your website is only viewable by browser fully CSS12 compliant and not by the most popular browser... and make you wensite missed by 80% users... , but about those ES/components system it seems for me to better match the reality (as far as I understand it  persecutioncomplex )

Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #97 - Posted 2009-06-18 15:17:43 »

You can see what I'm doing already with Galactic Commander:
http://private.is/arni/gcom/

The XML file is getting bigger and objects are more complex:
http://private.is/arni/gcom/gocs.xml

Overall this is going very well.


edit: I'll try to add more complex and different game objects for demonstration purposes.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline tom
« Reply #98 - Posted 2009-06-18 21:12:02 »

Has anyone looked at LINQ in .NET? It seems to be a way to do SQL like queries on datasets that is in memory.

I've rewritten the simulation editor I'm working on to using a component system. I've found that many components are just wrappers for other objects. An example: I have a Text3DComponent that just a wrapper for a Java3D Text3D. The actual data is stored in the Text3D object. The component exposes the data (font, text, size etc) as a list of properties. This list is used for serialisation and in the editor ui. It also has methods to set and get all properties to make it easer to use the component from scripts and other components. But here comes the "dirty" part that I'm uncertain about. Text3DComponent extends a SimulationComponent. It has an attachedToWorld and detachedFromWorld method that are invoked when the component is attached or  detached. Text3DComponent uses those callbacks to attaches its Java3D node to the scenegraph. Is this wrong? Should the Text3D scenegraph object be stored in the component or the system. Shoulde the attaching be done in the system instead?

Offline aazimon
« Reply #99 - Posted 2009-06-18 21:26:22 »

I've been lightly following this line.
Using your walk component. Putting all possible leg movement seems a bit excessive. I would think that you need to have an abstract leg movement class, then have classes that extend that for specific leg movement. Being that a given unit would only have a specific leg movement and you would add the leg movement that you need.
  The abstract class would have the common methods, like walk(), which would be used throughout the game. The only object that should care (per say) the specific movement is the unit.
  Yes you would have a lot of classes for each type of movement, but if you come up with a new movement you just add a new class, not change the existing one.
  I hope I explained that well.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SimonH
« Reply #100 - Posted 2009-06-19 00:59:27 »

I've been following this too...

I would think that you need to have an abstract leg movement class
I'm not sure that's right - it's the old OO thinking!

If I'm getting ES right, the 'old' procedural or OO approach is to think;

'a game is code controlling a set of data'

but the new ES approach is to think;

'a game is a set of data which uses code to change itself'.

The advantages of thinking in this new way are enormous! Everything (including logic code) just becomes a set of UIDs - change 1 int and you can change the behaviour of anything. Better still you can easily and quickly find things that were hard to find before (How many trees are near me?, Which players are running away?). With ES these are just easily optimised database queries.
Game state persistence is built right in! Perfect for distributed apps...
I like this idea! I think we'll see more of ES, especially in more complex games.

People make games and games make people
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #101 - Posted 2009-06-19 08:43:55 »

That wasn't OO thinking, that's attempting to model physical objects in what amounts to a program model - probably where most people fall down with OOP.

OOP is perfectly fine for all of these problems so far described; if you find you need some domain-specific problem solving and you're a Java programmer, consider modelling the ES implementation problem in OOP rather than the direct solution. In other words, use OOP to write an ES, then implement your game using the ES.

Of course if it's that complicated you're probably also using more than three levels of indents, and need spanking.

Cas Smiley

Offline DrunkenLizard

Junior Newbie





« Reply #102 - Posted 2009-06-19 13:23:33 »

ES is a fascinating concept, I like how flexible and maintainable it can be. Especially regarding to the article linked earlier in the thread (http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/).

At the risk of inserting a noob question, can anyone show how (if at all) it could be incorporated in a "game" loop like the following:


while (running)
   {
   // tick something over   
   something.tick();

   // display something to the user   
   render(something);
   }


Would what be the "something" that ticks over here? Would it be a single Entity Container, containing everything that has been set up? This would presumably imply that every entity would have a "tick()" method, or some other similar way of updating itself.

Also on a completely unrelated thought process, would other non game world objects like user interface objects be entities too?
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #103 - Posted 2009-06-19 14:39:33 »

Well, that's exactly how my games work.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 818
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #104 - Posted 2009-06-19 16:53:57 »

Well, that's exactly how my games work.

Cas Smiley

Well, that's kinda obvious Smiley He's asking how to convert that to ES.


Well, you can use a System to iterate over all Entities with Component X.

So each Component is already ticking, so just make a RenderComponent that sends info to the screen.

Due to the System tickrate being independant, you can have your PhysicsComponent tick at 60Hz, and the RenderComponent as fast as possible.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #105 - Posted 2009-06-19 17:25:12 »

Question is: why would you convert a completely simple and intuitive system like that into some newfangled and probably slower and harder to understand system?

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 818
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #106 - Posted 2009-06-19 17:45:03 »

Question is: why would you convert a completely simple and intuitive system like that into some newfangled and probably slower and harder to understand system?

Cas Smiley

That wasn't the question, but your question is a very valid one.

I'm still not convinced this is going to improve your average 'indie' game.

It is fun to play with it however...

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #107 - Posted 2009-06-19 17:57:37 »

I code my games for learning, I've never yet finished one, but I hope I understand something about technology or software engineering each time. Playing with entity systems might be fun, and that's reason enough for me YMMV Smiley

Endolf

Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #108 - Posted 2009-06-21 23:28:26 »

Seems to be functioning, this newfangled and probably slower system  Grin

http://gamadu.com/games/gcom/

Some disgust for princec and other pessimists:
http://gamadu.com/games/gcom/xml/


Of course there is alot of work still to be done, and things aren't exactly like I want them, but what's there is working.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #109 - Posted 2009-06-22 09:14:14 »

It looks absolutely horrible compared to my XML configurations Smiley More Spring hate from me.

Cas Smiley

Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #110 - Posted 2009-06-22 10:17:51 »

It looks absolutely horrible compared to my XML configurations Smiley More Spring hate from me.

Cas Smiley

I admit, they are rather, hm, verbose. I still think it's better than the alternative, to define it all in the code.

Well, at least it's one of the stop towards destination Perfection, although some might think it's a detour.  Grin

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 818
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #111 - Posted 2009-06-22 21:16:36 »

Just compare it with Java sourcecode.
If your whole game is in one class, you're making a (beginners) mistake.
Same thing for XML. Split it, and make references to other XML files.

In the end it's all about managebility.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #112 - Posted 2009-06-22 21:34:12 »

At the risk of inserting a noob question, can anyone show how (if at all) it could be incorporated in a "game" loop like the following:


while (running)
   {
   // tick something over   
   something.tick();

   // display something to the user   
   render(something);
   }



while (running)
   {
   // Let each system tick
   system1.tick( system1components );
   system2.tick( system2components );
...
   // ...or the obvious sensible way to do it instead
   foreach( system in systems )
   {
      Collection entities = getEntitiesForSystem( system );
      system.tick( entities );
   }

   // display something to the user   
   render( getEntitiesForSystem( getRenderableSystem() ) ); // I'm assuming you do animations inside your Renderables system
   }

   public Collection getEntitiesForSystem( ASystem system )
   {
      runSQLqueryToGetAllEntitesMatchingSystem( system.getUniqueName() );
   }


...or something like that. Typed off the top of my head, and trying to convert into java, didnt bother firing up eclipse, so where there are stupid mistakes try to ignore them Smiley

Quote
Also on a completely unrelated thought process, would other non game world objects like user interface objects be entities too?

If you want them to be part of the game, yes.

I would advise start off with them as "not", but you may decide to add them in later. Many games decide to merge UI and game sooner or later.

For instance, lots of games run the renderer in the background of the main menu, showing a simulated bit of game (AI battling it out on one of the game maps, for instance).

For instance, lots of games like to have the UI context-sensitive based on what's happening in-game: if the UI needs to read the state of game objects, and needs possibly to alter the state of game objects directly (e.g. "set the "selected" game unit"), then it's generally going to make life easier if the UI can "speak" directly to the entities.

But ... for the first time, this is hard enough already, I'd probably aim to keep them separate as long as possible, just to keep yourself as un-confused as possible.

malloc will be first against the wall when the revolution comes...
Offline Handyman

Innocent Bystander





« Reply #113 - Posted 2009-09-01 03:00:30 »

I dig this idea but I'm confused about a few things.  The post linked to here from T=Machine mentions that the Flyweight pattern should be used for components (he said this in the context of adding functions to components but since functions are not relevant to Flyweight I assume that he meant the statement to be general).  Right below that it says "all data lives in Components; ALL data"...

So I've got a component for "Position".  It holds my Entities' 3D position.  For it to be flyweight wouldn't make sense since it updates its data to what is basically a random value constantly (creating a bunch of instances!).  Maybe he was mentioning Flyweight as only for cases where its useful?  I would not expect it to be normally useful but I might have confused the whole thing.

I'm also not sure how I could have, say, a Physics component/system, an Animation component/system and a Collision handling component/system and have them coexist safely.  I assume that individual systems need to synchronize with one another but aren't they supposed to be completely distinct?  Or is this an "as distinct as possible -- suffer through the synchronization" kind of deal.  How can three systems (potentially with order dependencies) update/utilize the same entity's position value?

( Is this similar to categories in Objective-C?  Or mix-ins in other languages?  Also see Groovy DOM-Categories : http://groovy.codehaus.org/Groovy+Categories )

Finally, the analogy to RDBMS is spot-on.  I see the entity idea less as declarative-programming than procedural-programming (which undeservedly got a bad name after its popularity faded).  Of course, an OODBMS isn't usually a bad thing either.  If they work for your games needs then switching to db4o or something is smart.  I find it hard to use because of its object activation policy and I don't have serialization bottlenecks so I haven't bothered but if I did I'd switch DBMS in a heartbeat.

- Handyman
Pages: 1 2 3 [4]
  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.

Longarmx (33 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
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!