Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 7:03 am

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 ... 20, 21, 22, 23, 24, 25, 26 ... 28  Next
Author Message
PostPosted: Wed Feb 01, 2012 3:01 am 
Offline

Joined: Wed Feb 01, 2012 2:56 am
Posts: 4
Hi,

I'm looking for some assistance on a problem that I'm trying to solve. I've been looking at the code and the example (starwarrior game) and it appears that the spatials are where you setup the visual component for an entity, however they only contain one graphic or visual representation. How would you implement an animation system based on state? (i.e. Walking, turning, attacking, death, etc...). Should the visual representations and the state be contained within the spatial or components/systems? To make it more confusing, some enemies may have an attacking state and others might not, any ideas on how to implement this within the framework?

thanks,


Top
 Profile  
 
PostPosted: Wed Feb 01, 2012 10:18 pm 
Offline

Joined: Wed Feb 01, 2012 2:56 am
Posts: 4
is this forum still active?


Top
 Profile  
 
PostPosted: Thu Feb 02, 2012 1:34 am 
Offline
Regular
User avatar

Joined: Tue Apr 07, 2009 12:58 pm
Posts: 232
Location: Uruguay
In our case, we have an AnimationComponent with multiple Animations and each Animation is a collection of Sprite. Then, for each specific kind of entity (for example for the super mario character) we have one or more Scripts with the logic of which animation to use, for example, if the character starts to jump then we set the jumping animation, if the character is idle then we set the idle animation, etc.

Hope it could help as an idea, here is an old game I made for a ludum dare following this approach, search in the core module.

_________________
Image


Top
 Profile  
 
PostPosted: Sat Feb 04, 2012 11:20 pm 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
arielsan wrote:
In our case, we have an AnimationComponent with multiple Animations and each Animation is a collection of Sprite. Then, for each specific kind of entity (for example for the super mario character) we have one or more Scripts with the logic of which animation to use, for example, if the character starts to jump then we set the jumping animation, if the character is idle then we set the idle animation, etc.

Hope it could help as an idea, here is an old game I made for a ludum dare following this approach, search in the core module.
On your blog you post a possible solution for scripting. Wouldn't it be a security hole to pass world and entity into scripts? Might be more secure to create a interface api for adding entities to the world in a way that the host application can control what components an entity has and puts less control in scripts.

I do agree that Artemis is better to use for rendering then logic for more complex games, which you would use scripts for, otherwise you get SYSTEM OVERLOADING [PUN] :D

When I say System Overloading I mean so many systems doing so many things it creates a debugging nightmare when your sprites are doing funky stuff because they are being affected by one of the many systems you have running. This does not apply to everyone just some of us who prefer to be able to sleep at night.


Top
 Profile  
 
PostPosted: Sat Feb 04, 2012 11:31 pm 
Offline
Regular
User avatar

