Log In  

So... one of the things in my tinkering cart that I'm playing with is sprite complexity. The idea here is to associate the player position with the body, then draw the head relative to the player position, and finally, layer the expression on top of the head (unless it's facing up/away), and recolor as appropriate. It's not just the player that'll be using the build, but many enemies and NPCs as well, of course, so I'm trying to plan a "DRAWBODY(..)" function to draw the whole thing in one swoop.

So far, I'm thinking important factors are:

-x and y positions
-body frame
-colors of body
-relative head x/y
-head color/sprite
-eye expression/color
-facial expression/color

...but I get the feeling I might be forgetting something here?

P#32592 2016-11-17 17:58 ( Edited 2016-11-18 01:17)

Seems like a good start! I'd take what you have so far and get going on a draft version of that drawbody() function to make sure the parts you have so far work together the way you're thinking they will.

You could design a generic bodypart object that could be used for all your pieces -- something with a subset of those attributes that'll apply to everything that builds out a player/npc/baddie body, that you can then use to create a nested body, like

part = {}
part.x = (x offset relative to parent object)
part.y = (y offset likewise)
part.sp = (sprite index for this part)
part.pal = (list of {original,replacement} color pairs for pal() calls)
part.children = (list of bodypart objects that exist relative to this one)

Then your body object is the parent, and has in its children list a bodypart object for the head, which for its children in turn has bodypart objects for the eyes and the mouth.

Then your bodydraw() function can start from whatever a given player/npc/baddie object's top level parent object is and iterate through the nest of .children objects attached to it. And you can use the same generic approach for entities with different varieties and numbers of children objects without having to write per-entity code exception cases.

P#32594 2016-11-17 20:17 ( Edited 2016-11-18 01:17)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-05-29 05:17 | 0.008s | 2097k | Q:11