Pages

Sunday, February 20, 2011

Code::Blocks(11) RPG 1 - Tileset and maps(4) Cleaning up

I have been speaking with a good friend about the project , he has told me about many things that should be changed to prevent errors and to improve the code so i have worked on it before going any further in the tutorials so here is a list of things i have changed:

  1. I have removed the reference to the engine destructor, c++ calls it automatically so there is no need to do that, in fact my code made some strange errors when closing the app randomly, now i know why...
  2. I have removed the checking of NULL pointers in the SDL_FreeSurface() the function can handle it, so there is no need of doing that.
  3. In the SDL_SetColorKey i was using the screen format, shouldn't do that, instead i should use tileset format to prevent type mismatch...
  4. LoadTileset() should use const char* instead the char* i was using
  5. I have split UpdateMouse() function, now there is a DrawMouse() function that just draws the mouse, i have taken out the code for handling the mouse and button movement  i have also changed the getmousestate function for the sdl_event handling, now it's smoother.
Thanks to "Jonny D" >  http://code.bluedinosaurs.com/
He owes a good place with interesting tutorials (c++, sdl and many more things)for beginners and for experienced people too!

Bye!

No comments: