short on time after preparing this but i think a combination of both suggestions above would work well. it's a simple distance check between 2 "hot spots" as van b suggest using "states" flags per databug. it's NOT pixel perfect but could be considered accurate enough for your basic sprite-based fighter game.
some commented pseudo-code:
rem set up sprites
sprite fighter1,500,500,fighter1image `64x64 sprite
Xoffset1 = 32 `middle of the sprite
Yoffset1 = 64 `bottom of the sprite
offset sprite fighter1, Xoffset1, Yoffset1
fistoffsetX = 19
fistoffsetY = -40
fistRadius = 2
sprite fighter2,500,550,fighter2image `same as above
Xoffset2 = 32
Yoffset2 = 64
offset sprite fighter2, Xoffset2, Yoffset2
headoffsetX = 0
headoffsetY = -44
headRadius = 5
rem game loop
do
rem player controls
...
if PunchKey1 = 1
fighter1_IS_attacking
else
fighter1_ISN'T_attacking
fighter1_HASN'T_hit
endif
...
rem check for hit
if fighter1_IS_attacking and fighter1_HASN'T_hit
rem get current hotspot centers based on current sprite x,y locations
hotfistX = sprite x(fighter1) + fistoffsetX
hotfistY = sprite y(fighter1) + fistoffsetY
hotheadX = sprite x(fighter2) + headoffsetX
hotheadY = sprite y(fighter2) + headoffsetY
rem get distance between hotspot centers
hot2hotDistance = sqrt((hotheadX - hotfistX)^2 + (hotheadY - hotfistY)^2)
rem get distance to check against
totalhotlengths = fistRadius + headRadius
rem compare
if hot2hotDistance <= totalhotlengths
fighter1_HAS_hit
fighter2_health = fighter2_health - DAMAGE
else
fighter1_HASN'T_hit
endif
endif
...
loop
and a zoomed-in, less-than-perfect visual to go with it:
note, fighter1 is on the left, fist hotspot outlined and the sprite x,y reference point marked in red. green = fighter2.
the concept is there but you would definitely be fleshing this out more to include fist/feet vs head, torso, legs, etc, checks as well. perhaps using different shape checks. ie, represent torso and legs with rectangles (hotboxes) instead of circles (hotspots).
hope this helps! after whipping up the old-school karate champ-styled sprite samples, i now wanna make a full game