Update 10

I have tried to port the game to SDL2, but it is more difficult than expected. At first I have replaced all SFML’s functions with SDL’s functions but it does not work because sometimes the object to draw is deleted after calling the draw method, in SDL you need to render the texture to the renderer with SDL_RenderCopy or SDL_RenderCopyEx if you want to  rotate the sprite, but the object cannot be deleted before SDL_RenderPresent  because SDL_RenderCopy take addresses in parameter. So I have allocated theses objects on the heap with raw pointers. But this time the problem was after using delete to clear some pointers, the memories of other objects got corrupted. So I have replaced raw pointers with shared pointers it is better now, but there is still some weird bugs so I will continue to use the SFML version this week and come back to SDL later.

Leave a Reply

Your email address will not be published. Required fields are marked *