git » fp-git.git » commit 53611e6

Added listening and binding for u,h,n,j keys and actions.

author ecalot
2004-08-17 07:53:26 UTC
committer ecalot
2004-08-17 07:53:26 UTC
parent 8db0fc42531af095e67732cd14c516f658fe6110

Added listening and binding for u,h,n,j keys and actions.

FP/src/ker/kernel.c +19 -1
FP/src/ker/kid.c +1 -2
FP/src/ker/object.c +1 -2
FP/src/ker/room.c +9 -9
FP/src/out/input.c +16 -1

diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c
index 8843c9f..ac0b4c0 100644
--- a/FP/src/ker/kernel.c
+++ b/FP/src/ker/kernel.c
@@ -87,7 +87,25 @@ int playgame(int optionflag,int level) {
 			case gotoTitles:
 				resFree(map);
 				return 0;
-			default:
+			case showUp:
+				if(roomId=room.links[eUp]) {
+					room=mapGetRoom(map,roomId);
+					printf("Kernel/playgame: cheat: Looking up\n");
+				}
+				break;
+			case showLeft:
+				if(roomId=room.links[eLeft])
+					room=mapGetRoom(map,roomId);
+				break;
+			case showDown:
+				if(roomId=room.links[eDown])
+					room=mapGetRoom(map,roomId);
+				break;
+			case showRight:
+				if(roomId=room.links[eRight])
+					room=mapGetRoom(map,roomId);
+				break;
+		default:
 				break;
 			}
 		}
diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c
index 7d06af0..ff43b85 100644
--- a/FP/src/ker/kid.c
+++ b/FP/src/ker/kid.c
@@ -140,7 +140,7 @@ int kidMove(tKid* kid,tKey key/*,tRoom room*/) {
 		 *
 		 * Note: falling and climbing context are ignored
 		 */
-		printf("next action=%d direction=%d keystatus=%x ",kid->nextAction,kid->direction,key.status);
+		/*printf("next action=%d direction=%d keystatus=%x ",kid->nextAction,kid->direction,key.status);*/
 
 		/* STAY events
 		 */
@@ -250,7 +250,6 @@ int kidMove(tKid* kid,tKey key/*,tRoom room*/) {
 				kid->velocity=kid->velocity/2; /* 50% slower */
 			}
 		}
-		printf("Velocity=%d\n",kid->velocity);
 		return 1;
 	} else {
 		/* TODO: tile traspassing and validations here
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index 7d06af0..ff43b85 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -140,7 +140,7 @@ int kidMove(tKid* kid,tKey key/*,tRoom room*/) {
 		 *
 		 * Note: falling and climbing context are ignored
 		 */
-		printf("next action=%d direction=%d keystatus=%x ",kid->nextAction,kid->direction,key.status);
+		/*printf("next action=%d direction=%d keystatus=%x ",kid->nextAction,kid->direction,key.status);*/
 
 		/* STAY events
 		 */
@@ -250,7 +250,6 @@ int kidMove(tKid* kid,tKey key/*,tRoom room*/) {
 				kid->velocity=kid->velocity/2; /* 50% slower */
 			}
 		}
-		printf("Velocity=%d\n",kid->velocity);
 		return 1;
 	} else {
 		/* TODO: tile traspassing and validations here
diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c
index 10ab286..1fcbf24 100644
--- a/FP/src/ker/room.c
+++ b/FP/src/ker/room.c
@@ -116,10 +116,12 @@ void roomDrawBackground(tRoom* room) {
 	int x,y;
 	tTile tile;
 	tMap* map=room->level;
+	tTile tileNext;
 	
 	for (x=0;x<12;x++) {
 		for (y=0;y<5;y++) {
 			tile=roomGetTile(room,x,y);
+			if (x!=11) tileNext=roomGetTile(room,x+1,y);
 			if (tile.hasTorch) {
 				outputDrawBitmap(
 					roomGfx.torch->pFrames[(map->time+2*x+y)%(roomGfx.torch->frames)],
@@ -158,6 +160,13 @@ void roomDrawBackground(tRoom* room) {
 					y*TILE_H+1
 				);
 			}
+			if (tile.isWall&&(x!=11)&&(!tileNext.isWall)) {
+				outputDrawBitmap(
+					roomGfx.environment->pFrames[26],
+					x*TILE_W,
+					y*TILE_H+3
+				);
+			}
 		}
 	}
 }
@@ -165,13 +174,11 @@ void roomDrawBackground(tRoom* room) {
 void roomDrawForeground(tRoom* room) {
 	int x,y;
 	tTile tile;
-	tTile tileNext;
 	/*tMap* map=room->level;*/
 	
 	for (x=0;x<12;x++) {
 		for (y=0;y<5;y++) {
 			tile=roomGetTile(room,x,y);
-			if (x!=11) tileNext=roomGetTile(room,x+1,y);
 			if (tile.hasPillar) {
 				outputDrawBitmap(
 					roomGfx.environment->pFrames[25],
@@ -185,13 +192,6 @@ void roomDrawForeground(tRoom* room) {
 					(x-1)*TILE_W,
 					y*TILE_H+1
 				);
-				if ((x!=11)&&(!tileNext.isWall)) {
-					outputDrawBitmap(
-						roomGfx.environment->pFrames[26],
-						x*TILE_W,
-						y*TILE_H+1
-					);
-				}
 			}
 		}
 	}
diff --git a/FP/src/out/input.c b/FP/src/out/input.c
index be493c0..fad74e9 100644
--- a/FP/src/out/input.c
+++ b/FP/src/out/input.c
@@ -71,6 +71,22 @@ int editAction(tKey* key,SDLKey k) {
 	}
 	/* Normal actions */
 	if (!(key->status)) {
+		switch (k) {
+		case SDLK_u:
+			key->actionPerformed=showUp;
+			break;
+		case SDLK_h:	
+			key->actionPerformed=showLeft;
+			break;
+		case SDLK_n:	
+			key->actionPerformed=showDown;
+			break;
+		case SDLK_j:	
+			key->actionPerformed=showRight;
+			break;
+		default:
+			break;
+		}		
 	}
 	return key->actionPerformed;
 }
@@ -134,7 +150,6 @@ int inputGetEvent(tKey* key) {
 	
 	while(SDL_WaitEvent(&event))
 	{
-		/*printf("Event dropped: key status=%x action=%d\n",key->status,key->actionPerformed);*/
 		key->actionPerformed=none;
 		switch (event.type) {
 		case SDL_KEYDOWN: