Diary of the Exploding Fist

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

Have started on the high-res heads. The first thing to do was figure out how I was going to represent the data. I decided to add another 'layer' to the source graphics, the 'head' layer. In that layer I drop a pixel where the head/body are to join.

Then I updated the sprite conversion tool to read that layer. When it's separating the frames, and reading the 'centerpoint' layer, it also now reads the 'head' layer and produces two tables - frameHeadX and frameHeadY which contain the x,y offset of the join pixel position of the highresolution head to the low-resolution body.

I then wrote some boilerplate code to draw a head (just a random sprite block for now) and position that at the join point. It's extremely rudimentary and I'm not really in a productive mood at the moment; everything seems an immense chore and way too hard. But it's a start.

Image shows two fighters with double-width player sprites overlaid showing head position retrieved from the 'head' layer as described above. It's going to take me a few weeks to get these heads working. Really not feeling it at this stage.




Andrew Davie

I've spent seemingly a LOT of time/effort on refining the sprite data tool "sp.py"
Originally this tool took a sprite sheet and spit out individual 8-pixel-wide frames.
Then I extended it to output multiple 8-pixel wide columns for each frame.
This let me use the playfield draw bitmap code to draw "wide" playfield sprites.
That was all working.

I then extended it to allow me to define center points for each frame.
Rather than defining these manually in a table, I used GIMP to draw a layer on which I put a single white pixel over each frame, representing the frame center point. The tool then output the sprite frames, tables for accessing, and a table for the center point position

That, then, allowed me to draw the frames in consistent locations on the screen and do some of the basic animations without fiddling with positions.

At that point I started on the heads.
I realised that heads ALSO are drawn as sprite sheets, they're ALSO 8-pixels wide, and they ALSO need center points - even though they are sprites instead of playfield. But, essentially the same requirements.

But heads need to attach to bodies - so we need an "attachment" point on the body as to where to put the centerpoint of the associated head. So, that's a new layer on the source graphics for the fighter frames - they now have a layer for the center point, and another for the head attachment point. On that new layer, again, just a single non-blank point on each frame to indicate where the head is attached.

So, I rewrote the tool to do that, and removed all the hackiness which was basically hardwiring. It's now quite neat. I pass on the command-line the various paramaters. The fighter frames is thus:

python3 ../tools/sp.py -m manifest.txt -o _frames --layers Centerpoints,Heads wotef_scaled2.png

"-m manifest.txt" allows me to give names to frames - these names are persistent between runs. So if I modify a frame's graphics (but the frame is in the same general position), then the name for it is preserved. Here's the manifest for the fighter frames as it currently stands...

# UNIQUE_ID, frame_name, x, y, width, height
CROUCH1,wotef_scaled2_56_201,56,201,10,30
CROUCH2,wotef_scaled2_70_198,70,198,12,33
FLIP0,wotef_scaled2_124_143,124,143,9,36
FLIP1,wotef_scaled2_2_184,2,184,13,47
FLIP2,wotef_scaled2_18_192,18,192,14,31
FLIP3,wotef_scaled2_116_14,116,14,12,34
FLIP4,wotef_scaled2_2_59,2,59,8,56
FLIP5,wotef_scaled2_12_79,12,79,14,36
FLIP6,wotef_scaled2_54_15,54,15,12,31
FLIP7,wotef_scaled2_136_135,136,135,7,44
FLIP8,wotef_scaled2_102_189,102,189,10,39
FRAME_13,wotef_scaled2_76_74,76,74,9,41
FRAME_14,wotef_scaled2_138_74,138,74,12,41
FRAME_17,wotef_scaled2_108_82,108,82,8,33
FRAME_18,wotef_scaled2_118_83,118,83,15,32
FRAME_21,wotef_scaled2_58_135,58,135,11,44
FRAME_23,wotef_scaled2_2_138,2,138,12,41
FRAME_24,wotef_scaled2_94_138,94,138,11,41
FRAME_26,wotef_scaled2_76_139,76,139,12,40
FRAME_27,wotef_scaled2_108_139,108,139,11,40
FRAME_30,wotef_scaled2_86_189,86,189,12,42
FRAME_32,wotef_scaled2_114_191,114,191,9,38
FRAME_35,wotef_scaled2_126_199,126,199,14,30
FRAME_38,wotef_scaled2_36_207,36,207,18,24
FRAME_39,wotef_scaled2_2_235,2,235,11,42
FRAME_41,wotef_scaled2_74_241,74,241,12,41
FRAME_42,wotef_scaled2_150_243,150,243,7,39
FRAME_43,wotef_scaled2_89_247,89,247,12,35
FRAME_44,wotef_scaled2_16_248,16,248,17,20
FRAME_45,wotef_scaled2_104_256,104,256,17,26
FRAME_46,wotef_scaled2_36_261,36,261,17,18
FRAME_47,wotef_scaled2_54_272,54,272,17,10
FRAME_48,wotef_scaled2_124_273,124,273,18,9
FRAME_49,wotef_scaled2_138_291,138,291,12,42
FRAME_50,wotef_scaled2_150_291,150,291,11,42
FRAME_51,wotef_scaled2_2_292,2,292,12,41
FRAME_52,wotef_scaled2_16_294,16,294,12,39
FRAME_53,wotef_scaled2_88_303,88,303,11,30
FRAME_54,wotef_scaled2_72_304,72,304,13,29
FRAME_55,wotef_scaled2_34_307,34,307,17,26
FRAME_56,wotef_scaled2_102_307,102,307,15,26
FRAME_57,wotef_scaled2_120_314,120,314,15,19
JUMP2,wotef_scaled2_46_130,46,130,10,35
KICK0,wotef_scaled2_70_11,70,11,9,40
KICK1,wotef_scaled2_44_74,44,74,9,41
KICK1X,wotef_scaled2_134_11,134,11,12,40
KICK2X,wotef_scaled2_98_12,98,12,13,39
KICK3,wotef_scaled2_82_15,82,15,13,36
KKICK0,wotef_scaled2_30_74,30,74,10,41
KKICK1,wotef_scaled2_34_131,34,131,10,36
KKICK2,wotef_scaled2_56_77,56,77,17,38
SIT,wotef_scaled2_142_202,142,202,15,29
STAND,wotef_scaled2_142_239,142,239,4,43
WALK1,wotef_scaled2_0_10,0,10,12,41
WALK2,wotef_scaled2_14_10,14,10,11,41
WALK3,wotef_scaled2_28_10,28,10,11,41
WALK4,wotef_scaled2_40_10,40,10,11,41
XKICK2,wotef_scaled2_16_139,16,139,14,40

