예제 #1
0
        public void LoadContent()
        {
            _spriteBatch = new SpriteBatch(_graphics);

            _world = new StaticEntityWorld(_game.Services);

            var pp = _graphics.PresentationParameters;
            _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight));
            _cameraNode = _world.Scene.Root.CreateChild("Camera");
            _cameraNode.Position = new Vector3(_camera.ScreenSize / 2.0f, 0.0f);
            _cameraNode.Scale = new Vector3(.5f);
            _cameraNode.Attach(_camera);

            // Create the tile map.
            _terrain = new Terrain(new Vector2(102.4f, 102.4f), 51.2f, 9);
            _terrain.DebugEnabled = true;
            _world.Add(_terrain);

            // Create the circle brush.
            _circleBrush = new CircleBrush(2.5f);

            _circleBrushNode = _world.Scene.CreateSceneNode();
            _circleBrushNode.Attach(new CircleRenderable(2.5f, 64)
            {
                Color = Vector3.One
            });
        }
예제 #2
0
        public void LoadContent()
        {
            _spriteBatch = new SpriteBatch(_graphics);
            _world = new DynamicEntityWorld(_game.Services);
            var pp = _graphics.PresentationParameters;

            _debugView = new DebugViewXNA(_world.PhysicsWorld);
            _debugView.LoadContent(_graphics, _content);

            _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight));
            _cameraNode = _world.Scene.Root.CreateChild("Camera");
            _cameraNode.Attach(_camera);

            // Create the tile map.
            var terrainSize = new Vector2(4096.0f, 2048.0f);
            _terrain = new Terrain(terrainSize, 128.0f, 7)
            {
                DebugEnabled = false,
                Position = new Vector3(50.0f, -terrainSize.Y / 2.0f, 0.0f),
                TextureName = @"Textures\SpaceRock"
            };
            _world.Add(_terrain);

            GenerateTunnels(new Vector2(50.0f, 0));

            // Create the circle brush.
            _circleBrush = new CircleBrush(2.5f);

            _circleBrushNode = _world.Scene.CreateSceneNode();
            _circleBrushNode.Attach(new CircleRenderable(2.5f, 64)
            {
                Color = Vector3.One
            });

            // Dust cloud
            _dustCloud = _world.Scene.CreateSceneNode("DustCloud");
            _dustCloud.Position = new Vector3(0.0f, 0.0f, -1.0f);
            _dustCloud.Attach(new DustCloud());
            _world.Scene.Root.AddChild(_dustCloud);

            // Player
            _playerEntity = new SpaceShip();
            _playerEntity.Attach(new PlayerController());
            _playerEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f));
            _world.Add(_playerEntity);

            _payloadEntity = new Payload();
            _payloadEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f));
            _world.Add(_payloadEntity);

            _payloadChain = PayloadChain.Connect(_playerEntity, _payloadEntity, Vector2.UnitX * -20.0f);
        }