Joined: Tue Apr 07, 2009 12:58 pm
Posts: 232
Location: Uruguay
Security hole :shock:? We are not leaving personal user information available for hackers by using Scripts or anything like that (at least we don't have personal user information yet). On the other side, it is an optional thing, you can use all the systems and components you want to avoid using scripting. I agree, however, that the design and API could be improved.

_________________
Image


Top
 Profile  
 
PostPosted: Sat Feb 04, 2012 11:35 pm 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
Not the type of security hole i was talking about but that would be a very BIG security whole if you did.. I wouldn't play your game :(

But what I meant was API security. You might not want the end user to be able to Delete(npc) a special NPC therefore creating a chain of butterfly effects to your adventure altering the ending in ways you didn't imagine possible.


Top
 Profile  
 
PostPosted: Sat Feb 04, 2012 11:36 pm 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
Letting the end user get access to the World or Entity instances opens up the entity.Delete() and World.DeleteEntity(entity) methods to the end user.


Top
 Profile  
 
PostPosted: Sat Feb 04, 2012 11:52 pm 
Offline
Regular
User avatar

Joined: Tue Apr 07, 2009 12:58 pm
Posts: 232
Location: Uruguay
For now, the end user is not supposed to touch any Script since they are Java classes. If a hacker wants to decompile the code, modify a Script, good for him. If the game doesn't work anymore after that modification, it is not my problem.

I don't really understand the problem here. Maybe you are thinking about leaving the Scripts outside the code, for example, the Lua Scripts of Aquaria. Aquaria is a successful game and, as far as I know, nobody ever said anything about security holes for using Lua for scripting.

End users just play the game but please correct me if I am wrong. Maybe I am just misunderstanding your point.

_________________
Image


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 2:31 am 
Offline

Joined: Sun Jan 02, 2011 8:39 pm
Posts: 64
I was just trying to help with problems that may arise. Maybe I don't get what you are using Scripts for. I was under the impression they would be scripts loaded from files.


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 11:22 am 
Offline
Regular
User avatar

Joined: Tue Apr 07, 2009 12:58 pm
Posts: 232
Location: Uruguay
Here is an example of a script:

Code:
public class EngineScript extends ScriptJavaImpl {

   private final Vector2 force = new Vector2();

   @Override
   public void update(World world, Entity e) {
      EngineComponent engineComponent = Components.getEngineComponent(e);

      PhysicsComponent physicsComponent = Components.getPhysicsComponent(e);
      Body body = physicsComponent.getBody();

      if (body.getLinearVelocity().x > engineComponent.maxSpeed)
         return;

      force.set(engineComponent.speed, 0f );

      body.applyForceToCenter(force);
   }

}


Scripts are just Java classes, they are used because we can attach them to the Entity's life cycle in an easy way. For now, we are not using external files, nor different languages.

_________________
Image


Top
 Profile  
 
PostPosted: Wed Feb 08, 2012 10:58 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
I'd recommend loading only one instance for each script, compile it, and reuse the instance for all entities sharing the same script.


Top
 Profile  
 
PostPosted: Sat Feb 18, 2012 5:46 am 
Offline

Joined: Sat Feb 18, 2012 5:23 am
Posts: 2
... post deleted by author


Last edited by davesf on Mon Feb 27, 2012 5:17 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Feb 20, 2012 11:53 pm 
Offline

Joined: Wed Feb 01, 2012 2:56 am
Posts: 4
Hi,

I have an issue that I was wondering if someone could help me with that I have no idea on how to solve. Every so often when I run my tests (this is on iOS, I converted Artemis to Objective-C). I have gotten it setup with a some systems in place (currently 5) which have been working good. However during testing iterations of my game (If I kill the game and restart) one of my systems fails to process. I have traced it back to this code here:

- (void) change:(Entity*) entity {
BOOL contains = (systemBit & entity.systemBits) == systemBit;
BOOL interest = (typeFlags & entity.typeBits) == typeFlags;

if (interest && !contains && typeFlags > 0) {
[actives add:entity];
[entity addSystemBit:systemBit];
[self added:entity];
}

what happens is that sometimes through the contains variable evaluates to true and so the following if statement doesn't execute and that system doesn't have any entities to process. However this appears to be occurring sporadically. When the issue occurred the systemBit value as 156848688 and the entitySystemBits (1, 2, 4, 8, 16) respectively. Both systemBit and entity.systemBit are defined as longs. If anybody could provide some guidance that would be great.

thanks,


Top
 Profile  
 
PostPosted: Tue Feb 21, 2012 12:42 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
davesf wrote:
After wading through the many pages of posts piled up in this single thread... it would be nice to see a whole forum dedicated to Artemis.. The forum posted about seems to be unavailable..

http://gamadu.com/forum

Any chance for a Google Group / Yahoo Group, or some other reliable forum service?

I created a Google Group here if folks would like to use it..

https://groups.google.com/forum/?hl=en& ... ity-system

Well, I don't think there's enough traffic for a dedicated forum. I think 1 thread is sufficient, and Google has already decided this is it :)
I did put up a forum, you link to, but as I said, it's pretty dead.


Top
 Profile  
 
PostPosted: Tue Feb 21, 2012 12:49 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
BlackMarq wrote:
Hi,

I have an issue that I was wondering if someone could help me with that I have no idea on how to solve. Every so often when I run my tests (this is on iOS, I converted Artemis to Objective-C). I have gotten it setup with a some systems in place (currently 5) which have been working good. However during testing iterations of my game (If I kill the game and restart) one of my systems fails to process. I have traced it back to this code here:

- (void) change:(Entity*) entity {
BOOL contains = (systemBit & entity.systemBits) == systemBit;
BOOL interest = (typeFlags & entity.typeBits) == typeFlags;

if (interest && !contains && typeFlags > 0) {
[actives add:entity];
[entity addSystemBit:systemBit];
[self added:entity];
}

what happens is that sometimes through the contains variable evaluates to true and so the following if statement doesn't execute and that system doesn't have any entities to process. However this appears to be occurring sporadically. When the issue occurred the systemBit value as 156848688 and the entitySystemBits (1, 2, 4, 8, 16) respectively. Both systemBit and entity.systemBit are defined as longs. If anybody could provide some guidance that would be great.

thanks,

Not sure when you started porting, there are some fixes in the svn (http://gamadu.com/svn/artemis), you can check the logs and see if anything is relevant.

It may be a porting issue though, you're probably not resetting the entity.systemBits properly.


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 ... 20, 21, 22, 23, 24, 25, 26 ... 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