protected override void Initialize() { time = new XEditorGameTime(); X = new XMain(this.GraphicsDevice, this.Services, ContentRootDir, camera); //setup some basic usefull settings X.Gravity = new Vector3(0, -40, 0); X.UpdatePhysics = false; X.FrameRate.DisplayFrameRate = true; X.Console.AutoDraw = false; X.Debug.StartPosition.Y = 200; camera = new XFreeLookCamera(ref X, 0.1f, 1000f); //set the initial position of the camera such that we are looking at the center of the game world (0,0,0) camera.Position = new Vector3(30f, 15f, 40f); //so we look at center add in a rotation (trial and error) camera.Rotate(new Vector3(MathHelper.ToRadians(-10f), MathHelper.ToRadians(40f), 0)); X.LoadContent(); X.Physics.EnableFreezing = true; time.TotalGameTime.Reset(); time.TotalGameTime.Start(); time.ElapsedGameTime.Reset(); time.ElapsedGameTime.Start(); hasFocus = false; dragdroprelease = false; SetupBaseComponents(); //Begin draw timer! //redraw = new Timer(); //redraw.Interval = 1; //redraw.Start(); //redraw.Tick += new EventHandler(redraw_Tick); // Hook the idle event to constantly redraw our animation. Application.Idle += delegate { Invalidate(); }; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { //Load engine base content X.LoadContent(); //Game base elements menus.Load(Content); // load scene objects/content //sky = new XDynamicSky(ref X,X.Environment); //XSkyBox sky = new XSkyBox(ref X, @"Content\XEngine\Textures\Sky\front", @"Content\XEngine\Textures\Sky\back", @"Content\XEngine\Textures\Sky\left", @"Content\XEngine\Textures\Sky\right", @"Content\XEngine\Textures\Sky\top", @"Content\XEngine\Textures\Sky\bottom"); XSkyBox sky = new XSkyBox(ref X, @"Content\XEngine\Textures\Sky\GreenWaterSky"); heightmap = new XHeightMap(ref X, @"Content\Images\Heightmaps\Level2", X.Environment, @"Content\Textures\Grass", @"Content\Textures\Sand", null, @"Content\Images\Terrainmaps\Island1"); //resources.AddComponent(environment); resources.AddComponent(heightmap); resources.AddComponent(sky); model = new XModel(ref X, @"Content\Models\cube"); resources.AddComponent(model); Chassis = new XModel(ref X, @"Content\Models\chassis"); Wheel = new XModel(ref X, @"Content\Models\wheel"); resources.AddComponent(Chassis); resources.AddComponent(Wheel); housemodel = new XModel(ref X, @"Content\Models\spider"); resources.AddComponent(housemodel); resources.Load(); //Car = new XCar(ref X, Chassis, Wheel, true, true, 30.0f, 5.0f, 4.7f, 5.0f, 0.20f, 0.4f, 0.05f, 0.45f, 0.3f, 1, 520.0f, Math.Abs(X.Gravity.Y), new Vector3(-10, heightmap.Heights.GetHeight(new Vector3(-10, 3, 0))+5, 0)); Car = new XCar(ref X, Chassis, Wheel, true, // front wheel drive true, // rear wheel drive 35.0f, // max steering angle 5f, // steering rate 3.6f, // front lateral traction 3.1f, // rear lateral traction 1f, // front longintudinal traction 2f, // rear longitudinal traction 2.5f, // handbrake rear lateral traction .75f, // handbrake rear longitudinal traction 6f, // starting slide factor 15f, // threshold 1 slide factor 30f, // threshold 2 slide factor .7f, // slip threshold 1 10.0f, // slip threshold 2 2.0f, // slide speed factor 1.7f, // traction loss factor on slip 0.3f, // suspension travel 0.45f, // wheel radius -0.10f, // wheel mounting point 0.6f, // spring rate 0.6f, // shock dampening 2, // wheel rays 2.5f, // roll resistance 300.0f, // top speed 1200.0f, // torque X.Physics.Gravity.Length(), // gravity new Vector3(-10, heightmap.Heights.GetHeight(new Vector3(-10, 3, 0)) + 5, 0) ); Car.Load(X.Content); trees = new XTreeSystem(ref X, @"Content\Images\Treemaps\Level1", heightmap); trees.Load(Content); trees.GenerateTrees(freeCamera); input.Load(); base.LoadContent(); }