author | ecalot
<ecalot> 2005-02-20 20:22:57 UTC |
committer | ecalot
<ecalot> 2005-02-20 20:22:57 UTC |
parent | 8d8275ffcefb3cb310151d5c7df5424727b419e6 |
FP/src/conf/flags.conf | +1 | -0 |
FP/src/conf/states/main.conf | +33 | -4 |
FP/src/include/input.h | +1 | -1 |
FP/src/include/kid.h | +1 | -0 |
FP/src/ker/kernel.c | +51 | -16 |
FP/src/ker/kid.c | +5 | -0 |
FP/src/out/input.c | +7 | -0 |
diff --git a/FP/src/conf/flags.conf b/FP/src/conf/flags.conf index 10a741b..faaa4ca 100644 --- a/FP/src/conf/flags.conf +++ b/FP/src/conf/flags.conf @@ -10,6 +10,7 @@ f fall down u go up one floor t turn m mirror +x you are dead! d drink something that is in the tile you are in h loose a hit point diff --git a/FP/src/conf/states/main.conf b/FP/src/conf/states/main.conf index 5f1cf69..befe5bc 100644 --- a/FP/src/conf/states/main.conf +++ b/FP/src/conf/states/main.conf @@ -227,6 +227,8 @@ normal: level 0 1 + mark + resurrect guardskill 0 1 @@ -418,7 +420,8 @@ falling1: conditions MapDown spikes next - exit spiked + #exit spiked + spiked animation 15 f @50 212-216 @@ -457,7 +460,8 @@ falling2: conditions MapDown spikes next - exit spiked + #exit spiked + spiked animation 15 f @50 212-216 @@ -494,7 +498,8 @@ falling3: conditions MapDown spikes next - exit spiked + #exit spiked + spiked animation 15 f @45 212-216 @@ -502,11 +507,13 @@ falling3: conditions MapDown walkable next - exit splash + #exit splash + splash animation 117 f @45 117 @20 117 + 215-216 action Continue falling @@ -519,3 +526,25 @@ falling3: 117 f @45 117 @20 117 + +spiked: + action speaked forever + next + spiked + animation + 79 x + +splash: + action death forever + next + splash + animation + 80 x + +chopped: + action you are in two parts, ouch! + next + chopped + animation + 78 x + diff --git a/FP/src/include/input.h b/FP/src/include/input.h index fcb11d6..d0b5973 100644 --- a/FP/src/include/input.h +++ b/FP/src/include/input.h @@ -33,7 +33,7 @@ input.h: Free Prince : Input devices handling #ifndef _INPUT_H_ #define _INPUT_H_ -typedef enum {none=0,quit,load,reload,passLevel,showUp,showLeft,showRight,showDown,showScreens,showMoreScreens,showVersion,showTime,addTime,takeTime,addLive,addHitPoint,gotoTitles,kill,resurrect,joystick,keyboard,featherWeight,addHitpoint,invert,blind,other,save}tAction; +typedef enum {none=0,quit,load,reload,passLevel,showUp,showLeft,showRight,showDown,showScreens,showMoreScreens,showVersion,showTime,addTime,takeTime,addLive,addHitPoint,gotoTitles,kill,resurrect,joystick,keyboard,featherWeight,addHitpoint,invert,blind,other,save,buttonPressed,pause}tAction; /*#define inputIgnoreCtrl(a) (a&( ~(1<<1) ))*/ /* TODO: use inputIgnore* for each Set* */ diff --git a/FP/src/include/kid.h b/FP/src/include/kid.h index fc18de8..3ccccaf 100644 --- a/FP/src/include/kid.h +++ b/FP/src/include/kid.h @@ -43,6 +43,7 @@ void kidGetLive(tObject *kid); void kidGetHitPoint(tObject *kid); int kidTakeHitPoint(tObject *kid); int kidMove(tObject* kid,short flags,tRoom* room); +void kidKillHim(tObject *kid); #endif diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c index c29fc6c..6632485 100644 --- a/FP/src/ker/kernel.c +++ b/FP/src/ker/kernel.c @@ -51,12 +51,23 @@ tObject kid; int playgame(int optionflag,int level) { /* Create objects */ - tKey key=inputCreateKey(); - tData* resMap=resLoad(RES_MAP|level); - tMap* map=(tMap*)resMap->pFrames; + tKey key; + tData* resMap; + tMap* map; tRoom room; tRoomId roomId; - int death=0; + int notReset; + int flags; + int timeDead; + +while (1) { + /* Initialize */ + key=inputCreateKey(); + resMap=resLoad(RES_MAP|level); + map=(tMap*)resMap->pFrames; + notReset=1; + flags=0; + timeDead=0; /*TODO: use a map.c function that reads this information and creates the kid*/ kid=objectCreate(30,1,DIR_RIGHT,stateKidInLevel(level),RES_IMG_ALL_KID,1,oKid); @@ -69,7 +80,7 @@ int playgame(int optionflag,int level) { room=mapGetRoom(map,roomId); /* Level loop here */ - while (death>=0) { + while (notReset) { if (inputGetEvent(&key)) { /* Time event */ @@ -78,7 +89,7 @@ int playgame(int optionflag,int level) { * TODO: send to the real place where * the key is interpreted in kid object */ - death=objectMove(&kid,key,&room); + flags=objectMove(&kid,key,&room); mapMove(map); /* Drawing functions */ outputClearScreen(); /* TODO: send to drawBackground() */ @@ -86,6 +97,16 @@ int playgame(int optionflag,int level) { kidDrawLives(&kid); objectDraw(kid); roomDrawForeground(&room); + /* if dead */ + if (flags&STATES_FLAG_X) timeDead++; + if (timeDead==20) outputDrawMessage(120,"Press Button to Continue"); + if (timeDead==160) outputDrawMessage(10,"Press Button to Continue"); + if (timeDead==180) outputDrawMessage(10,"Press Button to Continue"); + if (timeDead==200) outputDrawMessage(10,"Press Button to Continue"); + if (timeDead==210) { + resFree(resMap); + return 0; + } outputUpdateScreen(); } else { /* Action event */ @@ -118,11 +139,22 @@ int playgame(int optionflag,int level) { resFree(resMap); level++; level%=16; - resMap=resLoad(RES_MAP|level); +/* resMap=resLoad(RES_MAP|level); map=(tMap*)resMap->pFrames; mapStart(map,&kid,&roomId,level); room=mapGetRoom(map,roomId); - outputDrawMessage(24,"Cheat: Pass to level %d\n",level); + outputDrawMessage(24,"Cheat: Pass to level %d\n",level);*/ + notReset=0; + break; + case buttonPressed: + if (!(flags&STATES_FLAG_X)) + break; /* break if not dead */ + case reload: + notReset=0; + break; + case addLive: + break; + case addHitPoint: break; case showVersion: outputDrawMessage(24,"FreePrince v"FP_VERSION"\n"); @@ -136,6 +168,8 @@ int playgame(int optionflag,int level) { room.links[eDown] ); break; + case pause: + break; case showMoreScreens: outputDrawMessage(24,"S%d AL%d AR%d BL%d BR%d\n", room.id, @@ -150,21 +184,22 @@ int playgame(int optionflag,int level) { } } } - switch (death) { +/* switch (death) { case STATE_EXIT_CODE_SPIKED: - outputDrawMessage(1,"You are spiked! Press a key\n"); + outputDrawMessage(1,"You are spiked! Press a key"); break; case STATE_EXIT_CODE_SPLASH: - outputDrawMessage(1,"Splashh! Explicit content censored!\n"); + outputDrawMessage(1,"Splashh! Explicit content censored!"); + break; + case STATE_EXIT_CODE_CHOMPED: + outputDrawMessage(1,"You are dead! Press a key"); break; -/* case STATE_EXIT_CODE_CHOMPED: - outputDrawMessage(1,"You are dead! Press a key\n"); - break;*/ } outputUpdateScreen(); inputPause(); - return playgame(optionflag,level); /* TODO: fix this recursivity */ -/* return 0;*/ + return playgame(optionflag,level); * TODO: fix this recursivity */ +} + return 0; } /* diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c index d4f9e4b..6a22362 100644 --- a/FP/src/ker/kid.c +++ b/FP/src/ker/kid.c @@ -68,6 +68,11 @@ int kidTakeHitPoint(tObject *kid) { return --kid->hitPoints; } +void kidKillHim(tObject *kid) { + /* Returns 0 if death or the number of remaining hit points if not */ + kid->hitPoints=0; +} + /* Room stuff */ int kidVerifyRoom(tObject *kid,tRoom *room,int refresh) { diff --git a/FP/src/out/input.c b/FP/src/out/input.c index 48253e3..bb21ecf 100644 --- a/FP/src/out/input.c +++ b/FP/src/out/input.c @@ -113,12 +113,19 @@ int editAction(tKey* key,SDLKey k) { key->actionPerformed=takeTime; break; default: + key->actionPerformed=buttonPressed; break; } } /* Normal actions */ if (!(key->status)) { switch (k) { + case SDLK_ESCAPE: + key->actionPerformed=pause; + break; + case SDLK_RETURN: + key->actionPerformed=buttonPressed; + break; case SDLK_r: key->actionPerformed=resurrect; break;