author | ecalot
<ecalot> 2005-02-25 10:56:34 UTC |
committer | ecalot
<ecalot> 2005-02-25 10:56:34 UTC |
parent | 0f4c953852a88cb0e32288c7fff536cc2ef43381 |
FP/src/include/kernel.h | +1 | -1 |
FP/src/include/maps.h | +1 | -1 |
FP/src/include/types.h | +1 | -0 |
FP/src/ker/kernel.c | +1 | -1 |
FP/src/ker/object.c | +7 | -2 |
FP/src/res/maps.c | +10 | -2 |
diff --git a/FP/src/include/kernel.h b/FP/src/include/kernel.h index fddb0db..23abba4 100644 --- a/FP/src/include/kernel.h +++ b/FP/src/include/kernel.h @@ -43,7 +43,7 @@ kernel.h: Princed Resources : Resource Handler headers #define hasFlag(a) (optionflag&(a)) #define setFlag(a) optionflag|=(a) -#define FP_VERSION "0.3-pre-alpha-fullscreen" +#define FP_VERSION "0.4-pre-alpha-shadow-of-the-castle" int kernel(int optionflag,int level); /* level=-1 is default diff --git a/FP/src/include/maps.h b/FP/src/include/maps.h index 7a2561c..f77fedb 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, tObject* kid, tRoomId* roomId, int level); /* events */ -void mapMove(tMap* map); +int mapMove(tMap* map); #endif diff --git a/FP/src/include/types.h b/FP/src/include/types.h index c96b28e..b5ca835 100644 --- a/FP/src/include/types.h +++ b/FP/src/include/types.h @@ -117,6 +117,7 @@ typedef struct { unsigned char levelNumber; tFlying* flyingObjects; + int refresh; } tMap; typedef struct { diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c index beca3cc..f758f8c 100644 --- a/FP/src/ker/kernel.c +++ b/FP/src/ker/kernel.c @@ -90,7 +90,7 @@ int playgame(int optionflag,int level) { * the key is interpreted in kid object */ flags=objectMove(&kid,key,&room); - mapMove(map); + if (mapMove(map)) room=mapGetRoom(map,room.id); /* Drawing functions */ outputClearScreen(); /* TODO: send to drawBackground() */ roomDrawBackground(&room); diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c index c3a8105..bf45e33 100644 --- a/FP/src/ker/object.c +++ b/FP/src/ker/object.c @@ -107,10 +107,15 @@ int objectMove(tObject* object,tKey key,tRoom* room) { outputBlinkScreen(1,1); } if (flags&STATES_FLAG_D) { - tTile tile=roomGetTile(room,object->location/TILE_W+1,object->floor+1); + int x=object->location/TILE_W; + int y=object->floor; + tTile tile=roomGetTile(room,x+1,y+1); if (!kidDrinkPotion(object,tile)) /* drink the potion */ flags=STATE_EXIT_CODE_SPLASH; - /* TODO: transform the tile into floor */ + /* Change the map */ + room->level->fore[(room->id-1)*30+x+y*10]=TILE_FLOOR; + room->level->back[(room->id-1)*30+x+y*10]=0; + refresh=1; } break; case oGeneric: diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index 68e7074..0fb1740 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -180,6 +180,7 @@ void* mapLoadLevel(tMemory level) { map->events[i].gate=auxGates[(S-1)*30+L]; /* in case of error null is assigned */ } free(auxGates); + map->refresh=0; return (void*)map; } @@ -340,8 +341,8 @@ void mapStart(tMap* map, tObject* kid, tRoomId *roomId, int level) { } /* TODO: This is part of the kernel, it needs to be moved */ -void mapMove(tMap* map) { - int i; +int mapMove(tMap* map) { + int i,refresh; slevel(time)++; if (slevel(time)==1000) slevel(time)=0; @@ -483,6 +484,7 @@ void mapMove(tMap* map) { printf("IMPACT in s%d x%d y%d\n",loose->screen,x,y); map->fore[(loose->screen-1)*30+x+y*10]=TILE_DEBRIS; map->back[(loose->screen-1)*30+x+y*10]=0; + refresh=1; loose->screen=0; } } @@ -498,6 +500,12 @@ void mapMove(tMap* map) { loose=loose->next; } } + + if (map->refresh) { + map->refresh=0; + refresh=1; + } + return refresh; } void mapFreeLevel(tMap* map) {