git » fp-git.git » commit fb70a50

states interpreter

author ecalot
2004-10-15 23:37:38 UTC
committer ecalot
2004-10-15 23:37:38 UTC
parent ec7d9ea222f51632613f03f6cecf4866f0bfa648

states interpreter

FP/src/include/states.h +60 -0

diff --git a/FP/src/include/states.h b/FP/src/include/states.h
new file mode 100644
index 0000000..39beacd
--- /dev/null
+++ b/FP/src/include/states.h
@@ -0,0 +1,60 @@
+
+
+tsCondition stateGetCondition(tsState state, int number);
+/* Returns a condition number "number" or NULL if there are no more conditions */
+
+tsConditionType stateGetConditionType(tsCondition condition);
+/* returns condition type */
+
+int stateEvaluateKeyCondition(tKey* keyState);
+int stateEvaluateMapCondition(tRoom* room,int x, int y);
+/* returns 0 if the condition if false for the current position or keys */
+
+tsAction stateGetAction(tsCondition condition);
+/* get the action related to the given condition to be performed in case that it is true */
+
+
+
+/* Start here */
+
+/* public object */
+struct tState { /* The state object: only struct that is not static to the state class */
+	int frame; /* when zero, animation is released and the next state is taken */
+	void** animation;
+	tsState* currentState;
+}
+
+/* public functions interface */
+tState* createState(tKid* kid,tMap* map);
+void updateState(tState* current,tKid* kid,tMap* map,tKey* key); /* This function should return the image frame
+																													and actions to be performed by this call */
+
+/* privates */
+
+tsAction createInitialState(tKid* kid,tMap* map); 
+tsAction evaluateState(tState* current,tKid* kid,tMap* map); 
+
+typedef enum {esKeyUp,esKeyDown,esKeyForward,esKeyBack,esShift,esMapUp,esMapDown,esMapForward,esMapBack,esMapIn,esForwardTileNearerThan,esForwardTileFarThan,esInScreen,esInLevel,esForwardChangeToScreen,esLast=0}tsConditionType;
+
+
+typedef enum {esDangerous,esNone,esWalk,esPotion,esSword,esMirror,esNotApplicable=0}tsTileType;
+typedef enum {esRelative,esForwardTile}tsMoveOffset;
+
+struct tsCondition {
+	tsConditionType type;
+	union {
+		tsTileType tile;
+		char units; 
+		char screen; 
+		char level; 
+	}
+}
+
+struct tsAction {
+	short tsConditionPointer;
+	tsMoveOffset moveOffset;
+	char	moveUnits;
+	short tsStatePointer;
+}
+
+