[quote name='Wooh' timestamp='1311775331' post='4841098']
You are passing a lot of things by value. For example in GameEngine::addSprite the sprite is passed by value which means that the sprite you have in addSprite is a copy of the sprite you passed from the main function. You may consider passing by pointer (Sprite* s) or by reference (Sprite& s). When you do spriteField.push_back(s) a copy of s will be stored in spriteField. You may want to store pointers to sprites in spriteField instead (std::vector<Sprite*>). The problem when using copies is that when you change the copy the original object will not be affected. You update the sprites in spriteField but blit the sprites in main which is not the same sprites. Another problem with making copies of large classes like Image is that it is probably slow, unless you have implemented something special.
I also noticed a few other things that is unrelated to the problem you have.
- checkFPS() always return 33 (if we assume that the two calls to SDL_GetTicks() return the same value). The function looks more complicated so it looks like you trying to do something else.
- in update() you call both SDL_Flip(screen) and SDL_UpdateRect(screen, 0, 0, 0, 0). These two calls do the same thing so one can be removed.
- GameEngine::exit() is called from both events() and from main. Why not place the code that is in exit() in the the GameEngine destructor?
Thanks for the tip! I am having a hard time figuring out pointers, are so used to coding in Java that I becomes difficult to use pointers for me. But you sure have a good point. I'll try to send the pointer to the things I am sending instead of a copy. And then see what happens.
And to other issues you mention. checkFps() should controll the framerate but if it allways returns 33 then It does not seem to do that.
The update function works, maybe I will change it later if I feel like it but it does not affect the program negatively as far as I know.
Good point about GameEngine::exit(), I'll do that
[/quote]
Ok, I have fixed checkFPS() and done as you suggested with the update() and the deconstructor. It all works perfectly. Have barely started the major changes you suggest but I'm getting there.