Some game example

Jul 6, 2011 at 5:46 PM

Hi,
is it possible to see nuclex in action in some real project? I mean in some really real project with game state manager, gameplay and with proper way of using services and in the best case with NInject for dependenci injection.
I try to figure out best solution how to setup everything together. To be more specific, let's imagine I have screen manager from Nuclex, gameplay screen with some logic and player and enemies inside it. How should I pass for example graphic service through all these layers into player/enemy to makes them able to draw themselfs. I would like to create everithing as modular as posible. Some example of real project will be really helpfull for me.
In past, I created services with XNA's build in sevice container, but passing them by constructor parameters seems to be better solution for me. And it should be prepared to DI container in future.
Thanks for any tips and knowledge you will provide
Lukas 

Jul 7, 2011 at 12:44 AM

I'll share some code when I get finished with my game! :D The code probably won't be pretty and it's a card game so it may not be that helpful, but it'll use the Nuclex Framework intensively. If I ever come to understand the Nuclex Framework that well, I may even write a bunch of documentation on it! XD

Jul 8, 2011 at 7:19 AM

Every open source code is helpful, thanks.

Is it right to have NInject kernel in every GameState class? Becouse I need to create other GameStates and some entities inside them, and passing every service through constructor parameter going to be a big mess. But using kernel to create objects in lots of places doesn't look good to me either. Maybe create some class like service container would do the trick, but I use build in service container in my previous projects and I would like to avoid this technique.

Coordinator
Jul 8, 2011 at 8:47 AM

It won't hurt to hand Ninject around everywhere, but it certainly isn't ideal. Most developers using IoC containers in other projects prefer accessing their container via IServiceProvider or IServiceLocator (Microsoft P&P).

I think the case of game states is very much like it is with ViewModels in MVVM or Presenters in MVP and have chosen the same solution in my game: I have an IGameStateProvider that constructs new game states that my game states use to look up or create other game states.