• Content count

  • Joined

  • Last visited

Community Reputation

187 Neutral

About FireNet

  • Rank
  1. Dynamic 2D lights

    An article on dynamic 2d soft shadows [url=""]http://archive.gamed...s/2dsoftshadow/[/url]
  2. You could use [url=""]PixelToaster[/url] which is designed to be used for software rendering. Basically it provides you with a framebuffer and takes care of all the inner details. [quote]PixelToaster is a library for C++ programmers who want to write their own software rendering routines, reading and writing to an array of pixels. You choose between high dynamic range floating point color or 32 bit truecolor and pixeltoaster converts to the native display format automatically. You also get basic keyboard and mouse input and a high resolution timer. [/quote] [url=""][/url]
  3. There are many ways you could go about doing this. The simplest I can think of would be to have a list of states, with only last one being updated and rendered. push_back the intro state intro states runs for 10 seconds intro state after 10 seconds push_back menu state menu state can push_back game states At end of a game, pop_back game state, menu state becomes the current state Take a look at Managing Game States in C++ Example: Emilio's Flight It uses a state manager similar to the one I described above. The intro state runs a few timed objects and on the player pressing enter pushes a new state onto the state list. The intro state then marks itself as over, and is safely deleted in the garbage collection phase of the state manager. Handling memory is an issue. If you are putting pointers to states in std::list or std::vector consider using boost::shared_ptr rather than raw pointers.
  4. MultiStream's problem

    When you are switching... are you loading a new sound file?
  5. Engine design and resources

    I use two template classes to handle my resources. The first one is a Resource Loader class that handles loading a valid resource. The other is of course the Resource Manager which ensures only one instance of resource is loaded. template<typename RES_ID,typename RES> class ResourceLoader { public: bool Load(); bool Unload(); } template<typename RES_ID, typename RES, typename RES_LOADER> class ResourceManager { public: bool Load(RES_ID &x); //Load a resource bool Get(); //Get last resource searched for or loaded bool GetP(); //Get pointer to above bool Have(RES_ID &x); //Check if a resource is loaded bool Unload(RES_ID &x); //unload said resource } Here's my c++ implementation of it #ifndef _MS_UTIL_RESOURCE_H_ #define _MS_UTIL_RESOURCE_H_ /*Simple Resource Manager Template*/ #include <string> #include <map> #include <iterator> namespace STICK { //!class GenResLoader /* \brief Format for a resource loader */ template<typename RESOURCE_ID, typename RESOURCE> class GenResLoader { public: virtual bool Load(const RESOURCE_ID &, const RESOURCE_ID &, RESOURCE &){return false;} virtual bool LoadNullResource(const RESOURCE_ID &, RESOURCE &){return false;} //virtual bool Unload(RESOURCE &){return false;} bool fileIsValid(std::string filepath) { std::fstream fin;,std::ios::in); if( fin.is_open() ) { fin.close(); return true; } fin.close(); return false; } protected: //std::string path; }; //!class GenResManager /* \brief This class is meant to be used internally, so main objects are public RESOURCE Recommended: A container which contains a [pointer to data or an id] and some some info to describe the properties of the resource RESOURCE_ID A unique way to identify a resource, like a file name RESOURCE_LOADER A class which can load and unload resouces Members required: bool Load(const RESOURCE_ID,RESOURCE) bool Unload(RESOURCE) */ //Some way to uniquely id a res, a res object, a class to load it template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> class GenResManager : public RESOURCE_LOADER { public: class RESOURCE_1 { public: RESOURCE res; int count; }; bool Load(const RESOURCE_ID &); //!< Will attempt to gain resource from memory/file(true=sucess) RESOURCE LoadGet(const RESOURCE_ID &); //!< Load and returns a resource (even when said resource is not loaded) RESOURCE* LoadGetP(const RESOURCE_ID &); //!< Load and returns a resource (even when said resource is not loaded) bool Unload(const RESOURCE_ID &); //!< Will attempt to unload memory bool Have(const RESOURCE_ID &); //!< Searches for a loaded resource RESOURCE Get(); //!< Gives last loaded/found resource RESOURCE* GetP(); //!< Gives last loaded/found resource RESOURCE Get(unsigned int); //!< Gives resource by internal list id (-1 = last resource) bool Add(const RESOURCE_ID &,const RESOURCE*); //!< Add a resource with id to internal list void Path(RESOURCE_ID pth, RESOURCE_ID def_pth) { path = pth; path_default = def_pth; } //Resources Constructs std::map<RESOURCE_ID,RESOURCE_1> resList; //!< Loaded resources list typename std::map<RESOURCE_ID,RESOURCE_1>::iterator resLast; //!< Last Find typename std::map<RESOURCE_ID,RESOURCE_1>::iterator find; //Path RESOURCE_ID path; RESOURCE_ID path_default; GenResManager() { RESOURCE res; RESOURCE_ID res_id; RESOURCE_LOADER::LoadNullResource(res_id,res); Add(res_id,&res); } }; template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> bool GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::Load(const RESOURCE_ID &id) { if(Have(id)) { resLast->second.count++; return true; } else { RESOURCE res; if(RESOURCE_LOADER::Load(id,path,res) || RESOURCE_LOADER::Load(id,path_default,res)) { Add(id,&res); return true; } else { return false; } } //return false; } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> RESOURCE GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::LoadGet(const RESOURCE_ID &id) { Load(id); return Get(); } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> RESOURCE* GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::LoadGetP(const RESOURCE_ID &id) { Load(id); return GetP(); } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> bool GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::Unload(const RESOURCE_ID &id) { find = resList.find(id); if(find == resMap.end())return false; if(find == resLast) { resLast = resList.begin(); } find->second.count -= 1; if(find->second.count > 0) { //Because there are other users dont remove it from the list return true; } RESOURCE_LOADER::Unload(find->second.res); resList.erase(find); return true; } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> bool GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::Have(const RESOURCE_ID &id) { find = resList.find(id); if( find != resList.end() ) { resLast = find; return true; } return false; } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> RESOURCE GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::Get() { return resLast->second.res; } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> RESOURCE* GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::GetP() { return &(resLast->second.res); } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> RESOURCE GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::Get(unsigned int arry_id) { return (resList.begin()+arry_id)->second.res; } template<typename RESOURCE_ID,typename RESOURCE,typename RESOURCE_LOADER> bool GenResManager<RESOURCE_ID,RESOURCE,RESOURCE_LOADER>::Add(const RESOURCE_ID &id,const RESOURCE *res) { RESOURCE_1 res_cont = {*(res),1}; resLast = resList.insert( resList.end(),std::pair<RESOURCE_ID,RESOURCE_1>(id,res_cont) ); //resLast = resList.begin()+; return true; } } #endif The resource loader class is for providing a standard way to load any resource. You can inherit the loader for every type of resource you want to load (or create a class with functions of the same name C++ the resource manager template does not really care along as you have Load() ....) LoadNullResource is for having a default resource when no resource has been loaded before... (preferably generated) The resource id can be any way to uniquely identify a resource, usually std::string for a file name. It can be also be a class, for a font which has font_name and font_size. You will have to overload the comparison operator in such a class though. This will be required by std::map to compare resource ids. The Manager template can do some nifty stuff like have multiple paths for a resource and handle any type of data without trouble as long as a few conditions are satisfied. Word of warning though, I've not done the Unload()... simply because I am currently using it for a game in which I don't expect to unload anything till the game is closed. Another important thing to watch out for is the copying of resources... the manager does blind copies using the assignment operator and expects the resource class to handle efficient copying and management of memory for a single resource. Working with classes rather than pointers made it much easier to code. When resources are destroyed, the destructor can take care of freeing memory automatically. Smart pointers would be a good to use on dynamically allocated memory. Usage Example (for SFML Image class) #ifndef _MS_RESOURCE_IMAGE_H_ #define _MS_RESOURCE_IMAGE_H_ #include "engine.h" namespace STICK { class ImageLoader : public STICK::GenResLoader<std::string,sf::Image> { public: bool Load(const std::string file , const std::string path, sf::Image &Image) { std::string filepath = path+file; if( fileIsValid(filepath) ) { return Image.LoadFromFile( filepath ); } return false; } bool LoadNullResource(const std::string &file, sf::Image &Image) { Image.Create(32,32,sf::Color(255,0,255,100)); return true; } }; //Singleton template based on class ImageManager : public CSingleton<ImageManager>, public STICK::GenResManager<std::string,sf::Image,ImageLoader> { public: friend CSingleton<ImageManager>; static ImageManager* CreateInstance(std::string _path,std::string _path_default) { ImageManager* inst = ImageManager::Instance(); inst->Path(_path,_path_default); return inst; } private: ImageManager(){}; ~ImageManager(){}; }; } #endif Init, Usage of manager and Deinit //Image Resource Manager STICK::ImageManager* image = STICK::ImageManager::CreateInstance(CONFIG::path_image,CONFIG::default_path_image); //Load image std::string icon_file = "icon.png"; sf::Image *icon = ImageManager::Instance()->LoadGetP(icon_file.c_str()); //Deinit the manager image->DestroyInstance(); //Pastebin Link for resource manager class //original skeleton template
  6. Raknet vs OpenTNL vs ???

    Try zoidcom... It has a fair amount of documentation and seems to be easy to use. I will be using it for a 2d game I am working on atm... Quote: The Zoidcom network library is a high-level, UDP based networking library providing features for automatic replication of gameobjects and synchronization of their states over a network connection in a highly bandwidth efficient manner. This is achieved by multiplexing and demultiplexing object information from and into bitstreams, which make it easily possible to avoid sending redundant data. Bools only take one single bit, integers and floats are stripped down to as many bits as needed.
  7. 2D Graphics - Best library?

    You can also use FreeGLUT to handle your window creation and input. It's the same as glut... You will still be working with OpenGL. The problem with DX is that you will have to download the SDK, set it up and use a bunch of code to set it up. OpenGL has a much simpler API, and as you are already familiar with it you can get coding your game faster. A sprite can be a texture mapped quad, so OpenGL can handled sprites just fine. You can also use an alpha channel in your images for transparent or translucent areas, just make sure you setup the blending properly. In any case since you are in the beginner's forum, the choice between DX or OGL is a simple one.... go with what easiest for you... - SFML is neat and does a fair amount of load lifting for you. I've been going over it documents and will be using it in a project I am working on. But in my opinion if you are just starting out, it's a lot more fun to do things yourself.... you dont have any time constraints and you get to learn a lot of things about the important background details.
  8. Game Development Libraries

    Quote:Original post by Falling Sky Just for the record, you should learn the language you want to use BEFORE you try to make a game with it. Extremely true, and learning the language, at least all the the basics of C++ and a little bit about STL will allow you to code a lot more efficiently. Otherwise you would be doing voodoo, doing things without really knowing what is going on and not being able to take full advantage of the tools available to you. However it does not mean you can't code a game while you are learning C++, just make sure they are small. Also if you are using a framework or an engine, there is an extra bit learning to use it. If you are not familiar with C++, keep the 3rd party stuff to a minimum as you are starting out. Just use GLUT, and stick to coding a simple game rather than coding a full game with everything. GLUT will give you rendering via opengl and input, pretty much all you need to make a simple game. And using GLUT is fairly trivial, just a few lines of code of init and you can be off making games.
  9. Game Development Libraries

    If you need 2D you could try: Gorgon - Hge - I've not used any of these yet :-P I am also working on the releasing framework I've been using as a starting point for my 2d projects. I only put it up a few hours ago, so the SVN has only the Video class. If you are using Visual Studio 2008, comes with .libs and headers for any external libs used. It's aimed at only doing the boring stuff of setting up the project, and initializing anything required. From then on you would be dealing with the actual libraries and their api, those some nice helpers would be provided. Take a look at it in a few days ;-) [Edited by - FireNet on January 6, 2009 10:55:32 PM]
  10. tile too big

    You should try a few tutorials for making seamless tiles
  11. Game Design in C++

    Yea, make it sleep for a bit. Use getch() to make it wait till a key is pressed. You will have to include <conio.h> Or from look at the second lesson's code //Wait 2 seconds SDL_Delay( 2000 ); Increase 2000 to a higher value
  12. Aerial Attack-Feedback

    The game is fine, but the controls are seriously messed up and hard. I like most people just wanted to shoot when I first tried the game. I kept hitting space, left click, alt,ctrl and nothing happened ...... I was reduced to dodging bullets and enemies. It was fun though. I even found that hitting B sent out a bomb while I was desperately hitting keys. The game is fun to play though... Insanely weak weapons make dodging a required skill, but a little more power would not hurt. Kinda difficult to take out even the basic enemies. As a far as bugs go, in full screen mode, I can see the game area , but the rest of the screen is a flashing grey area :P.
  13. First of all, I recommend you take the time to use floats in your ghosts(if you have not already).Box2D works on floats so you will find it a lot easier to use the data it gives you. When I did a pac-man clone (no physics), I took the vector from start to destination and scaled it by the speed multiplied by delta time (milliseconds). Something like: Vec Pos; Vec Dest; Vec Speed; Vec move = Dest - Pos; move *= speed * delta_time pos += move; if( abs(dest.x,y - pos.x,y) <= float_range)choose_next_node(); This would make the ghost move from point A to B as long as delta time was below 1. The next node would be targeted when the sprite was within distance from the target location. This would easily handle any small skips the sprite took, if it missed the exact location. Otherwise if delta time was >1 it would skip the target and go hit a wall. It would of course comeback, since a vector is being calculated before every move. For me the whole thing was just an exercise in A* with only ghosts running around to random targets so I didn't really care about how accurate the locations of the ghosts were. There were no walls, just an 2D array of ints which represented open/close area. You could use a similar method to push your ghosts by adding an impulse/force to the body and stopping it when it reaches within certain range to a node target. The you could set the position to the exact point on the node, before moving it to the next. You can use tweening move an object from one location to another. Adding a impulse or force to an object is somewhat like shooting a bullet and hope it reaches it's destination. But it you are happy to what it mostly follow the path then it should work out fine. Also looking at the programming faq for box2d will give you a few pointers. [Edited by - FireNet on January 6, 2009 12:28:19 PM]
  14. wOW I did just miss the global keyword. Darn. All that searching and trails. Thanks a lot and thanks for the tip ;) (v1.25b is what i used (latest atm))
  15. I been trying to get a simple int value from the script and i've been having little success gmMachine gm; gmTableObject *Gtable; gmVariable var; cout<<"\n->Compile Ret="<<gmLoadAndExecuteScript(gm,"../data/")<<endl; handleErrors(gm); Gtable = gm.GetGlobals(); var = Gtable->Get(&gm,"svar"); svar = 1013; I get 0 all the time and the object type is GM_NULL... What am i doing wrong? How can i get a value of a var easily?