Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Sprites and Entities

  1. #11

    Re: Sprites and Entities

    Quote Originally Posted by Andreaz
    After some more testing I'm considering ditching the TPHXEntity.Clone as a object construction method and use something like thise:

    Code:
    TPHXEntityDefinition = class
     private
      // Name of the entity definition
      FName: String;
     protected
      function AddImpl(const AParent: TPHXEntity): TPHXEntity; virtual; abstract;
     public
      // Create a new entity from this definition
      function Add(const AParent: TPHXEntity): TPHXEntity;
    
       // Name of the entity definition
      property Name: String read FName write FName;
     end;
    
    constructor TPlayerDefinition.Create(SpriteImages: TPHXImageList);
    begin
     Image    := SpriteImages.Find('Sprites/AncientCruiser');
     PatternIndex:= 0;
     ShipName  := 'Ancient Cruiser';
    end;
    
    function TPlayerDefinition.AddImpl(const AParent: TPHXEntity): TPHXEntity;
    var Sprite: TPHXSprite;
    begin
     Sprite:= TPHXSprite.Create(AParent);
     Result:= Sprite;
    
     Sprite.Image    := Image;
     Sprite.PatternIndex:= PatternIndex;
    end;
    
    and creating a player sprite:
    
    Player:= PlayerDefinition.Add(nil) ;
    
    and then you can retrieve the definition like this:
    
     TPlayerDefinition(Player.Definition).ShipName
    This seems to be working
    I don't know about this TPHXEntity.Clone function you're talking about. I can't find it in my version of Phoenix (2009-05-11 it's the latest public release right?)

    I must admit I'm struggling to see the big point with a THPXEntityDefinition. It gives a nice structured way to create entities but is there more to it?

    Quote Originally Posted by Andreaz
    I've had some great progress over the last few days, i have a canvas demo to make and some more fine tuning on the sprites, and then its time for a more final release. I wont promise to much, but you might see it before the weekend!
    Sounds good.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  2. #12

    Re: Sprites and Entities

    Quote Originally Posted by pstudio
    I don't know about this TPHXEntity.Clone function you're talking about. I can't find it in my version of Phoenix (2009-05-11 it's the latest public release right?)
    Yeah, its not in that version, it was discussed previously in this topic as a sprite creation tool.

    Ie at game startup you created one of every type of sprite and then used the clone on them to add sprites to the game world.

    The reasoning behind this is basically to get faster sprite creation and less sprite classes (makes creating a pool of sprites a lot easier)

    Quote Originally Posted by pstudio
    I must admit I'm struggling to see the big point with a THPXEntityDefinition. It gives a nice structured way to create entities but is there more to it?
    One thing is that it gives a (optional, i might add) nice way of creating sprites. It is really the model in the MVC pattern. It is also a place to put all the data that isn't necessary common to all entities (again, without inheritance as with the affectors).

    Also what i found about the Clone is that you seldom need a exact copy of a sprite, the definition class solves this by putting the copying code in a user class.

    I ran into a few bugs last weekend that i had to track down, but everything i wanted to get done before the release is completed, need to make sure everything compiles (D7, FPC as well) and cleanup some stuff.


    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  3. #13

    Re: Sprites and Entities

    Quote Originally Posted by Andreaz
    One thing is that it gives a (optional, i might add) nice way of creating sprites. It is really the model in the MVC pattern. It is also a place to put all the data that isn't necessary common to all entities (again, without inheritance as with the affectors).

    Also what i found about the Clone is that you seldom need a exact copy of a sprite, the definition class solves this by putting the copying code in a user class.

    I ran into a few bugs last weekend that i had to track down, but everything i wanted to get done before the release is completed, need to make sure everything compiles (D7, FPC as well) and cleanup some stuff.
    I see it gives a nice way to create sprites. It'll be interesting to see it in the release.

    About the release. Are there any significant changes to the entity system? For instance there was a TPHXEntityWorld class in the latest release that didn't quite seem finished.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •