Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 2:59 am

All times are UTC




Post new topic Reply to topic  [ 170 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 12  Next
Author Message
 Post subject:
PostPosted: Tue Jan 18, 2011 8:36 am 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
appel wrote:
I used arraylist in a similar manner as you're doing, and it was a big performance bottleneck. I swapped it out in favor of bags. It might not be a problem with a few hundred entities though.
....
Problem with linked entities like this is that you need to make sure all linked entities are deleted if the tank is destroyed.


Thanks for the info, appel! I'll have a look at your bags solution :wink:

How does your component system deal with linked or nested components?

My first approach would be to add some parent-child relationship between entities. And if the parent entity is destroyed it's children are destroyed too (or maybe not if they have a certain "keep me alive" flag set). If a child is destroyed it would be removed from its parent's list. Everything could be hidden in the destroy method of Entity.

Anyway, seems like you already solved some issues we didn't think about yet! Thanks for sharing :D

Good that our version number is just 0.1 - this gives room for improvements and doesn't already claim perfection :lol:

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2011 9:21 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Tommy wrote:
How does your component system deal with linked or nested components?


In my framework I do not have any specific nesting design, it's really up to the developer to make a component that deals with this. I was actually doing a entity using other nested entities just last night. I have a component simply called Node, once added to a entity, I can add whatever entities to this node. However, any entity contained in a Node is not registered in the EntityManager, so it's really "anonymous" within it's top-most entity.

It was a Tank entity, composed of something like 10 other entities. It had:
- 2 rear moving tracks, that scrolled according to the turning angle.
- 2 front turning and moving tracks, that also moved according to the turning angle.
- A base
- Two cover entities over the front tracks
- A rotating tower (a controller that controls it)
- - Barrels that inherit rotation from it's parent (with recoil effect) (a weapons controller that controls shooting)
- - The visual appearance of the tower (the turret without barrels)

I can't remember the exact layout. I can paste the code for this later tonight, as I don't have it here at work. It's many lines and quite verbose, but it allows me to construct a wide variety of tank types, without having to extend e.g. BasicTank, FourTracksTank, FourTracksTankWithTurningTracksAtFrontTank, BasicTankWithDualBarrels, etc.

Works pretty well.

But Artemis and Marte are two totally incompatible frameworks, I'd be careful about adopting anything from it.



As with "linked" entities, there aren't any, except in cases where I have a entity like Grid which has a nxm array of Tile, where each Tile has a collection of Entity which are on that tile. Each entity would then have a GridPositioner component, which would take care of positioning itself correctly in that Grid. This way I can look up any tile and get it's entities. This could do wonders for the framerate if you use it for culling, e.g. render only entities visible in tiles from 4,6 to 10,12.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2011 10:05 am 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
appel wrote:
But Artemis and Marte are two totally incompatible frameworks, I'd be careful about adopting anything from it.

Yeah, I'm just looking for ideas and inspiration.

BTW: Did you realize that Artemis and Marte share five characters?! There's more than meets the eye 8)

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2011 2:13 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Tommy wrote:
appel wrote:
But Artemis and Marte are two totally incompatible frameworks, I'd be careful about adopting anything from it.

Yeah, I'm just looking for ideas and inspiration.

BTW: Did you realize that Artemis and Marte share five characters?! There's more than meets the eye 8)

Martemis? :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2011 8:57 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
appel wrote:
I can't remember the exact layout. I can paste the code for this later tonight, as I don't have it here at work.


As promised:

Code:
   private void initTank(GameContainer container, StateBasedGame game) throws SlickException {
      
      Entity tank = new Entity("tank","Mammoth Tank","tanks", "PLAYER");
      tank.setPlayer(player);
      tank.setComponent(new Transform(500,300));
      PlayerMovementController playerMovementController = new PlayerMovementController();
      tank.setComponent(playerMovementController);
      
      Node tankNode = new Node();
      tankNode.setLayer(1);
      {
         {   // Shadow
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform());
            e.setComponent(new Sprite(new Image("mammoth/shadow.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }
         
         {   // Rear tracks bg
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform());
            e.setComponent(new Sprite(new Image("mammoth/rearTracks.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }
         {   // Left front tracks bg
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-40,40));
            e.setComponent(new Sprite(new Image("mammoth/frontTrack.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }         
         {   // Right front tracks bg
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-40,-40));
            e.setComponent(new Sprite(new Image("mammoth/frontTrack.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }   
         

         {   // Left rear track
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-76,-45));
            e.setComponent(new Track(playerMovementController, Track.Side.LEFT, 64, 11, new Image("mammoth/tracks.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }         
         {   // Right rear track
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-76,34));
            e.setComponent(new Track(playerMovementController, Track.Side.RIGHT, 64, 11, new Image("mammoth/tracks.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }   
         
         {   // Left front track
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,18,-45));
            e.setComponent(new Track(playerMovementController, Track.Side.LEFT, 44, 11, new Image("mammoth/tracks.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }   
         {   // Right front track
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,18,35));
            e.setComponent(new Track(playerMovementController, Track.Side.RIGHT, 44, 11, new Image("mammoth/tracks.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }            
         
         
         {   // Left rear track drawer
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-76,-45));
            e.setComponent(new TrackDrawer());
            e.initialize(container, game);
            tankNode.add(e, true);
         }         
         {   // Right rear track drawer
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-76,34));
            e.setComponent(new TrackDrawer());
            e.initialize(container, game);
            tankNode.add(e, true);
         }   
         {   // Left front track drawer
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,18,-45));
            e.setComponent(new TrackDrawer());
            e.initialize(container, game);
            tankNode.add(e, true);
         }         
         {   // Right front track drawer
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,18,35));
            e.setComponent(new TrackDrawer());
            e.initialize(container, game);
            tankNode.add(e, true);
         }            
         
         
         {   // Base
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform());
            e.setComponent(new Sprite(new Image("mammoth/base.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }
         
         {   // Left front track cover
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-40,40));
            e.setComponent(new Sprite(new Image("mammoth/leftFrontTrackCover.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }
         {   // Right front track cover
            Entity e = new Entity();
            e.setPlayer(player);
            e.setComponent(new Transform(0,0,-40,-40));
            e.setComponent(new Sprite(new Image("mammoth/rightFrontTrackCover.png")));
            e.initialize(container, game);
            tankNode.add(e, true);
         }
         
         {   // Tower
            Entity tower = new Entity();
            tower.setPlayer(player);
            tower.setComponent(new Transform());
            tower.setComponent(new PlayerTowerController());
         
            Node towerNode = new Node();
            {
               {   // Barrels
                  Entity e = new Entity();
                  e.setPlayer(player);
                  e.setComponent(new Transform());
                  e.setComponent(new Sprite(new Image("mammoth/barrels.png")));
                  e.setComponent(new PlayerWeapons());
                  e.initialize(container, game);
                  towerNode.add(e,true);
               }

               {   // Turret
                  Entity e = new Entity();
                  e.setPlayer(player);
                  e.setComponent(new Transform());
                  e.setComponent(new Sprite(new Image("mammoth/tower.png")));
                  e.initialize(container, game);
                  towerNode.add(e,true);
               }
            }
            tower.setComponent(towerNode);
            tower.initialize(container, game);
            
            tankNode.add(tower);
         }
         
      }
      tank.setComponent(tankNode);
      
      tank.initialize(container, game);
      EntityManager.getInstance().addEntity(tank);
   }

the "true" in the tankNode.add(..) is "inheritRotation".

Demo:
http://gamadu.com/games/tankz/webstart/tankz.jnlp

(yet to add physics so it collides with the crates)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2011 9:17 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
Wow! My respect! The tank looks pretty cool when driving (WASD) and the effect of the turret cannons moving back and forth when firing is also pretty cool.

But the huge code snippet to properly set up this tank :roll:

That's the perfect proof that we're targeting a different audience :wink:

Again, thanks for sharing all those informations with us - it definitely gives me (and I guess Gornova too) some ideas about improvements for Marte.

Maybe you'll find something helpful for Artemis too :lol:

Cheers,
Tommy

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2011 10:13 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Yes, the above code is totally wrong, and I'm working on ways to solve this issue so it's really just a few lines.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2011 12:55 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
Release for version 0.2 is near, on github wiki you can find some tutorials:

https://github.com/Gornova/MarteEngine/wiki

if you want to provide some feedback, feel free to say something! :D

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2011 9:25 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
MarteEngine 0.2 is out :D

Thanks Tommy for support and everyone for feedback, feel free to get more feedback or build your game with MarteEngine.

To start develop games, see wiki page!


note: updated main post, tagged version on github

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2011 10:17 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
WOOT! :D

Yes, show us your games made with Marte!

The upcoming competition would be a great possibility to create your winning entry with this nice little framework :wink:

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2011 12:44 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
Tommy wrote:
WOOT! :D

Yes, show us your games made with Marte!

The upcoming competition would be a great possibility to create your winning entry with this nice little framework :wink:



Yes I agree :D My entry will be based on top of MarteEngine 0.2 :D

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2011 12:20 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
Back from the compo with nice games (someone made with MarteEngine too, yeah!!), to give you a little news: video tutorial about making a shump with Java, Slick and MarteEngine

You can find them on crazyandcoding web site

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2011 8:18 am 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
Yeah, just for the statistics: Lex' winning entry Crush used MarteEngine :D
And of course my entry too. Didn't check for the other entries yet.

Great result and a very good reason to continue improving our MarteEngine!

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2011 11:31 am 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
I'm working on a new game with MarteEngine, here more information about it

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2011 4:32 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Your camera seems to be broken 8)

I'm trying to tell the camera to follow my player with the following:

setCameraOn(player);

But it doesn't work. My player isn't centered and I can move out of the container.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 170 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 12  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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