Slick Forums

Discuss the Slick 2D Library
It is currently Wed May 22, 2013 3:20 pm

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 420 posts ]  Go to page Previous  1 ... 23, 24, 25, 26, 27, 28  Next
Author Message
PostPosted: Tue Jun 26, 2012 6:25 pm 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
Try removing the Gravity component from your entity then try to process it in your GravitySystem and you will notice that your Entity isn't affected by Gravity (+godlike).


Top
 Profile  
 
PostPosted: Tue Jun 26, 2012 10:09 pm 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
Ok, but look at this: first I write a constructor like this:
Code:
public GravitySystem() {
   super(Gravity.class, Position.class, Speed.class);
}

then I write it not passing the Gravity.class parameter:
Code:
public GravitySystem() {
   super(Position.class, Speed.class);
}

and nothing seems to change, so I was wondering why do I have to pass to the super(..) the Gravity argument? And in particular which arguments (components) do I have to pass? For example, do I have to pass the Position and Velocity component (which are modified within the system, beacuse affected by gravity of course) as well? What changes if I don't pass them?


Top
 Profile  
 
PostPosted: Thu Jun 28, 2012 3:03 am 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
Are you adding the GravitySystem to the world's SystemManager and calling InitializeAll() ?


Top
 Profile  
 
PostPosted: Thu Jun 28, 2012 9:49 am 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
Yeah, I think that if I didn't add those things the system wouldn't work. The point is, it works well, but it works also without passing the Gravity.calss, and so I can't understand why I have to pass those arguments...


Top
 Profile  
 
PostPosted: Thu Jun 28, 2012 10:35 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Alessandro wrote:
Yeah, I think that if I didn't add those things the system wouldn't work. The point is, it works well, but it works also without passing the Gravity.calss, and so I can't understand why I have to pass those arguments...

Position+Speed is a "super-aspect" of Position+Speed+Gravity.

If you were to make a "PositionSystem" that only processes Position, then it surely would process all entities having Position, even entities having Speed or Gravity or both.

GravitySystem should process Position+Speed+Gravity only. If you were to remove Gravity from a entity it would no longer be processed by GravitySystem.


Top
 Profile  
 
PostPosted: Thu Jun 28, 2012 11:12 am 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
Oh, ok, I think it's all clear now, but let me see if I understood: if I pass Position + Speed + Gravity as parameters, the system will only process entities which have ALL of this components, so if i pass only Position + Speed it will process also entities that have Gravity, but not entities that don't have Position or Speed. Is it right? Thank you for your patience :)


Top
 Profile  
 
PostPosted: Thu Jun 28, 2012 12:09 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Alessandro wrote:
Oh, ok, I think it's all clear now, but let me see if I understood: if I pass Position + Speed + Gravity as parameters, the system will only process entities which have ALL of this components, so if i pass only Position + Speed it will process also entities that have Gravity, but not entities that don't have Position or Speed. Is it right? Thank you for your patience :)

Correct.


Top
 Profile  
 
PostPosted: Thu Jun 28, 2012 12:13 pm 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
Ok, now it's all clear :) thank you very much, and again great work with this entity framework, I'm really having fun using it!


Top
 Profile  
 
PostPosted: Sat Jun 30, 2012 12:33 am 
Offline

Joined: Sat Jun 30, 2012 12:28 am
Posts: 1
First post here, and this question may have already been asked, but is there any way to have Component inheritance be compatible with Systems?

e.g.
Code:
public class AnimationSystem extends EntityProcessingSystem{
    public AnimationSystem() {
        super(AnimationComponent.class);
    }
}


Is there any way to have this system process entities that have Components that extend AnimationComponent, for example, KeyframedAnimationComponent or TweenAnimationComponent?

Thanks! :D


Top
 Profile  
 
PostPosted: Mon Jul 09, 2012 2:27 pm 
Offline

Joined: Sat Jun 23, 2012 4:14 pm
Posts: 74
Location: Germany
appel wrote:
Click here for demo game, code and jars for everything:
Game demo: http://gamadu.com/games/starwarrior/
Artemis here: http://gamadu.com/artemis/

