author | ecalot
<ecalot> 2004-11-06 10:29:31 UTC |
committer | ecalot
<ecalot> 2004-11-06 10:29:31 UTC |
parent | 742f8e031524d9c662de811516cc780ccc270916 |
FP/src/conf/awk/states_conf_static.awk | +5 | -3 |
FP/src/conf/states/main.conf | +33 | -31 |
FP/src/include/states.h | +2 | -1 |
FP/src/ker/kid.c | +5 | -2 |
FP/src/ker/object.c | +5 | -2 |
FP/src/ker/states.c | +30 | -35 |
FP/src/out/output.c | +2 | -1 |
diff --git a/FP/src/conf/awk/states_conf_static.awk b/FP/src/conf/awk/states_conf_static.awk index 5260f17..0b2f346 100644 --- a/FP/src/conf/awk/states_conf_static.awk +++ b/FP/src/conf/awk/states_conf_static.awk @@ -31,10 +31,12 @@ BEGIN { currentCondition=-1 currentAction=-1 - printf("#define STATES_MOVETYPES_RELATIVE 0\n") - printf("#define STATES_MOVETYPES_ABSOLUTEFORWARD 1\n\n") - printf("#define STATES_MOVETYPES_RELATIVETURN 2\n\n") + printf("#define STATES_MOVETYPES_ABSOLUTEONSTART 0\n") + printf("#define STATES_MOVETYPES_ABSOLUTEONSTOP 1\n") + printf("#define STATES_MOVETYPES_RELATIVETURN 2\n") + printf("#define STATES_MOVETYPES_RELATIVE 3\n") printf("#define STATES_CONDITIONS {\\\n") + #mawg property validation # tmp="conf/statesproperties.conf" # while ((getline line < tmp) > 0) { diff --git a/FP/src/conf/states/main.conf b/FP/src/conf/states/main.conf index 03a7fe1..2ae1202 100644 --- a/FP/src/conf/states/main.conf +++ b/FP/src/conf/states/main.conf @@ -39,7 +39,7 @@ normal: animation 16-22 steps - relative 0 + relative 0 action Jump conditions @@ -52,7 +52,7 @@ normal: 28 ps 29-33 p steps - relative 20 + relative 0 action Pass level @@ -64,7 +64,7 @@ normal: animation 53-64 steps - relative 0 + relative 0 action Climb up conditions KeyUp pressed @@ -90,7 +90,7 @@ normal: 81-93 96-99 steps - relative 0 + relative 0 action Jump up with free space up conditions @@ -102,7 +102,7 @@ normal: 81-93 96-99 steps - relative 2 + relative 0 action Jump up with cieling conditions @@ -113,7 +113,7 @@ normal: 81-92 97-99 steps - relative 0 + relative 0 action Start walking but he will crach into the wall conditions KeyShift pressed @@ -122,7 +122,7 @@ normal: next normal steps - relative 0 + relative 0 animation 15 p action Walking a step @@ -132,11 +132,13 @@ normal: next normal steps - relative 10 + relative 0 animation - 134-135 p 1 - 136-142 2 - 143-145 p 1 + 134-135 p 0 + 136 1 + 137-139 2 + 140 1 + 141-145 p 0 #total: 10 action Start running and crashing conditions KeyForward pressed @@ -144,7 +146,7 @@ normal: next normal steps - relative 0 + relative 0 animation 15 p action Start running @@ -153,7 +155,7 @@ normal: next running steps - relative 12 + relative 0 animation 1-4 p action Turn @@ -162,7 +164,7 @@ normal: next normal steps - relativeTurn 0 + relativeTurn 5 animation 45-52 p action Crouch @@ -171,7 +173,7 @@ normal: next crouched steps - relative 0 + relative 0 animation 118-120 p @@ -181,7 +183,7 @@ normal: next crouched steps - relative 0 + relative 0 animation 15 f @@ -193,7 +195,7 @@ normal: animation 15 p steps - relative 0 + relative 0 level 0 1 @@ -209,7 +211,7 @@ running: next crouched steps - relative 2 + relative 0 animation 118-120 p action Jump and crash @@ -220,7 +222,7 @@ running: next normal steps - relative 0 + relative 0 animation 15 p @@ -231,7 +233,7 @@ running: next running steps - relative 20 + relative 0 animation 34-44 p @@ -243,7 +245,7 @@ running: next normal steps - relative 0 + relative 0 animation 15 p action Keep running @@ -252,7 +254,7 @@ running: next running steps - relative 15 + relative 0 animation 5-14 p action Turn @@ -261,7 +263,7 @@ running: next normal steps - relativeTurn 0 + relativeTurn 0 animation 65-77 p action Stop running @@ -270,7 +272,7 @@ running: next normal steps - relative 10 + relative 0 animation 65-68 p 49-52 p @@ -285,7 +287,7 @@ crouched: normal steps - relative 0 + relative 0 animation 121-123 p 129-130 p @@ -297,7 +299,7 @@ crouched: next wcrouched steps - relative 4 + relative 0 animation 120-123 p @@ -307,7 +309,7 @@ crouched: next crouched steps - relative 0 + relative 0 animation 120 p @@ -317,7 +319,7 @@ crouched: next normal steps - relative 0 + relative 0 animation 121-123 p 129-130 p @@ -328,7 +330,7 @@ crouched: next normal steps - relative 3 + relative 0 animation 121-130 p wcrouched: #Make the player re-press the forward key to contin @@ -339,7 +341,7 @@ wcrouched: #Make the player re-press the forward key to contin next wcrouched steps - relative 0 + relative 0 animation 120 p action The user drop forward key @@ -367,6 +369,6 @@ titlesjaffar: animation 1-20 steps - relative 10 + relative 0 mark jaffar diff --git a/FP/src/include/states.h b/FP/src/include/states.h index c4c619a..2a3b4bd 100644 --- a/FP/src/include/states.h +++ b/FP/src/include/states.h @@ -10,7 +10,8 @@ typedef enum {esLast=0,esKeyUp,esKeyDown,esKeyForward,esKeyBack,esKeyShift,esMap typedef enum {esDangerous,esNone,esWalk,esPotion,esSword,esMirror,esNotApplicable=0}tsTileType; -typedef enum {esRelative,esForwardTile,esRelativeTurn}tsMoveType; /* */ +/*typedef enum {esRelative,esForwardTile,esRelativeTurn}tsMoveType; */ +typedef char tsMoveType; typedef struct { tsConditionType type; diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c index f432c9b..0fca5b0 100644 --- a/FP/src/ker/kid.c +++ b/FP/src/ker/kid.c @@ -132,9 +132,12 @@ tKid kidCreate() { } void kidDraw(tKid kid) { + void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1]; + /* TODO: move this -1 to each script frame */ + printf("w=%d\n",outputGetWidth(image)); outputDrawBitmap( - kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1], /* TODO: move this -1 to each script frame */ - (kid.location*32)/10, + image, + ((kid.location*32)/10)-((kid.direction==DIR_LEFT)?0:outputGetWidth(image)), 58+kid.floor*TILE_H ); } diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c index f432c9b..0fca5b0 100644 --- a/FP/src/ker/object.c +++ b/FP/src/ker/object.c @@ -132,9 +132,12 @@ tKid kidCreate() { } void kidDraw(tKid kid) { + void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1]; + /* TODO: move this -1 to each script frame */ + printf("w=%d\n",outputGetWidth(image)); outputDrawBitmap( - kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1], /* TODO: move this -1 to each script frame */ - (kid.location*32)/10, + image, + ((kid.location*32)/10)-((kid.direction==DIR_LEFT)?0:outputGetWidth(image)), 58+kid.floor*TILE_H ); } diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c index a2990ca..b020a25 100644 --- a/FP/src/ker/states.c +++ b/FP/src/ker/states.c @@ -181,51 +181,46 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) { current->currentState=statesActionList[action].nextStateId; printf("NEW STATE: action=%d next=%d\n",action,current->currentState); /* Move the kid (turn+traslate) */ - /* TODO: code absolutestepsforward and relativestepsforward*/ - /* switch(statesActionList[action].moveType) { + switch(statesActionList[action].moveType) { case STATES_MOVETYPES_ABSOLUTEONSTART: + /* AbsoluteOnStart (x) + * Moves the kid x step units from the first forward tile change + * and starts the animation there + */ + + /* 1) move current location to the left tileChange */ + kid->location-=(kid->location%STATES_STEPS_PER_TILE); + /* 2) if looking right add one tile to reach the right tileChange + * 3) if looking right add x, if looking left substract x */ + if (kid->direction!=DIR_LEFT) + kid->location+=STATES_STEPS_PER_TILE+statesActionList[action].moveOffset; + else + kid->location-=statesActionList[action].moveOffset; break; case STATES_MOVETYPES_ABSOLUTEONSTOP: + /* AbsoluteOnStop (x) + * Deletes frames (in the middle) to make sure that, at the end of the animation, + * the kid had moved only x step units from the first forward tile change + * if there is a lack of movements by frame it stops before reaching it. + */ + break; case STATES_MOVETYPES_RELATIVETURN: + /* relative but turning */ + kid->direction=(kid->direction==DIR_LEFT)?DIR_RIGHT:DIR_LEFT; + kid->location+=(kid->direction==DIR_LEFT)? + -statesActionList[action].moveOffset: + statesActionList[action].moveOffset; break; case STATES_MOVETYPES_RELATIVE: + kid->location+=(kid->direction==DIR_LEFT)? + -statesActionList[action].moveOffset: + statesActionList[action].moveOffset; break; - }*/ - if (kid->direction==DIR_LEFT) { - /*current->step=-current->step;*/ - /*steps=-steps;*/ - switch(statesActionList[action].moveType) { - case STATES_MOVETYPES_RELATIVE: - /*kid->location-=statesActionList[action].moveOffset;*/ - break; - case STATES_MOVETYPES_ABSOLUTEFORWARD: - kid->location=kid->location-(kid->location%STATES_STEPS_PER_TILE); - break; - case STATES_MOVETYPES_RELATIVETURN: - /*kid->location-=statesActionList[action].moveOffset;*/ - kid->direction=DIR_RIGHT; - break; - } - } else { - switch(statesActionList[action].moveType) { - case STATES_MOVETYPES_RELATIVE: - /*kid->location+=statesActionList[action].moveOffset;*/ - break; - case STATES_MOVETYPES_ABSOLUTEFORWARD: - kid->location=STATES_STEPS_PER_TILE+kid->location-(kid->location%STATES_STEPS_PER_TILE); - break; - case STATES_MOVETYPES_RELATIVETURN: - /*kid->location+=statesActionList[action].moveOffset;*/ - kid->direction=DIR_LEFT; - break; - } } - current->acumLocation=kid->location; } - /*current->acumLocation+=current->step;*/ - steps=(kid->direction==DIR_LEFT)?steps:-steps; - kid->location+=steps; /*current->acumLocation;*/ + + kid->location+=(kid->direction==DIR_LEFT)?-steps:steps; { diff --git a/FP/src/out/output.c b/FP/src/out/output.c index aa92677..5de4063 100644 --- a/FP/src/out/output.c +++ b/FP/src/out/output.c @@ -246,7 +246,8 @@ int outputGetHeight(void* image) int outputGetWidth(void* image) { - return ((SDL_Surface*)image)->w; + register tSurface* img=(tSurface*)image; + return img->surface->w; } /* Finish all output modes, including the screen mode */