Jump to content
  • Advertisement

templar_vii

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About templar_vii

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. templar_vii

    Game data container

    I guess, I ignored the rule "don't have classes that tries to do too much". Tahts an example of a terrible constructor. The "StateMachine" is a class which manges diffrent game-states and the conditions to change from one state to an other. public StateMachine( GameState gameState, // Container of the current state, the last state and the events WorldEvents worldEvents, // Helper to add or remove items into the world ResourceLoader resourceLoader, // Language-Helper to get a translatet text GameSettings gameSettings, // Options of the game List<CommandBase> commands, // All classes that gives the opurtunity fot user-interaction List<AiBase> aiAlgorithms, // Logic of AI List<WorkerBase> helpers, // Alle other helpers ServerCallbackSynchroniser serverCallbackSynchroniser, // Helper class so sync repsonses from the server to the game-Thread GameLauncher gameLauncher) // Helper class to start a battle Why the hell is "AI-Algorithms" and all the other stuff needed in a simple class like "StateMachine" ? Why not just passing the "GameState" instance? That's what I thought now by myself. I have to tell, that this is my first big game project. It started small and grown. I did some code refactoring but I never cared about splitting classes. So the design get worse and worse. Some weeks ago I started reading "Clean Code" of "Robert C Martin" and I noticed theres something bad, but I had no idea what's the solution. I very like all of your advices. If I follow them there's a chance. Thanks a lot!
  2. templar_vii

    Game data container

    That's exactly what the constructors look like in my project. My constructors have up to 12 parameters. But I guess, there's no way to pass less data. Maybe I can group some classes in a superclass. And I should better encapsulate the data access, as the "frob" has described. But it will remain confusing.
  3. templar_vii

    Game data container

    I understand. There's a lot of refactoring work, but I guess it will be worth I hope that makes my code clean enough, to publish my Project (https://www.microsoft.com/de-ch/store/p/high-treason/9wzdncrfjgpz) as open source in GitHub. Thanks a lot for your detailed explanations!
  4. templar_vii

    Game data container

    Thanks a lot for your response. But that means, you have a container, named "GameWorld" which contains all the data of the game?
  5. A big game project contains a lot of runtime data like List of all world objects List of all players Game states Viewport ... I have to pass a lot of these data to most of my classes. So I have a huge list of parameters in every constructor. What's the best practice to avoid this mass of parameters? Is it recommended to summarize all data to one class (something like "GameData") and pass this container to all methods and classes? Is there a common name for this container in game development? I'm a bit worried, because if I pass this class to all classes and methods, I get something like a global variable. Thanks a lot for your advice!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!