author | ecalot
<ecalot> 2005-12-28 01:27:48 UTC |
committer | ecalot
<ecalot> 2005-12-28 01:27:48 UTC |
parent | 9b4a951e58efec45c764995614ae08fcf6997028 |
FP/src/include/input.h | +6 | -0 |
FP/src/ker/kernel.c | +7 | -1 |
FP/src/ker/kid.c | +1 | -0 |
FP/src/ker/object.c | +4 | -0 |
FP/src/out/input.c | +16 | -0 |
FP/src/res/resources.c | +1 | -0 |
diff --git a/FP/src/include/input.h b/FP/src/include/input.h index d0b5973..bb16b64 100644 --- a/FP/src/include/input.h +++ b/FP/src/include/input.h @@ -33,6 +33,8 @@ input.h: Free Prince : Input devices handling #ifndef _INPUT_H_ #define _INPUT_H_ +#include "common.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,buttonPressed,pause}tAction; /*#define inputIgnoreCtrl(a) (a&( ~(1<<1) ))*/ @@ -82,4 +84,8 @@ void inputStopTimer(); void inputInitTimer(); void inputPause(); +#ifdef DEBUG_POS +void inputDebugSetTimer(int fps); +#endif + #endif diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c index 897da25..889c10a 100644 --- a/FP/src/ker/kernel.c +++ b/FP/src/ker/kernel.c @@ -37,11 +37,13 @@ kernel.c: FreePrince : Main Kernel #include "kernel.h" #include "maps.h" #include "object.h" +#include "kid.h" #include "output.h" #include "resources.h" #include "room.h" #include "states.h" /* stateKidInLevel */ #include "titles.h" +#include "common.h" /* * Main game control function @@ -71,7 +73,7 @@ int playgame(int optionflag,int level) { /*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); - outputDrawMessage(24,"LEVEL %d\n",level); + outputDrawMessage(24,"LEVEL %d",level); /* Game loop here */ @@ -170,6 +172,10 @@ int playgame(int optionflag,int level) { ); break; case pause: + /* using to turn to interactive debug mode if compuled with the flag */ +#ifdef DEBUG_POS + inputDebugSetTimer(500); +#endif break; case showMoreScreens: outputDrawMessage(24,"S%d AL%d AR%d BL%d BR%d\n", diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c index 6f07ba0..0da4541 100644 --- a/FP/src/ker/kid.c +++ b/FP/src/ker/kid.c @@ -34,6 +34,7 @@ kid.c: Free Prince : Kid object #include "room.h" #include <stdio.h> /* DEBUG printf */ #include "states.h" +#include "common.h" #include "output.h" /* outputDrawBitmap */ #include "maps.h" /* mapGetRoom */ diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c index a6e8a52..ab3fa05 100644 --- a/FP/src/ker/object.c +++ b/FP/src/ker/object.c @@ -84,6 +84,10 @@ void objectDraw(tObject* object) { object_getLocation(object,image), 58-stateGetBottom(object)+object->floor*TILE_H ); +#ifdef DEBUG_POS + if (object->type==oKid) + outputDrawMessage(1,"kidPos: %d,%d",object_getLocation(object,image),stateGetBottom(object)); +#endif } /* event triggered when an object is moved */ diff --git a/FP/src/out/input.c b/FP/src/out/input.c index bb21ecf..2ddd993 100644 --- a/FP/src/out/input.c +++ b/FP/src/out/input.c @@ -33,6 +33,7 @@ input.c: FreePrince : Input interface #include <SDL/SDL.h> #include "input.h" +#include "common.h" #include <stdio.h> /* only for the printf debug */ tKey inputCreateKey() { @@ -225,6 +226,14 @@ int inputGetEvent(tKey* key) { case SDL_KEYUP: editKey(key,event.key.keysym.sym,0); break; +#ifdef DEBUG_POS + case SDL_MOUSEBUTTONDOWN: + printf("apretaste un boton en (%d,%d)\n",event.button.x,event.button.y); + break; + case SDL_MOUSEBUTTONUP: + printf("levantaste el boton en (%d,%d)\n",event.button.x,event.button.y); + break; +#endif case SDL_USEREVENT: return 1; /* A new time cicle has started! */ case SDL_QUIT: @@ -252,6 +261,13 @@ Uint32 timer_callback(Uint32 interval, void *param) return interval; /* Timer must raise an alarm again after 'interval' ms. */ } +#ifdef DEBUG_POS +void inputDebugSetTimer(int fps) { + inputStopTimer(); + timer=SDL_AddTimer(fps, timer_callback, NULL); +} +#endif + void inputInitTimer() { timer=SDL_AddTimer(83, timer_callback, NULL); diff --git a/FP/src/res/resources.c b/FP/src/res/resources.c index 773b3c3..4956e2a 100644 --- a/FP/src/res/resources.c +++ b/FP/src/res/resources.c @@ -236,6 +236,7 @@ tData* resLoad(long id) { } void resFree(tData* res) { + if (!res) return; if (res->type==eImages) { while (res->frames) { /* free all frames */ outputFreeBitmap(res->pFrames[--(res->frames)]);