git » fp-git.git » commit 7f980d8

coded absoluteonstop

author ecalot
2004-11-06 13:08:33 UTC
committer ecalot
2004-11-06 13:08:33 UTC
parent 672b1532ff024e814af99955c3897fcce96cd637

coded absoluteonstop

FP/src/conf/states/main.conf +36 -33
FP/src/conf/tiles.conf +8 -0
FP/src/ker/kid.c +0 -1
FP/src/ker/object.c +0 -1
FP/src/ker/states.c +29 -5

diff --git a/FP/src/conf/states/main.conf b/FP/src/conf/states/main.conf
index 2ae1202..73a7751 100644
--- a/FP/src/conf/states/main.conf
+++ b/FP/src/conf/states/main.conf
@@ -22,7 +22,8 @@
 # Copyright 2004, 2003 Princed Development Team
 #  Created: 15 Oct 2004
 #
-#  Author: Enrique Calot <ecalot.cod@princed.com.ar>	Rodrigo Campos Catelin <rodrigocc@gmail.com>
+#  Authors: Rodrigo Campos Catelin <rodrigocc@gmail.com>
+#           Enrique Calot <ecalot.cod@princed.com.ar>
 #
 # Note:
 #  DO NOT remove this copyright notice
@@ -37,9 +38,9 @@ normal:
 		next
 			normal
 		animation
-			16-22 
+			16-22 2
 		steps
-			relative  0
+			absoluteOnStop  8
 	
 	action            Jump
 		conditions
@@ -75,10 +76,11 @@ normal:
 		animation
 			81-93 
 			96-98
+			145 u
 			146-160
-			99 u
+			99 
 		steps
-			relative 10 #use absolute forward
+			absoluteOnStart 10
 	action            Jump up with free space up and a block in front
 		conditions
 			KeyUp                  pressed
@@ -185,7 +187,7 @@ normal:
 		steps
 			relative  0
 		animation
-			15 f
+			15 f 2
 
 	action            If there aren't more actions then the normal state is kept
 		conditions
@@ -297,11 +299,12 @@ crouched:
 			KeyDown			pressed
 			KeyForward		pressed
 		next
-			wcrouched
+			crouched
 		steps
 			relative  0
 		animation
-			120-123 p
+			120 1
+			121-123 p
 
 	action		 Stay Crouch
 		conditions
@@ -333,31 +336,31 @@ crouched:
 			relative  0
 		animation
 			121-130 p
-wcrouched: #Make the player re-press the forward key to contin
-	action Make the player re-press de forward key
-		conditions
-			KeyDown			pressed
-			KeyForward		pressed
-		next
-			wcrouched
-		steps
-			relative  0
-		animation
-			120 p
-	action  The user drop forward key
-		conditions
-			KeyDown			pressed
-		next
-			crouched
-		animation
-			120 p
-	action Get up
-		conditions
-			none
-		next
-			coruched
-		animation
-			120 p
+# wcrouched: #Make the player re-press the forward key to contin
+#	action           Make the player re-press the forward key
+#		conditions
+#			KeyDown			pressed
+#			KeyForward		pressed
+#		next
+#			wcrouched
+#		steps
+#			relative  0
+#		animation
+#			120 p
+#	action  The user drop forward key
+#		conditions
+#			KeyDown			pressed
+#		next
+#			crouched
+#		animation
+#			120 p
+#	action Get up
+#		conditions
+#			none
+#		next
+#			coruched
+#		animation
+#			120 p
 
 #title animations
 titlesjaffar:
diff --git a/FP/src/conf/tiles.conf b/FP/src/conf/tiles.conf
index e8fc2da..f97cd4d 100644
--- a/FP/src/conf/tiles.conf
+++ b/FP/src/conf/tiles.conf
@@ -40,16 +40,24 @@ tile GATE 4 gate
 gates block@1
 
 tile BTN_STUCK 5 none
+walkable
 tile BTN_DROP 6 event
+walkable
 tile TAPESTRY 7 tapest
 tile BP_BOTTOM 8 none
+walkable
 tile BP_TOP 9 none
 tile POTION 10 potion
 tile LOOSE 11 none
+walkable
 tile TAPESTRY_TOP 12 ttop
 tile MIRROR 13 none
+walkable
 tile DEBRIS 14 none
+walkable
 tile BTN_RAISE 15 event
