• Content count

  • Joined

  • Last visited

Community Reputation

212 Neutral

About ASnogarD

  • Rank
  1. What exactly is a Game Engine?

    In short , a game engine is a set of tools that allow you to craft a game using those tools provided. It makes more sense when you actually make a small game, and then another small game... you can take a few things from your first game and use them in the second game... in C++ and SDL that would be your initiating SDL functions, blitting functions, loading art functions, probably your text functions... stuff that doesnt change that much and each game can use. The more games you make the more 'tools' (tricks, techniques, methods) you aquire and the more you put into your next game... eventually you have a nice set of tools. A Game Engine allows you to bypass that building up of your tool collection and presents you with the tools (but you do now have to learn how to use the tools as you didnt aquire them normally). A Game Engine is usually coded in a more robust manner concentrating on ensuring the interfaces provide only the actions that were intended, and not allow for unintended calls... proper encapsulation, whereas most beginner coders are more concerned with getting damn thing to run and dont worry if someone else uses the code.
  2. OpenGL book for beginner

    See if helps, its at least free and may be of the very least it may have some references for you to chase up.
  3. Well I am happy to report that the problem is sorted... as best as I can tell I am clearing every bullet and the element in the entity store that was holding the pointer to the bullet. I have a static counter counting bullets as the constructor is called, and taking one off each time the destructor is called... and the numbers are consistant, I also check the number of elements in my vector ( basic int variable counts 1 each time an element is called , reports total count after loop, then resets ) and it show 1 for the player and the number of bullets consistantly. .... plus the FPS dips when there is a LOT of bullets fired (over 98 in one trial, with keyboard repeat enabled ) but returns to the usual values when the bullets are cleared... I assume if there is a lot of bullets lost in the system it would degrade performance. I basically got the same code in but the approach was different. I basically wrote the player and bullet as thier own classes without inheriting the entity class , then got both to behave properly as seperate classes... then I created the entity class and got the player and bullet classes to inherit from it and set everything to work via polymorphic inheritance. In short I got the 2 classes to work properly before I made them into a fancy inherited polymorphic tree to eliminate inheritance issues and polymorphism bugs. Finally... now I can add enemy entities, finish off the level editor ...and a ton of other shite... why do I do this again for ?
  4. That may of been a cause for sure, however I deleted those classes to re-write them so I cant go check now... however I am pretty certain I resorted to a delete this in the cleanup after the delete Entity::EntityList[i] seemed to cause crashes, but as I tried a number of things in a rush I cant remember for certain. I will ensure that it doesnt do both in the new re-write I am busy with, thanks for the help... I do appreciate the effort, and the links .
  5. The element in the vector that held the pointer is erased after the OnCleanup() call, using : Entity::EntityList.erase(Entity::EntityList.begin() + (i --)); I was under the impression that erasing the element holding the pointer would remove the pointer from the system ? What really makes it confusing is the crash is pointing to the part of the code that control the game states ( ie menu or in game, or in the editor )... and that is pretty basic, I cant see how creating and deleting entities in the ingame state would crash the state manager... and when I remove the statemanager and all the states so the game is called directly by the main loop crashes there, but not in the for loop that runs through the EntityList vector. I am re-writing the player entity code, same stuff but checking each line more carefully ( had re-wrote the whole lot a few times and got lazy in some sections ).
  6. In brief the delete this was in a cleanup() called via a pointer to the base class of the bullets , the pointer is stored in a vector of pointers of entity object types and there is a loop that basically calls the cleanup like : Entity::EntityList[i]->OnCleanup(); It was working, I had a static counter counting each time the constructor made a object and it took one off each time the destructor was called... the destructor was called each time the OnCleanup() was called to delete this on the bullets ( ie the destructor was called each time the bullet got deleted - confirmed because I had the destructor report each time it was called). Its moot now as the code crashed out in the loop when firing, it would sometimes work for a bit then crash or crash as soon as I shoot the first bullet... it was unstable as hell. I basically deleted all the entity, player and collision classes and going to rewrite it in my own way instead of trying to adapt the tutorials entity system (its wierd the tutorial seemed to offer so much flexibility and elegant solutions to dealing with lots of entities... but on closer inspection, it seemed limited to only making 1 or 2 player entities ). edit: ym seplilign scuks.
  7. Thanks for the reply, I will look into smart pointers at some time. I got the code to delete the objects successfully with delete this , the crash seems to be caused by too many events when I press the fire button too quickly... I guess there is a problem when you pass an event too much. Do you think passing SDL_Event objects through a number of functions could cause issues ? Currently an event gets passed from the main loop, to the statemanager, to the ingame state, to the player object... if I press the fire button. *sigh* coding is such a pain when it goes wrong [img][/img] I give for now... to test if it was me mashing the fire button to get lots of bullets out.... I disabled the actual bullet create portion of the each time I fired it merely reported to my ingame console bullet fired... and didnt crash at all. So the issue is still with the entities.
  8. Update: As a test I disabled : if(Entity::EntityList[i]->Type == ENTITY_TYPE_BULLET_PLAYER) { delete Entity::EntityList[i]; } Entity::EntityList.erase(Entity::EntityList.begin() + (i --)); I re-enabled : Entity::EntityList.erase(Entity::EntityList.begin() + (i --)); to clear the element and it clears out the bullets from the game... but I cant tell if it actually removes the bullets from memory as well.... or am I just removing the pointers to the objects from the vector but not getting rid of the actual objects ? It doesnt crash the game, and the bullets are not left of the screen... just wonder if the bullet objects are still in memory ?
  9. I am using much of the framework I got from [url=""][/url] , and while its entity class is great for creating new player entities I cant get the thing to make bullet entities... least not without generating exception faults. The way to make a player entity is straight forward, declare it in the source file , load its assets when entering the in game state and clear the assets when exiting ... no problem. The bullets however pose a number of issues, I cant declare each bullet beforehand.... they need to be created dynamically so I create one each time the player fires, and store it in the entity vector like the player... and when the bullet collides with a wall it dies, so I delete it and erase the element in the vector it was stored in. Code to create a bullet : [CODE] Entity_Bullet* pBullet = new Entity_Bullet; pBullet->OnLoad(16,16,1,ENTITY_TYPE_BULLET_PLAYER); if(Facing == ENT_DIR_RIGHT) { pBullet->MoveRight = true; pBullet->MoveLeft = false; pBullet->X = X + Width; pBullet->Y = Y + (Height/2); } if(Facing == ENT_DIR_LEFT) { pBullet->MoveLeft = true; pBullet->MoveRight = false; pBullet->X = X - 20; pBullet->Y = Y + (Height/2); } Entity::EntityList.push_back(pBullet); [/CODE] The entity list is declared like this : std::vector<Entity*> Entity::EntityList; The code to remove the bullet is in the ingame state loop, where it goes through the entity vector and calls up each element. [CODE] // Move , Animate and calculate actions for ALL entities for(unsigned int i = 0; i < Entity::EntityList.size(); i++) { if(!Entity::EntityList[i]) continue; Entity::EntityList[i]->OnLoop(); // If the entity is not a player if(Entity::EntityList[i]->Type != ENTITY_TYPE_PLAYER) { // If the Entity is suppose to be destroyed if(Entity::EntityList[i]->Dead == true) { Text::AddText("Dead one here", 10, 400); Entity::EntityList[i]->OnCleanup(); if(Entity::EntityList[i]->Type == ENTITY_TYPE_BULLET_PLAYER) { delete Entity::EntityList[i]; } Entity::EntityList.erase(Entity::EntityList.begin() + (i --)); } } } [/CODE] The issue seems to be in the clearing up portion, I think there is a conflict in the vector when a few bullets are made and destroyed... I am thinking it is trying to store a bullet in a vector that was deleted but not cleared ? If I remove the delete and erase portions of the entity loop it runs without crashing, just leaves bullets all over the place. I would prefer the actual bullet class to delete the bullet during the OnCleanup() call, but using delete this crashes the game as soon as a bullet is fired, and I cant think of a way to identify the particular bullet beyond a this call. Hmm, would the bullet object go out of scope if the pointer ( or rather the element the pointer was erased ? ). Tips , ideas , advice welcome ... thanks. [i]FYI - I havent just copied the tutorials code , I have modified a number of things in the code except for portions where I like how it works, ie I havent just copy pasted someone elses code and want you to sort out the bugs.[/i]
  10. I assume the expect_string(":") is a user created function ? I tried it and if didnt recognise the function, then I did some searches for that fuction, and no luck so I assume you are saying the issue with me using the >> format is that the ":" is not allowed in the ifstream >> operator function ? I would then have to make a function that would accept that string and be acceptable to the >> opertator ? ... I'll put this issue aside, my level loads fine and displays fine with the fopen and fscanf functions.
  11. Sorry to drag ths old question out but its better than a new topic as it relates to the answers in here... I wanted to convert my fscanf calls that all the tutorials I read used to load levels, to ifstream to use the >> operators... it works in saving a level, but >> is not a recognised operator for ifstream objects... VS IDE has no issue but wont compile. example std::ifstream map(FILE); map >> oneparameter >> ":" >> secondparameter // doesnt work std::ofstream map(FILE); map << oneparameter << ":" << secondparameter // saves perfectly. to get the load part to work it seems I need to use getline with a delimiter , right ? This means I need a string buffer that needs to be converted to an int to use in the level, I need to also use a getline per parameter and the ":" to read the 3 components of a tile in my level... How is this better than FILE* map = fopen(File, "r"); fscanf(map, "%d:%d ", &oneparameter, &secondparameter); ?? It would seem to me that the old C style is more elegant than the C++ style ? I understand I could in theory overload the >> operator in ifstream to do the map >> oneparmeter (etc) style but it is still awkward compared to the older C style. Or is there a suitable C++ manner to get the same elegant style ?
  12. std::vector Question

    I think you guys are going over the top with the answer, unless I am mistaken the basic question was wether or not a vector needs to be cleared before exiting the application it was used in, not really a question about scope. I am curious as well about that, I often wonder if my code is leaving junk in the systems memory after a coding session... initially I assumed when the application ended all its resources was freed, but when I starting getting into SDL the tutorials I was following insisted in freeing the surfaces and quiting SDL before the application finished.
  13. Using cerr with Visual Studio

    Thanks for the reply , however I cant see the output... The project is a empty project file, not a Win32 console or application... would the stderr still output to a file ? I tried putting fprintf(stderr, "ERROR: Init SDL(%s)", SDL_GetError()); as a statement that will get executed even if the application runs without an error, does it need to be an actual error / crash out ?
  14. Using cerr with Visual Studio

    Bit of a silly question but I cant seem to find a proper answer to this... A lot of code snippets will use std::cerr << "Error xyz is doing shit it shouldnt" ... or something like that when a fault occurs, right. Where the heck do I see these cerr messages in the Visual Studio IDE ? There is no console where the cerr can output here, and it doesnt show on the output window either. Lots of answers to other questions about it usually slip off to re-directing the cerr output to a file, again in the console... how do I do this in VS ? I get you can use this to report errors to one pipe and cout streams to its own pipe thus not mixing up error reports with your output buffers. I would really like to be able to use cerr for sections of the code where I cant rely on the code being able to put up text to the screen... like in SDL_Init , or ttf init, or events where the init causes a crash ( had that trying to get keyboard repeat interval set ...crashed immediately and didnt get to the if init fails tell me about it portions.
  15. There simply isnt really an engine for indie MMO developers... indie and MMO dont work that well. The only MMO engine I ever heard about that is not an in house specific propriety one is the Hero engine, which was used with SW:ToR ( as a development aid, allegedly the ToR devs moved onto thier own engine later ). You can still just code some basic level, putting the whole MMO aspect aside and experiment with the features you want to add while you wait for an engine / research an engine.