-------------------------------------------------------------------------- G2dEngine (g2d) fact sheet (psycho.mypage.sk, 2008) -------------------------------------------------------------------------- g2d should be modifiable by scripts, so that creating new games needs no (or at least very little) modifying of source code. primary target is to have a highly expandable 2d engine, where most 2d games could be made by limited amount of scripting. therefore the most useful stuff, which would be pain to script, should be hardcoded, and accessible through scripts. -------------------------------------------------------------------------- core classes in G2dEngine *g2d: -------------------------------------------------------------------------- AppInfo - info - information about application, potentialy useful for many different parts (mouse pos, screen res, fps, pressed keys, ...) SystemStuff - *ss - creating and mantaining window, calculating fps, relative mouse position, and other system stuff SceneManager - *sm - scene, which is rendered, cares for culling frustum, loads objects, removes, connects objects with physics GUI_Manager - *gui - simply gui, manages windows and various gui components in there InputManager - *im - processes windows messages to create info about keys being down and keys being changed (press/release) lately BindingManager - *bm - binds keys to actions, and makes it all work ScriptBind - *sb - manages gameMonkey scripts (loads and runs them), there are also all g2d scripts coded -------------------------------------------------------------------------- there are also singletons, which are accessible globaly: -------------------------------------------------------------------------- ResourceManager - returns handle for resource (id for textures, pointer for sounds, etc) SoundManager - plays sound using fmod other classes: Animation - loads texture file, cuts it into frames, loads into opengl and then manages animating Material - used for loading texture/animation, and for binding proper texture id to opengl FontManager - used by gui to load, manage and draw text ParticleSystem - simply particle system used in scene Physics - interface with box2d physics engine WebCam - takes images from camera and can kind of track objects, potentialy useful for special controling -------------------------------------------------------------------------- here are some utilities, that may be useful for programmer (and are widely used throughout the engine): -------------------------------------------------------------------------- RAD2DEG, DEG2RAD - definition of amount by which you can multiply radians to get degrees, and back, example: float radians = degrees * DEG2RAD; bool parseLine(std::vector &vOut, std::ifstream &inF) - returns next non-empty row in ifstream, pushes separate (by spaces or tabs) strings to vector of strings (see example) how to init std::ifstream: std::ifstream inFile(fname.c_str(), std::ios::in); if (!inFile) return; std::vector loadIniParam(string name) - finds row with requested string in file "ini", when you store result in variable "p", then words are strings: "p[i]" std::vector dirGetFiles(const string& strDir, const string& ext="") - returns vector of filenames in requested directory, filter for extension can be used string getClipboard() - returns text clipboard from windows string makeS(int i), string makeS(float f), string makeSf2(float f), string makeS(Vector2 v), string makeS(Vector4 v) float makeFloat(string s), int makeInt(string s), Vector2 makeV2(string s), Vector4 makeV4(string s) - converts variable into string, or string into variable string pvtos(void *pv, char t), void stopv(string s, void *pv, char t) - converts variables and strings (type can be: b(bool), c(char), i(int), f(float), v(v2), w(v3), x(v4), see source for more) float rnd(float mn, float mx), float rnd01() - returns float between min and max, and second one returns random number between 0 and 1 void swapf(float &a, float &b) - swaps float values between two variables void showMessage(const char *title, const char *error, ...) - shows windows message, can be used like printf (replaces chars in "error") void err(char *error, ...) - same as showMessage, but shorter (used often to inform user about some error) void normalizeAngleRad(float &f) - normalizes angle between 0 and 360 degrees float sinFast(float x), float cosFast(float x) - takes sin/cos from table of 1024 elements (so for whole sinusoide, there is 4096 values, that's usualy precise enough) float getdt() - returns amount of time between last and current call ValueLogger, void add(T t), void reset() - saves values into array - useful when debugging, to see last "num_values" values of variable of type "T"