+walkable
+dangerous
 tile EXIT_LEFT 16 none
 gates 
 
diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c
index 0fca5b0..7586643 100644
--- a/FP/src/ker/kid.c
+++ b/FP/src/ker/kid.c
@@ -134,7 +134,6 @@ tKid kidCreate() {
 void kidDraw(tKid kid) {
 	void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1];
 	/* TODO: move this -1 to each script frame */
-	printf("w=%d\n",outputGetWidth(image));
 	outputDrawBitmap(
 		image, 
 		((kid.location*32)/10)-((kid.direction==DIR_LEFT)?0:outputGetWidth(image)),
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index 0fca5b0..7586643 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -134,7 +134,6 @@ tKid kidCreate() {
 void kidDraw(tKid kid) {
 	void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1];
 	/* TODO: move this -1 to each script frame */
-	printf("w=%d\n",outputGetWidth(image));
 	outputDrawBitmap(
 		image, 
 		((kid.location*32)/10)-((kid.direction==DIR_LEFT)?0:outputGetWidth(image)),
diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c
index b020a25..fb8fa58 100644
--- a/FP/src/ker/states.c
+++ b/FP/src/ker/states.c
@@ -78,8 +78,11 @@ int evaluateCondition(int condition,tKey* key, tKid* kid, tRoom* room) {
 			STATES_CONDRESULT_TRUE:STATES_CONDRESULT_FALSE;
 	case esMapUpForward:
 		DefaultFalse(room);
-		return isInGroup(room->fore[thisTile-12+((kid->direction==DIR_LEFT)?-1:1)],room->back[thisTile-12+((kid->direction==DIR_LEFT)?-1:1)],c.argument)?
+		{
+			int t=thisTile-12+((kid->direction==DIR_LEFT)?-1:1);
+		return isInGroup(room->fore[t],room->back[t],c.argument)?
 			STATES_CONDRESULT_TRUE:STATES_CONDRESULT_FALSE;
+		}
 	case esMapUp:
 		DefaultFalse(room);
 		return isInGroup(room->fore[thisTile-12],room->back[thisTile-12],c.argument)?
@@ -197,14 +200,35 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 			else
 				kid->location-=statesActionList[action].moveOffset;
 			break;
-		case STATES_MOVETYPES_ABSOLUTEONSTOP:
+		case STATES_MOVETYPES_ABSOLUTEONSTOP: {
 			/* AbsoluteOnStop (x)
 			 * Deletes frames (in the middle) to make sure that, at the end of the animation,
 			 * the kid had moved only x step units from the first forward tile change
 			 * if there is a lack of movements by frame it stops before reaching it.
 			 */
-
+			/* 1) calculate the number of frames the guy will move */
+			int accumulate=0;
+			int i,j;
+			int from,to;
+			/* First iteration: determine i=number of frames not cropped */
+			for (i=0;(i<current->frame)&&(accumulate<statesActionList[action].moveOffset);i++) {
+				accumulate+=current->steps[alternate(i,current->frame)];
+			}
+			for (j=0;j<i;j++) {
+				from=alternate(j,current->frame);
+				to=alternate(j,i);
+				if (j%2) {
+					/* the first frames are ok, so I'll fix the last frames */
+					printf("from=%d to=%d ok\n",from,to);
+					current->animation[to]=current->animation[from];
+					current->flags[to]=current->flags[from];
+					current->steps[to]=current->steps[from];
+				}
+			}
+			printf("total frames=%d number of frames to be used=%d. wanted movement=%d movement to be performed=%d\n",current->frame,i,statesActionList[action].moveOffset,accumulate);
+			current->frame=i; /* now the last frames are moved, crop the animation */
 			break;
+			}
 		case STATES_MOVETYPES_RELATIVETURN:
 			/* relative but turning */
 			kid->direction=(kid->direction==DIR_LEFT)?DIR_RIGHT:DIR_LEFT;
@@ -222,7 +246,7 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 	
 	kid->location+=(kid->direction==DIR_LEFT)?-steps:steps;
 
-
+/*
 	{
 		int jj;
 		for (jj=0;jj<5;jj++) {
@@ -232,7 +256,7 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 		}
 		printf("\n");
 	}
-
+*/
 
 	
 	if (current->currentState<0) return current->currentState; /* if last state return exit code */