git » fp-git.git » commit d76e26d

button events are binded

author ecalot
2004-08-25 07:25:19 UTC
committer ecalot
2004-08-25 07:25:19 UTC
parent fc30b0d341625a8153edd420ff127363f48638df

button events are binded

FP/src/include/maps.h +1 -1
FP/src/include/types.h +1 -0
FP/src/ker/kid.c +4 -2
FP/src/ker/object.c +4 -2
FP/src/ker/room.c +4 -5
FP/src/res/maps.c +7 -0

diff --git a/FP/src/include/maps.h b/FP/src/include/maps.h
index 6948a1e..7ba7acd 100644
--- a/FP/src/include/maps.h
+++ b/FP/src/include/maps.h
@@ -51,7 +51,7 @@ tRoom mapGetRoom(tMap* map, tRoomId roomId);
 void  mapStart(tMap* map, tKid* kid, tRoomId* roomId, int level);
 
 /* events */
-void  mapPressedTile(tMap* map, tTile tile);
+void  mapPressedTile(tMap* map, tTile tile, int s, int x, int y);
 void  mapMove(tMap* map);
 
 #endif
diff --git a/FP/src/include/types.h b/FP/src/include/types.h
index e7ad265..6ac73fb 100644
--- a/FP/src/include/types.h
+++ b/FP/src/include/types.h
@@ -93,6 +93,7 @@ typedef struct {
 	int isWall;
 	int hasSword;
 
+	tModId back;
 	char code;
 } tTile;
 
diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c
index dc1bd6a..a3299e9 100644
--- a/FP/src/ker/kid.c
+++ b/FP/src/ker/kid.c
@@ -257,8 +257,10 @@ int kidMove(tKid* kid,tKey key,tRoom* room) {
 	}
 	tile=roomGetTile(room,(kid->location/TILE_W)+1,kid->floor+1);
 	if (!tile.walkable) {
-			fprintf(stderr,"kidMove: Tile not walkable, falling\n");
-			kid->floor++;
+		fprintf(stderr,"kidMove: Tile not walkable, falling\n");
+		kid->floor++;
+	} else {
+		mapPressedTile(room->level, tile, room->id, (kid->location/TILE_W)+1, kid->floor+1);
 	}
 	if (kid->floor<0) {
 		kid->floor=2;
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index dc1bd6a..a3299e9 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -257,8 +257,10 @@ int kidMove(tKid* kid,tKey key,tRoom* room) {
 	}
 	tile=roomGetTile(room,(kid->location/TILE_W)+1,kid->floor+1);
 	if (!tile.walkable) {
-			fprintf(stderr,"kidMove: Tile not walkable, falling\n");
-			kid->floor++;
+		fprintf(stderr,"kidMove: Tile not walkable, falling\n");
+		kid->floor++;
+	} else {
+		mapPressedTile(room->level, tile, room->id, (kid->location/TILE_W)+1, kid->floor+1);
 	}
 	if (kid->floor<0) {
 		kid->floor=2;
diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c
index 6bc8ef6..480693b 100644
--- a/FP/src/ker/room.c
+++ b/FP/src/ker/room.c
@@ -63,10 +63,9 @@ void roomFree() {
 tTile roomGetTile(tRoom* room,int x, int y) {
 	tTile   result;
 	tTileId fore;
-	tModId  back;
 
 	fore=room->fore[x+12*y];
-	back=room->back[x+12*y];
+	result.back=room->back[x+12*y];
 	result.code=fore&0x1F;
 	
 	switch (result.code) { /* TODO: use arrays and a better algorithm */
@@ -108,7 +107,7 @@ tTile roomGetTile(tRoom* room,int x, int y) {
 	case T_PILLAR:
 	case T_DEBRIS:
 		result.hasGateFrame=0;
-		result.bricks=(result.code==T_FLOOR)?back:0;
+		result.bricks=(result.code==T_FLOOR)?result.back:0;
 		result.hasPillar=(result.code==T_PILLAR);
 		result.hasBigPillar=(result.code==T_BP_BOTTOM);
 		result.isGate=0;
@@ -116,7 +115,7 @@ tTile roomGetTile(tRoom* room,int x, int y) {
 		result.hasChopper=(result.code==T_CHOPPER);
 		result.isExit=(result.code==T_EXIT_LEFT)?1:((result.code==T_EXIT_RIGHT)?2:0);
 		result.block=0;
-		result.isPressable=(result.code==T_BTN_RAISE);
+		result.isPressable=(result.code==T_BTN_RAISE)|(result.code==T_BTN_DROP);
 		result.hasSkeleton=(result.code==T_SKELETON);
 		result.hasSpikes=(result.code==T_SPIKES);
 		result.hasTorch=(result.code==T_TORCH)|(result.code==T_TORCH_DEBRIS);
@@ -150,7 +149,7 @@ tTile roomGetTile(tRoom* room,int x, int y) {
 	default:
 		result.hasGateFrame=(result.code==T_TAPESTRY_TOP);
 		result.hasBigPillar=(result.code==T_BP_TOP)*2;
-		result.bricks=back;
+		result.bricks=result.back;
 		result.hasPillar=0;
 		result.walkable=0;
 		result.isExit=0;
diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c
index c5d5d91..b3acb12 100644
--- a/FP/src/res/maps.c
+++ b/FP/src/res/maps.c
@@ -293,7 +293,14 @@ void  mapMove(tMap* map) {
 	if (slevel(time)==1000) slevel(time)=0;
 }
 
+void  mapPressedTile(tMap* map, tTile tile, int s, int x, int y) {
+		if (tile.isPressable) {
+			/* drop or raise button */
+			fprintf(stderr,"mapPressedTile: throw event %d\n",tile.back);
+		}
+
 
+}