Ejemplo n.º 1
0
        public MainPage(GameManager gameManager)
        {
            Window.Current.VisibilityChanged += CurrentOnVisibilityChanged;
            Window.Current.SizeChanged += WindowSizeChanged;
            InitializeComponent();
            ResizeAll(new Size(Window.Current.Bounds.Width, Window.Current.Bounds.Height));

            _buttonsDictionary = new Dictionary<InputType, Border>
                                    {
                                        {InputType.Space, SpaceButton},
                                        {InputType.Up, UpArrowButton},
                                        {InputType.Down, DownArrowButton},
                                        {InputType.Left, LeftArrowButton},
                                        {InputType.Right, RightArrowButton},
                                        {InputType.Pause, MenuButton}
                                    };

            _buttonsLastColors = new Dictionary<Border, Color>
                                    {
                                        {SpaceButton,  Colors.White},
                                        {UpArrowButton, Colors.White},
                                        {DownArrowButton, Colors.White},
                                        {LeftArrowButton, Colors.White},
                                        {RightArrowButton, Colors.White},
                                        {MenuButton, Colors.White}
                                    };

            _gameManager = gameManager;
        }
Ejemplo n.º 2
0
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create Game Manager
            _gameManager = new GameManager();

            // Place the frame in the current Window and ensure that it is active
            _mainPage = new MainPage(_gameManager);
            Window.Current.Content = _mainPage;
            Window.Current.Activate();

            // Safely dispose any previous instance
            // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC)
            _deviceManager = new DeviceManager();

            // New CubeRenderer
            _renderer = new Renderer(_gameManager);
            //    var fpsRenderer = new FpsRenderer();

            // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget)
            _target = new SwapChainBackgroundPanelTarget(_mainPage);

            // Add Initializer to device manager
            _deviceManager.OnInitialize += _target.Initialize;
            _deviceManager.OnInitialize += _renderer.Initialize;
             //   _deviceManager.OnInitialize += fpsRenderer.Initialize;

            // Render the cube within the CoreWindow
            _target.OnRender += _renderer.Render;
             //   _target.OnRender += fpsRenderer.Render;

            // Initialize the device manager and all registered deviceManager.OnInitialize
            _deviceManager.Initialize(DisplayProperties.LogicalDpi);

            // Setup rendering callback
            CompositionTarget.Rendering += CompositionTargetRendering;

            // Callback on DpiChanged
            DisplayProperties.LogicalDpiChanged += DisplayPropertiesLogicalDpiChanged;

            // Create colors which will be use in all games.
            GamesParams.CreateColors(_deviceManager);

            // Create Game Manager
            _gameManager.Create(_mainPage, _renderer);

            // And start first game
            _gameManager.StartSession();
        }
Ejemplo n.º 3
0
 protected BaseGame(GameManager gameManager, float gameMaxTime)
 {
     _gameManager = gameManager;
     _gameMaxTime = gameMaxTime;
     _gameTime = 0;
 }
Ejemplo n.º 4
0
 public Renderer(GameManager gameManager)
 {
     _gameManager = gameManager;
     Show = true;
 }