Hi,

I'm working on Wormux source code. I try to kill all (I said ALL!) global 
variarbles.

I choosed to move camera, action_handler, game_mode, ... to GameLoop class 
(because it's the center class of the game). But there is no more "game_loop" 
global variable, so each class have its own protected/private reference to 
the instance. Example of Camera class:

------------------------ 8< --------------------------------------------
class GameLoop;

class Camera
{
  GameLoop &game_loop;
public:
  Camera(GameLoop &game_loop);
  ...
};

Camera::Camera(GameLoop &p_game_loop) : game_loop(p_game_loop)
{ ... }
------------------------ 8< --------------------------------------------

I removed, now useless, namespace Wormux.

I changed some names:
- instance curseur_ver => game_loop.cursor
- class ImagesParSeconde => FramePerSecond
- ...

I moved some functions:
- ActiveCharacter() => game_loop.ActiveCharacter()
- ActiveTeam() => game_loop.ActiveTeam()
- ...

I changed ResourceManager mechanism: LoadImage and LoadSprite are part of 
Profile and not ResourceManager, which is more logic!

I splitted Sprite to BasicSprite (not animated) and Sprite (animated) because 
BasicSprite is used in menu (for buttons) and Sprite need to access world to 
update the graphic cache.

I splitted Font to Font and GameFont because Font is used in Menu when 
game_loop doesn't exit (and GameFont needs world.ToRedrawOnScreen). Same with 
Text and GameText.

I splitted Profile to Profile and GameProfile. Profile can only load Image and 
BasicSprite. GameProfile inherits from Profile and can load Sprite.

I changed constructor of Text => Text(std::string, Font&, SDL_Color), it was 
Text(std::string, SDL_Color, Font*).

Menu does create their own fonts. Game fonts are game_loop.font.big, 
game_loop.font.small, game_loop.font.normal, ...

I didn't finish my patch, it's a really huge work! "svn diff|wc -l" say 
+15.000 lines :-P

*The* question: should I create a "0.7" branch, and commit my patch to trunk 
or ... just commit ? :-)

I can't wait 0.7 release because my local repository will be too old and merge 
current svn with my local directory will be a very hard work :-P

Bye, Haypo

Répondre à