git » fp-git.git » commit e41299d

step by frame

author ecalot
2004-11-05 01:21:49 UTC
committer ecalot
2004-11-05 01:21:49 UTC
parent 777f1d7c8b474ac132e6737ac914808e21ff7574

step by frame

FP/src/conf/awk/states_conf_static.awk +14 -9
FP/src/include/kernel.h +1 -1
FP/src/include/types.h +1 -0
FP/src/ker/states.c +14 -7

diff --git a/FP/src/conf/awk/states_conf_static.awk b/FP/src/conf/awk/states_conf_static.awk
index 53bbd44..0ae9d7c 100644
--- a/FP/src/conf/awk/states_conf_static.awk
+++ b/FP/src/conf/awk/states_conf_static.awk
@@ -35,6 +35,7 @@ BEGIN {
 	printf("#define STATES_MOVETYPES_ABSOLUTEFORWARD 1\n\n")
 	printf("#define STATES_MOVETYPES_RELATIVETURN 2\n\n")
 	printf("#define STATES_CONDITIONS {\\\n")
+#mawg property validation
 #	tmp="conf/statesproperties.conf"
 #	while ((getline line < tmp) > 0) {
 #		gsub(/[	 ]+/, "-",line)
@@ -77,19 +78,20 @@ BEGIN {
 		#add condition
 		currentCondition++
 		if ($2!=sprintf("%d",$2)) {
-			if (1) {      #defines[$2]) {
+			#if (1) {      #defines[$2]) {
 				if ($1~/^Map/) {
 					result=sprintf("TG_%s",$2,0)
 				} else {
 					result=sprintf("STATES_COND_%s",$2,0)
 				}
-			} else {
-				if ($2) {
-					printf("Parsing error in states.conf: Condition modifier '%s' not recognized on uncommented line %d.\n",$2,NR)>"/dev/stderr"
-					exit 22
-				}
-				result=0
-			}
+			#} else {
+			#
+			#	if ($2) {
+			#		printf("Parsing error in states.conf: Condition modifier '%s' not recognized on uncommented line %d.\n",$2,NR)>"/dev/stderr"
+			#		exit 22
+			#	}
+			#	result=0
+			#}
 		} else {
 			result=$2
 		}
@@ -101,11 +103,13 @@ BEGIN {
 			for (g=a[1];g<=a[2];g++) {
 				arrayAnimation[currentAnimation,"frame"]=g
 				arrayAnimation[currentAnimation,"flags"]=$2
+				arrayAnimation[currentAnimation,"steps"]=$2+$3
 				currentAnimation++
 			}
 		} else {
 			arrayAnimation[currentAnimation,"frame"]=$1
 			arrayAnimation[currentAnimation,"flags"]=$2
+			arrayAnimation[currentAnimation,"steps"]=$2+$3
 			currentAnimation++
 		}
 # level option
@@ -253,6 +257,7 @@ END {
 	coma=""
 	for (i=0;i<currentAnimation;i++) {
 		flags=arrayAnimation[i,"flags"]
+		steps=arrayAnimation[i,"steps"]
 		if (flags!="") {
 			coma2=""
 			flagmask=""
@@ -264,7 +269,7 @@ END {
 		} else {
 			flagmask="0"
 		}
-		printf "%s%d,%s",coma,arrayAnimation[i,"frame"],flagmask
+		printf "%s%d,%s,%d",coma,arrayAnimation[i,"frame"],flagmask,steps
 		if (i%10==9) printf("\\\n\t")
 		coma=","
 	}
diff --git a/FP/src/include/kernel.h b/FP/src/include/kernel.h
index 56a94b4..ce464db 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"
+#define FP_VERSION "0.3-pre-alpha-win-brendon"
 
 int kernel(int optionflag,int level);
 /* level=-1 is default
diff --git a/FP/src/include/types.h b/FP/src/include/types.h
index b278411..bdd1fd9 100644
--- a/FP/src/include/types.h
+++ b/FP/src/include/types.h
@@ -49,6 +49,7 @@ typedef struct { /* The state object: only struct that is not static to the stat
 	short* animation; /* list of frames for this state */
 	short* animOffset; /* position of those frames */
 	short* flags;      /* actions to be performed by each frame (make sound, press floor, etc) */
+	short* steps;      /* the number of steps each frame has to move */
 	short  currentState; /* the Id of the state the kid is */
 	short  image; /* the next image to be shown */
 	float  step; /* the number of pixels a frame has to move */
diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c
index daaabde..cb37ce9 100644
--- a/FP/src/ker/states.c
+++ b/FP/src/ker/states.c
@@ -21,17 +21,19 @@ static tsCondition statesConditionList[]=STATES_CONDITIONS;
 void stateGetAnimation(int action,tState *state/*short *frames,short** flags,float* offsets*/) {
 	tsAction* a=statesActionList+action;
 	short i=a->animSize;
-	short* j=statesAnimationList+(a->animStart*2);
+	short* j=statesAnimationList+(a->animStart*3);
 	short totaloffset=a->moveOffset;
 	/* TODO: depending on relative and absolute crop the middle frames */
 	state->frame=i;
 	state->animation=(short*)malloc(sizeof(short)*i);
+	state->steps=(short*)malloc(sizeof(short)*i);
 	state->flags=(short*)malloc(sizeof(short)*i);
 	printf("* Animsize=%d Animstart=%d. (new animation allocated) Next:\n",i,a->animStart);
-	state->step=(float)(totaloffset)/(float)(i); /* the first short is the frame */
+	state->step=(float)(totaloffset)/(float)(i); /* this is the full step to be used in case a non step walk is set TODO: delete this system */
 	while (i--) {
-		(state->animation)[i]=*(j++);
+		(state->animation)[i]=*(j++); /* the first short is the frame */
 		((state->flags)[i])=*(j++); /* the second short is the flag */
+		((state->steps)[i])=*(j++); /* the third short is the frame step */
 	}
 }
 
@@ -149,14 +151,16 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 	/*static float step;
 	static float acumLocation;*/
 	short flags;
+	short steps;
 	
 	current->frame--;
 	
 	current->image=current->animation[current->frame];
 	flags         =current->flags    [current->frame];
+	steps         =current->steps    [current->frame];
 	
 	/* BEGIN DEBUG */
-	printf("stateUpdate: animation=%d ",current->image);
+	printf("stateUpdate: animation=%d steps=%d ",current->image,steps);
 	debugShowFlag(flags);
 	/* END DEBUG */
 	
@@ -164,6 +168,7 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 		int action;
 		free(current->animation);
 		free(current->flags);
+		free(current->steps);
 		/* Find matching action */
 		action=evaluateState(current->currentState,key,kid,room);
 
@@ -174,8 +179,10 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 		current->currentState=statesActionList[action].nextStateId;
 		printf("NEW STATE: action=%d next=%d\n",action,current->currentState);
 			/* Move the kid (turn+traslate) */
+		/* TODO: code absolutestepsforward and relativestepsforward*/
 		if (kid->direction==DIR_LEFT) {
-			current->step=-current->step;
+			/*current->step=-current->step;*/
+			steps=-steps;
 			switch(statesActionList[action].moveType) {
 			case STATES_MOVETYPES_RELATIVE:
 				/*kid->location-=statesActionList[action].moveOffset;*/
@@ -204,8 +211,8 @@ short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
 		}
 		current->acumLocation=kid->location;
 	}
-	current->acumLocation+=current->step;
-	kid->location=current->acumLocation;
+	/*current->acumLocation+=current->step;*/
+	kid->location+=steps; /*current->acumLocation;*/
 	if (current->currentState<0) return current->currentState; /* if last state return exit code */
 	return flags;
 }