| author | ecalot
<ecalot> 2004-08-26 11:25:52 UTC |
| committer | ecalot
<ecalot> 2004-08-26 11:25:52 UTC |
| parent | cccf6e5463ce703a403fcf39a6b17dbf489a3e9b |
| FP/src/include/types.h | +2 | -0 |
| FP/src/ker/room.c | +16 | -8 |
| FP/src/res/maps.c | +18 | -3 |
diff --git a/FP/src/include/types.h b/FP/src/include/types.h index 5526bbe..b058799 100644 --- a/FP/src/include/types.h +++ b/FP/src/include/types.h @@ -42,6 +42,7 @@ typedef unsigned char tModId; typedef enum {eOpenTimer,eOpen,eClose,eClosing,eOpening,eClosingFast}tGateAction; typedef enum {eJustPressed,eNormal,ePressed,eStuck}tPressableAction; typedef enum {eNormalGate,eExitGate}tGateType; +typedef enum {eDrop,eRaise}tPressableType; typedef struct { int time; @@ -57,6 +58,7 @@ typedef struct { typedef struct { tEvent* event; + tPressableType type; tPressableAction action; } tPressable; diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c index 9266d8a..6bab6ad 100644 --- a/FP/src/ker/room.c +++ b/FP/src/ker/room.c @@ -304,7 +304,7 @@ void drawBackPanel(tRoom* room,int x, int y) { outputDrawBitmap( roomGfx.environment->pFrames[10], (x-1)*TILE_W, - y*TILE_H+1 + y*TILE_H+((((tPressable*)left.moreInfo)->action==eNormal)?1:2) ); } /* debris/left */ @@ -438,9 +438,9 @@ void drawBackPanel(tRoom* room,int x, int y) { /* pressable/this */ if (tile.isRaise) { outputDrawBitmap( - roomGfx.environment->pFrames[58-((left.walkable)&&(!left.isRaise))], + roomGfx.environment->pFrames[(((tPressable*)left.moreInfo)->action==eNormal)?(58-((left.walkable)&&(!left.isRaise))):58], (x-1)*TILE_W, - y*TILE_H + y*TILE_H+((((tPressable*)left.moreInfo)->action==eNormal)?0:1) ); } /* debris/this */ @@ -483,11 +483,19 @@ void drawBackBottomTile(tRoom* room,int x, int y) { /* normal */ if (tile.walkable) { - outputDrawBitmap( - roomGfx.environment->pFrames[(tile.isPressable)?47:11], - (x-1)*TILE_W, - y*TILE_H+3 - ); + if (tile.isPressable) { + outputDrawBitmap( /* TODO: drop has resource 59 for unpressed/reise 47? check game */ + roomGfx.environment->pFrames[59], + (x-1)*TILE_W, + y*TILE_H+((((tPressable*)tile.moreInfo)->action==eNormal)?3:4) + ); + } else { + outputDrawBitmap( + roomGfx.environment->pFrames[11], + (x-1)*TILE_W, + y*TILE_H+3 + ); + } } else { /* wall */ if (tile.isWall) { diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index 81fb4ec..9c6c959 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -102,6 +102,7 @@ void* mapLoadLevel(tMemory level) { tPressable newPressable; newPressable.event=map->events+map->back[i*30+j]; newPressable.action=eNormal; + newPressable.type=((map->fore[i*30+j]&0x1f)==T_BTN_RAISE)?eRaise:eDrop; map->back[i*30+j]=pressableInRoom; map->screenPressables[i][pressableInRoom]=map->pressables+pressables; fprintf(stderr,"mapLoadLevel: Creating button: indexed=%d,%d btn pointer=%p\n",i,pressableInRoom,(void*)(map->pressables+pressables)); @@ -285,8 +286,8 @@ void mapMove(tMap* map) { int i; slevel(time)++; if (slevel(time)==1000) slevel(time)=0; - /* check out all the gates in the level */ - + + /* check out and update all the gates in the level */ for (i=0;i<slevel(totalGates);i++) { int maxFrames; maxFrames=(map->gates[i].type==eNormalGate)?46:50; @@ -328,11 +329,26 @@ void mapMove(tMap* map) { break; } } + + /* check out and update all the buttons in the level */ + for (i=0;i<slevel(totalPressables);i++) { + switch (map->pressables[i].action) { + case eJustPressed: + map->pressables[i].action=ePressed; + break; + case ePressed: + map->pressables[i].action=eNormal; + break; + default: + break; + } + } } void mapPressedTile(tMap* map, tTile tile, int s, int x, int y) { if (tile.isPressable) { tEvent* event; + ((tPressable*)tile.moreInfo)->action=eJustPressed; /* drop or raise button */ event=((tPressable*)tile.moreInfo)->event; fprintf(stderr,"mapPressedTile: throw event from button %d event:%p\n",tile.back,(void*)event); @@ -340,7 +356,6 @@ void mapPressedTile(tMap* map, tTile tile, int s, int x, int y) { event->gate->action=tile.isRaise?eOpening:eClosingFast; } while ((event++)->triggerNext); } - }