Update: Worked on the sprite engine a bit more today. The two guys on the bottom right are constructed from sub-sprites via the anchors and pivots I was talking about before.
Anchors and pivots can both be animated, so e.g., there is a pivot on moonman's hand that a weapon or item can be anchored to. This is all stored in resource files, here's the one for moonman's right arm walk animation, each frame specifies where in the bitmap the frame is (x,y), the anchor points for that frame (ax,ay), and any pivot points (p0x,p0y,p1x,p1y,...)
sprite {
name = "moonman_rightarm_wlkr",
sprite_sheet = "entities/moonman/moonman_walkright_rightarm.png",
width = 5,
height = 9,
animated = true,
loop = true,
duration = 0.1,
pivots = 1,
frames = {
{x= 0,y= 0,ax= 0,ay= 1,p0x= 0,p0y = 8},
{x= 0,y= 9,ax= 0,ay= 2,p0x= 2,p0y = 8},
{x= 0,y=18,ax= 0,ay= 1,p0x= 3,p0y = 6},
{x= 0,y=27,ax= 1,ay= 0,p0x= 3,p0y = 6},
{x= 0,y=36,ax= 1,ay= 0,p0x= 3,p0y = 7},
{x= 0,y=45,ax= 1,ay= 1,p0x= 3,p0y = 7},
{x= 0,y=54,ax= 0,ay= 0,p0x= 1,p0y = 7},
{x= 0,y=63,ax= 0,ay= 1,p0x= 0,p0y = 8}
}
}
These are then collected into
spritemaps, which contain all the possible animations of a single component, e.g., moonman's rightarm currently has three modes "face" (face forward), "facr" (face right), and "wlkr" (walk right). There are more to do: walk left, face left, shoot left/right, whack left/right, drink potion, etc..
sprite_map {
name = "moonman_rightarm",
modes = {
face = "moonman_rightarm_face",
facr = "moonman_rightarm_facr",
wlkr = "moonman_rightarm_wlkr"
}
}
These sprite_maps are then composited together into larger structures, via different templates. There will be templates for humanoids (legs,arms,head,torso,right arm,left arm,right item,left item,(hat?!)), simple creatures (body), machines (part1,part2,part3,...), etc. To instantiate a template, you make a resource file like so (where the components reference the sprite_maps you've already specified):
sprite_template {
name = "moonman_template",
type = core.sprite_types.humanoid,
components = {
head = "moonman_head",
tors = "moonman_torso",
rarm = "moonman_rightarm",
legs = "moonman_legs"
},
}
@electrolye Cheers, yeh I opted to go this route because I want the game to be easily modded -- adding a new weapon should only require a few sprites and a single scripts work.
@rek, @seasons, @dgh cheers for the feedback, I'll tackle the jump again sometime soon!