So in the animations, for example, the walking uses WALK1, WALK2, WALK3, WALK4 as the frame ID/number for drawing the walk animation. The ones named "FRAME_**" are automatic and I haven't given them proper names yet.

So that's all nice and good, and working well.

The next parameter "-o _frames" is the filename for the .c and .h file generated by the code. The .h file contains equates for the frame naming; these will be the names in the manifest if the frame is located in the sprite sheet (i.e., same position), or generated names if something dramatic has happened (new frame, or repositioned).  Those .c and .h files are included in the build for the game and contain the graphics data/tables, centerpoints (if used), head attachment (if used).

The next parameter "--layers Centerpoints,Heads" tells the tool that there are two layers to process, in addition to the file that contains the sprite shapes. So here we have two layers, one called "Centerpoints" and the other "Heads". More on this in a tic...

The last parameter "wotef_scaled2.png" is the source graphics file for the frames. This is basically a sprite sheet with frames drawn in arbitrary positions in the image/file, each surrounded by 8-separated zero (black) pixels. The graphics file can be any python/pillow supported format (png, gif, jpg, etc).

Now, first the tool produces the tables for the sprite strips (8 pixels wide, ChronoColour format). Then it processes the layers, which are each stored in their own file with the layer suffix appended to the sprite sheet filename.  So in this example, we will be looking for "wotef_scaled2Centerpoints.png" and "wotef_scaled2Heads.png".  Those are, of course, where I saved each of the layers (with just a single non-black pixel placed in the appropriate place for each frame).  That's super-simple to do in GIMP because you can see layers, set transparency, etc., and thus put a pixel exactly where the centerpoint or the head attach point needs to be.

OK, so in this example, we will have two additional tables in our output _frames.c file;  one giving the X,Y offset for each frame of the centerpoint, and another table giving the X,Y offset for the head. These names Centerpoint and Head are arbitrary and could be used for any purpose. We could for example add another one called Weapon and in the image file wotef_scaled2Weapon.png have a dot on each frame location where a weapon is attached to a hand/foot/wherever.

Right, that's the main body/frames for the fighters, what about the heads?

The call for that is...

python3 ../tools/sp.py -m manifestHead.txt -o _heads --layers Centerpoints wotefHeads.png

So here we don't have a Heads layer (heads don't have heads on them... but they could!). We have a separate manifest file for the persistent frame names, and we output to _heads.h and _heads.c

One aside; the split-out frames are saved to temporary directories so they can be manually reviewed - these are temp_heads/ in this particular case. In the earlier example, temp_frames/

So the tool took a lot of work, but currently I have it successfully producing playfield sprite data (multiple 8-pixel-wide PF strips forming larger fighter frames), and head sprite data (actual sprites, 8 pixels wide strips).  It's rather neat.

