| author | ecalot
<ecalot> 2004-11-09 09:03:19 UTC |
| committer | ecalot
<ecalot> 2004-11-09 09:03:19 UTC |
| parent | 84ac3ad1f3449388ea11f2da9af14194b1e20ea1 |
| FP/src/conf/states/main.conf | +7 | -7 |
| FP/src/ker/kid.c | +56 | -5 |
| FP/src/ker/object.c | +56 | -5 |
| FP/src/ker/states.c | +1 | -1 |
diff --git a/FP/src/conf/states/main.conf b/FP/src/conf/states/main.conf index 73a7751..eca9931 100644 --- a/FP/src/conf/states/main.conf +++ b/FP/src/conf/states/main.conf @@ -136,11 +136,11 @@ normal: steps relative 0 animation - 134-135 p 0 - 136 1 - 137-139 2 - 140 1 - 141-145 p 0 #total: 10 + 134-135 p 1 + 136 5 + 137-139 6 + 140 5 + 141-145 p 1 #total: 32 action Start running and crashing conditions KeyForward pressed @@ -159,7 +159,7 @@ normal: steps relative 0 animation - 1-4 p + 1-4 p 3 action Turn conditions KeyBack pressed @@ -258,7 +258,7 @@ running: steps relative 0 animation - 5-14 p + 5-14 p 5 action Turn conditions KeyBack pressed diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c index ee9df81..a3737fc 100644 --- a/FP/src/ker/kid.c +++ b/FP/src/ker/kid.c @@ -131,12 +131,55 @@ tKid kidCreate() { return kid; } +int kidVerifyRoom(tKid *kid,tRoom *room) { + /* if the kid is out of the screen we need to change the screen and put + * the kid back again on it + */ + + int refresh=0; + + /* The kid is down */ + if (kid->floor==4) { + kid->floor=0; + room->id=room->links[eDown]; + refresh=1; + } + + /* The kid is up */ + if (kid->floor==-1) { + printf("pas\xf3: kf=0 ahora es 3, cambio el id del room y refresco\n"); + kid->floor=2; + room->id=room->links[eUp]; + refresh=1; + } + + /* The kid is left */ + if (kid->location<0) { + kid->location+=TILE_W*10; + room->id=room->links[eLeft]; + refresh=1; + } + + /* The kid is right */ + if (kid->location>TILE_W*10) { + kid->location-=TILE_W*10; + room->id=room->links[eRight]; + refresh=1; + } + + return refresh; +} + + + +#define kid_getLocation(kid,image) ((kid).location-(outputGetWidth(image)>>1)) + void kidDraw(tKid kid) { void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1]; /* TODO: move this -1 to each script frame */ outputDrawBitmap( image, - ((kid.location*32)/10)-((kid.direction==DIR_LEFT)?0:outputGetWidth(image)), + kid_getLocation(kid,image), 58+kid.floor*TILE_H ); } @@ -146,21 +189,29 @@ int kidMove(tKid* kid,tKey key,tRoom* room) { /* advance state and get the flag, then interpret the flag and do the events */ short flags; int refresh=0; + int x; + flags=stateUpdate(&key,kid,room); + + x=kid_getLocation(*kid,kidGfx.kid[kid->direction]->pFrames[stateGetImage(*kid)-1])/TILE_W; + if (flags&STATES_FLAG_P) refresh=mapPressedTile( room->level, - roomGetTile(room,(kid->location/10)+1,kid->floor+1), + roomGetTile(room,x+1,kid->floor+1), room->id, - (kid->location/10)+1, + x+1, kid->floor+1 ); +printf("f era %d. ",kid->floor); if (flags&STATES_FLAG_F) kid->floor++; if (flags&STATES_FLAG_U) kid->floor--; - - if (refresh) { /* room was changed and needs to be refreshed */ +printf("f pasa a ser %d\n",kid->floor); + refresh=kidVerifyRoom(kid,room)||refresh; + + if (refresh) { /* room map was changed and needs to be refreshed */ *room=mapGetRoom(room->level,room->id); } return flags; diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c index ee9df81..a3737fc 100644 --- a/FP/src/ker/object.c +++ b/FP/src/ker/object.c @@ -131,12 +131,55 @@ tKid kidCreate() { return kid; } +int kidVerifyRoom(tKid *kid,tRoom *room) { + /* if the kid is out of the screen we need to change the screen and put + * the kid back again on it + */ + + int refresh=0; + + /* The kid is down */ + if (kid->floor==4) { + kid->floor=0; + room->id=room->links[eDown]; + refresh=1; + } + + /* The kid is up */ + if (kid->floor==-1) { + printf("pas\xf3: kf=0 ahora es 3, cambio el id del room y refresco\n"); + kid->floor=2; + room->id=room->links[eUp]; + refresh=1; + } + + /* The kid is left */ + if (kid->location<0) { + kid->location+=TILE_W*10; + room->id=room->links[eLeft]; + refresh=1; + } + + /* The kid is right */ + if (kid->location>TILE_W*10) { + kid->location-=TILE_W*10; + room->id=room->links[eRight]; + refresh=1; + } + + return refresh; +} + + + +#define kid_getLocation(kid,image) ((kid).location-(outputGetWidth(image)>>1)) + void kidDraw(tKid kid) { void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1]; /* TODO: move this -1 to each script frame */ outputDrawBitmap( image, - ((kid.location*32)/10)-((kid.direction==DIR_LEFT)?0:outputGetWidth(image)), + kid_getLocation(kid,image), 58+kid.floor*TILE_H ); } @@ -146,21 +189,29 @@ int kidMove(tKid* kid,tKey key,tRoom* room) { /* advance state and get the flag, then interpret the flag and do the events */ short flags; int refresh=0; + int x; + flags=stateUpdate(&key,kid,room); + + x=kid_getLocation(*kid,kidGfx.kid[kid->direction]->pFrames[stateGetImage(*kid)-1])/TILE_W; + if (flags&STATES_FLAG_P) refresh=mapPressedTile( room->level, - roomGetTile(room,(kid->location/10)+1,kid->floor+1), + roomGetTile(room,x+1,kid->floor+1), room->id, - (kid->location/10)+1, + x+1, kid->floor+1 ); +printf("f era %d. ",kid->floor); if (flags&STATES_FLAG_F) kid->floor++; if (flags&STATES_FLAG_U) kid->floor--; - - if (refresh) { /* room was changed and needs to be refreshed */ +printf("f pasa a ser %d\n",kid->floor); + refresh=kidVerifyRoom(kid,room)||refresh; + + if (refresh) { /* room map was changed and needs to be refreshed */ *room=mapGetRoom(room->level,room->id); } return flags; diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c index 3c92779..d81faf4 100644 --- a/FP/src/ker/states.c +++ b/FP/src/ker/states.c @@ -44,7 +44,7 @@ void debugShowFlag(short optionflag) { printf("\n"); } -#define STATES_STEPS_PER_TILE 10 +#define STATES_STEPS_PER_TILE TILE_W /* Private static state graph */ static tsAction statesActionList[]=STATES_ACTIONS; static short statesAnimationList[]=STATES_ANIMATIONS;