author | ecalot
<ecalot> 2005-01-15 17:25:13 UTC |
committer | ecalot
<ecalot> 2005-01-15 17:25:13 UTC |
parent | 54c4b35b21322895c5c27e2b638ecc4402dec5e7 |
FP/src/conf/flags.conf | +1 | -0 |
FP/src/include/maps.h | +0 | -1 |
FP/src/include/room.h | +1 | -0 |
FP/src/ker/room.c | +72 | -0 |
FP/src/res/maps.c | +0 | -21 |
diff --git a/FP/src/conf/flags.conf b/FP/src/conf/flags.conf index dfc204c..1ae4c5a 100644 --- a/FP/src/conf/flags.conf +++ b/FP/src/conf/flags.conf @@ -8,3 +8,4 @@ s make a sound g you hit the guard/kid f fall down u go up one floor +t turn diff --git a/FP/src/include/maps.h b/FP/src/include/maps.h index 8331636..7a2561c 100644 --- a/FP/src/include/maps.h +++ b/FP/src/include/maps.h @@ -51,7 +51,6 @@ tRoom mapGetRoom(tMap* map, tRoomId roomId); void mapStart(tMap* map, tObject* kid, tRoomId* roomId, int level); /* events */ -int mapPressedTile(tMap* map, tTile tile, int s, int x, int y); void mapMove(tMap* map); #endif diff --git a/FP/src/include/room.h b/FP/src/include/room.h index 384f8e7..fcf7361 100644 --- a/FP/src/include/room.h +++ b/FP/src/include/room.h @@ -43,6 +43,7 @@ tTile roomGetTile(tRoom* room,int x, int y); void roomDrawBackground(tRoom* room); void roomDrawForeground(tRoom* room); void roomLoadGfx(long environment); /* Only to initialize environment by mapStart */ +int roomPress(tRoom* room, tObject* obj); #endif diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c index 857aeab..fb584a1 100644 --- a/FP/src/ker/room.c +++ b/FP/src/ker/room.c @@ -452,4 +452,76 @@ void roomDrawForeground(tRoom* room) { } } +/* kernel functions */ + +int roomPress(tRoom* room, tObject* obj) { + /* Catching the press events done by an object to a room + * returns 0 if the room didn't change, 1 if it did + */ + + tMap* map=room->level; + int s=room->id; + int x=(obj->location/TILE_W)+1; + int y=obj->floor+1; + tTile tile=roomGetTile(room,x,y); + tTile aux; + int refresh=0; + + enum {border,nearborder,nearbordernotlooking,middle} where; + int i; + + /* buttons */ + if (isIn(tile,TILES_PRESSABLE)) { + 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); + do { + event->gate->action=isIn(tile,TILES_RAISE)?eOpening:eClosingFast; + } while ((event++)->triggerNext); + } + + /* Loose tiles */ + printf("s=%d x=%d y=%d\n",s,x,y); + if (isIn(tile,TILE_LOOSE)) { + map->fore[(s-1)*30+(x-1)+(y-1)*10]=TILE_EMPTY; + refresh=1; /* room changed, refresh it */ + } + + /* spikes */ + /* there are 7 possibilities to be */ +#define WHERE_NEAR 3 +#define WHERE_IN 1 + where=border;i=1; + if (((obj->location%TILE_W)<(TILE_W-WHERE_IN))&&obj->direction==DIR_LEFT){ + where=nearborder;i=1;} + if (((obj->location%TILE_W)<(TILE_W-WHERE_IN))&&obj->direction==DIR_RIGHT){ + where=nearbordernotlooking;i=1;} + if ((obj->location%TILE_W)<(TILE_W-WHERE_NEAR)){ + where=middle;} + if (((obj->location%TILE_W)<WHERE_NEAR)&&obj->direction==DIR_LEFT){ + where=nearborder;i=-1;} + if (((obj->location%TILE_W)<WHERE_NEAR)&&obj->direction==DIR_RIGHT){ + where=nearbordernotlooking;i=-1;} + if ((obj->location%TILE_W)<WHERE_IN){ + where=border;i=-1;} + + if (where!=middle) { + if (isIn(aux=roomGetTile(room,x+i,y),TILES_CHOPPER_SPIKE)) { + /* spikes left in this floor */ + tDanger* danger=aux.moreInfo; + } else if ((y<3)&&isIn(roomGetTile(room,x+i,y),TILE_EMPTY)&&isIn(aux=roomGetTile(room,x+i,y+1),TILES_CHOPPER_SPIKE)) { + /* spikes left in the lower floor, there is + * a space so you can fall down */ + tDanger* danger=aux.moreInfo; + } else if ((y<2)&&isIn(roomGetTile(room,x+i,y),TILE_EMPTY)&&isIn(roomGetTile(room,x+i,y+1),TILE_EMPTY)&&isIn(aux=roomGetTile(room,x+i,y+2),TILES_CHOPPER_SPIKE)) { + /* spikes left in the 2 level lower floor, there are + * spaces so you can fall down */ + tDanger* danger=aux.moreInfo; + } + } + return refresh; + +} diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index a7fa499..a1dd913 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -378,27 +378,6 @@ void mapMove(tMap* map) { } } } - -int mapPressedTile(tMap* map, tTile tile, int s, int x, int y) { - int refresh=0; - if (isIn(tile,TILES_PRESSABLE)) { - 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); - do { - event->gate->action=isIn(tile,TILES_RAISE)?eOpening:eClosingFast; - } while ((event++)->triggerNext); - } - printf("s=%d x=%d y=%d\n",s,x,y); - if (tile.code==TILE_LOOSE) { - map->fore[(s-1)*30+(x-1)+(y-1)*10]=TILE_EMPTY; - refresh=1; /* room changed, refresh it */ - } - return refresh; -} - void mapFreeLevel(tMap* map) { int i; for (i=0;i<24;i++) {