Source code included for those interested, and some sample images as used by.


Andrew Davie

Here's the current generated data/files from the aforementioned tool.

Al_Nafuur

Quote from: Andrew Davie on 02 Feb 2026, 04:01 AMSo here we don't have a Heads layer (heads don't have heads on them... but they could!). We have a separate manifest file for the persistent frame names, and we output to _heads.h and _heads.c
Heads on heads? "Brilliant: One head for thinking, one head for the party." (Zaphod Beeblebrox)  

Andrew Davie

I did run out of space - mainly because there were 70+ frames of animations and many of those I won't use at all. So I modified the tool such that if the frame name (e.g. FRAME_23) in the manifest is prefixed with a dash, then that frame is NOT include in the output .c/.h source files. This gave me 7K back in one fell swoop. It's useful because previously I had to manually erase the frames in the sprite sheet - now I just process the whole sheet, and mark the frames I don't want (in the manifest) with that dash. It means I can add in new frames as I want, by giving them a good name and removing the dash. It's all persistent (that's why I made a manifest file in the first place).

So now I have a bunch of heads - I'm drawing them in this video offset from the player frame, just so I can see them properly. It's all pretty crap looking - placeholder graphics and colours - but I do think it can look OK once I tweak.  I need to associate the right head with the right body. I'm not sure how to do that efficiently (i.e., non-manually) yet... probably something to do with the naming; include the body name in the head name would do it nicely. But that would mean no head re-use across bodies. Gotta think about it.

But the heads DO join correctly to the correct body *position* (taking into account that debugging offset). So that's all working nicely.


Andrew Davie

Next up; collision boxes. Now that I have a pretty decent conversion tool that can parse images for things like center points and attachment points (for heads) -- it's time to extend it to doing collision boxes. There will be two types at least ... attack boxes and defense boxes.

I'll just create a new 'layer' for each, and modify the tool to detect boxes on those layer(s) and output to tables. Won't take too long once I get around to it.

I'm putting off final graphics and gameplay, in deference to getting the tools honed. So for a while it's still going to look pretty rough. But once I have the functionality of collisions (which will pretty much be pixel-accurate), then I can move on to refining the gameplay and graphics.


Andrew Davie

I have completed the updates to the sprite tool, and now I have boxes output as described. Each box layer (there can be any number of them) defines collision areas on frames. I currently have an attack layer and a defend layer. The code to check the collisions isn't working properly, but at east the data is here. Sample shown here...

__attribute__((used)) const BOX wotef_scaled2_Attack_KKICK2[] = { // wotef_scaled2_56_77
    {13,8,4,5},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_FLIP3[] = { // wotef_scaled2_116_14
    {2,16,2,7},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_FLIP4[] = { // wotef_scaled2_2_59
    {6,39,2,6},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_FLIP5[] = { // wotef_scaled2_12_79
    {12,16,2,7},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_FLIP6[] = { // wotef_scaled2_54_15
    {9,7,3,9},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_KKICK0[] = { // wotef_scaled2_30_74
    {2,0,3,8},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_KKICK2[] = { // wotef_scaled2_56_77
    {1,0,3,7},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_WALK1[] = { // wotef_scaled2_0_10
    {3,0,4,8},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_WALK2[] = { // wotef_scaled2_14_10
    {3,0,3,8},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_WALK3[] = { // wotef_scaled2_28_10
    {2,0,3,8},
};

__attribute__((used)) const BOX wotef_scaled2_Defend_WALK4[] = { // wotef_scaled2_40_10
    {2,0,3,8},
};

__asm__(".section .rodata\n"
    ".global AttackVectorTable_frames\n"
    "AttackVectorTable_frames:\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword wotef_scaled2_Attack_KKICK2\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
   );

__asm__(".section .rodata\n"
    ".global DefendVectorTable_frames\n"
    "DefendVectorTable_frames:\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword wotef_scaled2_Defend_FLIP3\n"
    "    .hword wotef_scaled2_Defend_FLIP4\n"
    "    .hword wotef_scaled2_Defend_FLIP5\n"
    "    .hword wotef_scaled2_Defend_FLIP6\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword wotef_scaled2_Defend_KKICK0\n"
    "    .hword 0\n"
    "    .hword wotef_scaled2_Defend_KKICK2\n"
    "    .hword 0\n"
    "    .hword 0\n"
    "    .hword wotef_scaled2_Defend_WALK1\n"
    "    .hword wotef_scaled2_Defend_WALK2\n"
    "    .hword wotef_scaled2_Defend_WALK3\n"
    "    .hword wotef_scaled2_Defend_WALK4\n"
   );


Essentially, for each box type (attack, defend) we have a pointer for each frame to a list of boxes for that frame, or 0 if no boxes.  The boxes are defined as x,y top left, and width, height.  The collision system needs to look for box overlap between attacker frame (attack boxes) and defender frame (defender boxes).  The code as it currently stands (not working!) is...

#include "collision.h"
#include "../gfx/_frames.h"
#include "player.h"
#include "random.h"
#include "splats.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"

void collide(int attacker, int defender) {

int frameAttack = *man[attacker].animPtr;
int frameDefend = *man[defender].animPtr;

const BOX *attackBox = (BOX *)AttackVectorTable_frames[*man[attacker].animPtr];
if (attackBox) {

int attackX1 =
    (man[attacker].x >> FRAC) - frameCenterpoints_framesXY[frameAttack].x + attackBox->x;
int attackX2 = attackX1 + attackBox->width;

if (man[attacker].mirror < 0) {
int temp = attackX1;
attackX1 = attackX2;
attackX2 = temp;
}

int attackY1 =
    (man[attacker].y >> FRAC) - frameCenterpoints_framesXY[frameAttack].y + attackBox->y;
int attackY2 = attackY1 + attackBox->height;

int spx = (attackX1 + attackX2) >> 1;
int spy = (man[attacker].y >> FRAC); //(attackY1 + attackY2) >> 1;
spy = 50;

addLocalSplat(spx << 8, spy << 8, rangeRandom(60) - 30, rangeRandom(100) - 50, 6, 50);

const BOX *defendBox = (BOX *)DefendVectorTable_frames[*man[defender].animPtr];
if (defendBox) {

FLASH(0xD4, 10);

int defendX1 = (man[defender].x >> FRAC) - frameCenterpoints_framesXY[frameDefend].x +
               defendBox->x;
int defendX2 = defendX1 + defendBox->width;

if (man[defender].mirror < 0) {
int temp = defendX1;
defendX1 = defendX2;
defendX2 = temp;
}

int defendY1 = (man[defender].y >> FRAC) - frameCenterpoints_framesXY[frameDefend].y +
               defendBox->y;
int defendY2 = defendY1 + defendBox->height;

bool overlap = !(attackX2 <= defendX1 || defendX2 <= attackX1);
//  || attackY2 <= defendY1 ||
//                  defendY2 <= attackY1);

if (overlap)
FLASH(0x44, 10);
}
}
}

#pragma GCC diagnostic pop
// EOF


There are many many glitches in the system at the moment, and lots to repair. But I want the diary to be an "in progress" unpolished view of how things are going from day to day.  Here's a video...


Andrew Davie

A quick update - here's the first "good looking" head stuff. I got the basic head shape/placement correct for the walking frames, and also individualised the palettes for the head (different to the PF clothing). It looks MUCH better. Remember, still placeholder graphics.  But I think it will look quite nice in the end.


Mike.Littau

I like the particle effects when a hit is made.  Makes it look like they dipped their feet in chalk before the fight.

Andrew Davie

Quote from: Mike.Littau on 06 Feb 2026, 07:59 AMI like the particle effects when a hit is made.  Makes it look like they dipped their feet in chalk before the fight.

It will be MUCH better once I correctly algin the particles with the point of impact. That's close, now, because I have the collision box data.

Andrew Davie

Quote from: Mike.Littau on 06 Feb 2026, 07:59 AMI like the particle effects when a hit is made.  Makes it look like they dipped their feet in chalk before the fight.


A bit more of an idea what it will look like...


Andrew Davie

#26
Binary just for fun. Lots of work to do.
Hold fire+forward for kick. That's the only attacking move you have right now.


Andrew Davie

#27
Update with better head placement, and I found a way to remove the "noise" behind the sprite heads.



Bomberman94

An idea for a game might be: you are running from left to right (player stays in the middle of screen, legs are moving when player moves and - if possible upper and lower parts ,,scroll" to the right). In this part player must defeat flying objects and avoid obstacles. After a while the player reaches an enemy and you must win against him (this is like the actual video you made). One additional scene could be kicking a wall or so to pass in a given time.

Andrew Davie

Quote from: Bomberman94 on 07 Feb 2026, 08:26 AMAn idea for a game might be: you are running from left to right (player stays in the middle of screen, legs are moving when player moves and - if possible upper and lower parts ,,scroll" to the right). In this part player must defeat flying objects and avoid obstacles. After a while the player reaches an enemy and you must win against him (this is like the actual video you made). One additional scene could be kicking a wall or so to pass in a given time.


These might all work, but I'm leaning towards just a few more tidy-ups and leaving it unfinished.
I just don't quite feel it's going to be a great game at this point, so I'm not inclined to make the effort to finish it. It's been fun developing the tools/systems, though, and those will be very useful in future.