[Dev] SVN: james/326 Experimenting with a different method of styling a creature's animations

James Paige Bob at HamsterRepublic.com
Tue Mar 25 10:49:43 PDT 2008


(taking this on-list)

On Tue, Mar 25, 2008 at 09:54:29AM -0700, Brian Fisher wrote:
> neat, marauders seems fun to play with
> 
> ---
> well a problem with your current code is forward vs. backward slashes
> - asset paths are canonicalized to use forward slashes, even on
> windows, so it fails on windows...  (the reason for that is so that on
> disk asset path strings are the same on all platforms) I committed a
> fix for that to motherhamster (so assetref assignment fixes the path)
> just so I could play with it easier

Oops! Clumsy me.

Well, the only reason I used os.path.join was because had to manually 
check whether or not the png file existed before assigning it's name to 
the ImageAsset's AssetRef... I don't understand why after I did 
self.style.sprite = "folder/and/file_that_totally_does_not_exist" I got 
a crash on display.render() instead of displaying he broken image 
asset...

> ---
> So there are two things going on - first is animations, second is
> dynamically picking an image for a direction...
> 
> I want to add some kind of support of an animation as a native
> editable resource - where all the images are in a single magically
> named folder and therefore can be selected and used as a single asset.
> I guess I forgot to get around to it - it should be fairly simple, but
> sadly it's not been done yet...

That will be cool for later :)

> so it would be something like:
>   left = AssetRef(AnimationAsset, "knight_left")
> then like:
>   image = self.left.get_frame(ratio_through_anim)
>   display.render(image, pos)
> where on disk, there is a knight_left.ani directory with some number
> of images in them

I would like that.

> ..On how to simplify/streamline/beautify a process of picking one of
> many animations based on the scenario, but still make it integrated
> with the asset management system... I don't really have a good general
> approach - I have been thinking about making an "AssetDict" which
> would be a dictionary of other asset's in a dictionary, where maybe
> you could restrict the possible keys to an enum or something like
> that, i.e.
>    direction_anims = AssetDict(AssetRef(ImageAsset), allowed_keys =
> direction_enum)
> where it would be used like:
>    anim = self.style.direction_anims[self.direction]
> which would streamline the code, but not the process of picking 4
> animations, one for each direction...
> 
> of course maybe we can make some kind of like "structuredImageSet"
> type of thing for that if we want to...

It would be nifty to have something like:

anim = AssetCollection(AssetRef(ImageAsset), "images/$1/$1_$2_$3$4")

which would be used like:

image = anim.get(collection_name, direction_name, frame_name, frame_num)
display.render(image, pos)

and would load files like
"images/knight/knight_left_striking1"

> and also, in your current situation the whole thing can be cleaned up
> a bit (see below)
> 
> ---
> As far as a "hidden AssetRef" - well you could put the AssetRef on
> Creature itself (instead of CreatureStyle) and it wouldn't be editable
> in that context - however, there is no really no reason to go through
> an assetref at all in this case - it's completely appropriate to
> explicitly load a particular asset with
> motherhamster.cheekpouches.Disgorge()
> 
> so you could do something like this in draw:
>   art_path =self. get_path(direction, frame)
>   image = cheekpouches.Disgorge(ImageAsset, art_path, verify_assetid=True)
>   display.render(image, pos)
> 
> and get rid of the AssetRef and set call on "CreatureStyle" entirely
> and put the path building code into Creature's "draw" function to get
> the path into some "get_path" function

*tests* Okay, I like that.

> as a note - the advantages of using assetrefs are editability and also
> being able to figure out which assets are actually used by static
> analysis of some root asset. since you don't want editability in that
> case it's out - and the dynamic assignment of paths breaks the other
> advantage of being able to build a used asset tree even if you use
> AssetRefs - which is why AssetRefs are useless for your use model.

Understood... (well, mostly. explain the "advantage of being able to 
build a used asset tree even if..."

> ---
> ... and yes the knight is adorable - egg-shaped military really cuts
> the edge off of the death and killing themes quite well

I plan on making this game "Math Marauders". The enemies will be 
numbered, and his weapons will be operators like the Sword of Minus, the 
Axe of Plus, and the Mace of Multiplication. I haven't figured out the 
whole gameplay yet, but that is the inspiration I am working from.

--
James

> On Tue, Mar 25, 2008 at 9:08 AM,  <subversion at hamsterrepublic.com> wrote:
> > james
> >  2008-03-25 09:08:39 -0700 (Tue, 25 Mar 2008)
> >  713
> >  Experimenting with a different method of styling a creature's animations.
> >  Instead of a long list of AssetRefs to ImmageAssets accompanied by a long
> >  if elif elif elif block to select the right one to display, the CreatureStyle
> >  just stores a base string used to construct the name of a set of appropriately
> >  named png files, which are assigned to the Style's .sprite asset member at
> >  runtime
> >
> >  Questions:
> >  * Is there a better way to handle a whole bunch of animation frames?
> >  * Is there such thing as a hidden AssetRef? Is there a way to create
> >   and ImageAsset that can be assigned using the string-assignment method
> >   at runtime, without making that ImageAsset editable in the Asset Browser?
> >  * Isn't the knight cute?
> >  ---
> >  U   marauders/creature.py
> >  U   marauders/data/knight.creaturestyle
> >  U   marauders/locals.py
> >  U   marauders/sourceart/knight.svg
> >
> 
> 



More information about the Dev mailing list