We're looking for feedback, so please provide if you can.

Any questions? Please ask here.


Are you (appel) and Spiegel still developing Artemis, because the last and only commit is from May 10, 2012?


Top
 Profile  
 
PostPosted: Wed Jul 11, 2012 3:31 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
snapy666 wrote:
appel wrote:
Click here for demo game, code and jars for everything:
Game demo: http://gamadu.com/games/starwarrior/
Artemis here: http://gamadu.com/artemis/

We're looking for feedback, so please provide if you can.

Any questions? Please ask here.


Are you (appel) and Spiegel still developing Artemis, because the last and only commit is from May 10, 2012?


Well, we developed it to implement the idea of entity systems. Really a proof-of-concept project. Where to go from there, I'm not sure. I'd probably redesign the whole thing, and add some more game engine stuff. But part of the success of Artemis is because of its simplicity and being clean, not being more than it is. So, if you have ideas I'd welcome them :)

Bug is, I'm not doing much game programming these days, so my interested has dwindled a little, but you never know when it's rekindled.


Top
 Profile  
 
PostPosted: Fri Jul 13, 2012 10:13 pm 
Offline

Joined: Fri Jul 13, 2012 9:59 pm
Posts: 25
Hello,

I'm using Artemis for a while, but I'm not experienced with an Entity Framework, so I've run into a problem.

My entity has a StatusComponent, that has CurrentHP and MaxHP. This component is used by some systems.

Now I'm creating a System to show a health bar above each unit. But the problem is that not every entity that has a StatusComponent should have a health bar above it. I don't know how to overcome this problem. I thought of some solutions:

- Add another component just to act as a flag for this system.
- Whenever an unit is added, check if the unit should have a health bar. If not, remove it.

I'm pretty sure the second approach is not recommended, as I would have to expose the private API for the EntitySystem class, but the first approach sems as bad as the second to me.

Brainstorm:
For the first solution, the component that should be created could be called UnitComponent and I could actually add more things in the future for that component.


Top
 Profile  
 
PostPosted: Fri Jul 13, 2012 11:44 pm 
Offline
Regular
User avatar

Joined: Tue Apr 07, 2009 12:58 pm
Posts: 232
Location: Uruguay
I believe adding a new component as flag is a correct solution, you could also add a flag in your current StatusComponent to say if you want to render a health bar or not but that means you have to check that all the time in your system process(e) to know if you have to render or not, while adding a new component as flag will make the system to avoid entities without the component and hence only render the correct ones.

_________________
Image


Top
 Profile  
 
PostPosted: Sat Jul 14, 2012 10:24 am 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
I'd also use the first solution, simple and fast to implement :)


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 4:58 am 
Offline

Joined: Fri Jul 13, 2012 9:59 pm
Posts: 25
Ok I have decided to stay with that solution, thank you for that ^^ It's going to be a nice solution, as I'm going to need that component for identifying other things Unit-only related.

Now, I'm building my 7th system, and that's actually a behavior (wich I think that suits like a glove). It's an AutoAttack system, that whenever an unit A get's in range of another unit B, if unit A has an AttackComponent and B has an ArmorComponent, then A will attack B. The problem is that I don't know a way to do this. I can't separate in two different collections the units that have Attack and units that have Armor. I've came up with one solution:

- I create two systems, one called AttackSystem, and the other is ArmorStackerSystem (or some name like that).
- In the ArmorStackerSystem processEntities(ImmutableBag<Entity), I could save that variable and export it with a getter method (like getArmoredUnits).
- In the AttackSystem, I'd call the SystemManager, get the ArmorStackerSystem, get the ArmoredUnits and then I could iterate, checking who is in range of who.

But I'm thinking that this could be a bad design, since I'm new to an entity/component way of thinking. Because one of the things I'd like to have is that, if it's an unit (has UnitComponent), it must have an ArmorComponent, but it may or may not have AttackComponent.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 420 posts ]  Go to page Previous  1 ... 23, 24, 25, 26, 27, 28  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group