/// parser for masses, particles, players, level specific settings #ifndef __ENGINE_H__ #define __ENGINE_H__ #include "mass.h" //#include "particle.h" #ifndef __PARTICLE__ typedef struct _Particle_ Particle; #endif // So player id is '0'-'9' only one char #define MAX_PLAYERS 10 // A script will parse this in the build process: // Comments starting with % are members that will be loaded/reset typedef struct { //TODO: save this structure; remember/add player viewport position // some options in here might even change during game //% boolean % default=0 % [player movement] turn with left/right, accelerate with up/down (instead of bomberman style controls) int firstPersonMovement : 1; //% int % min=-1,max=255,default=0 % [player movement] when using firstPersonMovement, this is the initial heading int startHeading; //% int % default=20 % [player movement] how strong the player moves his viewport himself (negative values possible) int viewportForce; //% int % min=0,default=40 % [player movement] how much friction there is when the viewport moves int viewportFriction; //% boolean % default=1 % [engine] calculate/move all masses instead of only visible ones (aka FieldFreeze) int calculateInvisible : 1; //% boolean % default=0 % [goal] whether a player without a body mass (a mass with playerBody=true) is considered dead int playerNeedsBodyMass : 1; //% enum % exit=DA_EXIT,ignore=DA_IGNORE,recreate=DA_RECREATE % what happens if the player dies (exit, ignore or recreate) (FIXME: not yet implemented) enum { DA_EXIT, DA_IGNORE, DA_RECREATE } playerDeathAction; //% string % default=PlaceableMass1NotSet % mass class placeable while editing the level char * placeableMass1; //% string % default=PlaceableMass2NotSet % as above char * placeableMass2; //% string % default=PlaceableMass3NotSet % char * placeableMass3; //% string % default=PlaceableMass4NotSet % char * placeableMass4; //% string % default=PlaceableMass5NotSet % char * placeableMass5; //% string % default=PlaceableMass6NotSet % char * placeableMass6; //% string % default=PlaceableMass7NotSet % char * placeableMass7; //% string % default=PlaceableMass8NotSet % char * placeableMass8; //% string % default=PlaceableMass9NotSet % char * placeableMass9; } EngineOptions; extern EngineOptions engine; typedef struct { // inputs (read-only, modified when an engine command is received) int exists; // a player may not exist or suddenly be removed (eg network troubles) int movex; // -1, 0, +1 (keyboard/network input) int movey; int button1; // 0 or 1 int button2; // player game status (read/write everywhere inside the engine) int heading; // direction where the player looks at Point force; // vector where the player pushes towards (could move sideways) int force_abs; // absolute value of the above Point pos256; // camera field position * 256 (defines thawn field, too) Point velocity; // (256, 0) means move 1 pixel right per round int bodies; // reference-counting the owned m->playerBody masses } Player; extern Player player[MAX_PLAYERS]; extern void InitEngine(); extern void FreeEngine(); extern char * EngineLine(int indent, char * name, char * value); extern int CountPlayers(void); extern Point PlayerPos(Player * p); // player body reference counting extern void PlayerFoundBody(int id); extern void PlayerLostBody(int id); extern Mass * MassClassByName(char * class); extern Particle * ParticleClassByName(char * class); // dump difference to base class extern void DumpMassProperties(FILE * f, Mass * m); extern void DumpParticleProperties(FILE * f, Particle * pt); // same, but include creation statement extern void DumpMassWithBody(FILE * f, Mass * m); extern void DumpParticleWithBody(FILE * f, Particle * pt); /* Considering network games, randarea() MUST be used for all in-game random decisions which have to go synchronous on all clients; do not use in display code! */ extern int randarea(int smallest, int size); extern void randareaseed(int seed); extern char * malloc_ChooseStringFromList(char * s, char sep); extern void SaveGame(char * filename); // calculating only, displaying is done seperately // TODO: maybe this should be an engine command instead extern void NextGameFrame(void); #endif