Exemplo n.º 1
0
 public GameEngine(
     IGraphicsService graphicsService,
     GameEntityUpdateEngine engine,
     ILogger logger)
 {
     _graphicsService    = graphicsService;
     _engine             = engine;
     _logger             = logger;
     _starSpriteProvider = new StarSpriteProvider(_graphicsService);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var logger = LoggerFactory.GetLogger();

            logger.Information("===== Запуск =====");

            using (IGraphicsService graphicsService = new GraphicsService(logger))
            {
                if (graphicsService.TryInitialize())
                {
                    var blockMoveEngine = new GameEntityUpdateEngine();
                    var gameEngine      = new GameEngine(graphicsService, blockMoveEngine, logger);

                    gameEngine.CreateNew();

                    try
                    {
                        var quit = false;

                        while (!quit)
                        {
                            while (SDL2.SDL.SDL_PollEvent(out SDL2.SDL.SDL_Event sdlEvent) != 0)
                            {
                                if (sdlEvent.type == SDL2.SDL.SDL_EventType.SDL_QUIT)
                                {
                                    quit = true;
                                    break;
                                }
                            }

                            gameEngine.Update();
                        }
                    }
                    finally
                    {
                        blockMoveEngine = null;
                    }
                }
            }

            logger.Information("===== Останов =====");
        }