/// <summary> /// Loads graphics content for this screen. The background texture is quite /// big, so we use our own local ContentManager to load it. This allows us /// to unload before going from the menus into the game itself, wheras if we /// used the shared ContentManager provided by the Game class, the content /// would remain loaded forever. /// </summary> public override void LoadContent() { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Psuedo3DRacer.Content"); LoadTex("arrow"); LoadTex("blank"); LoadTex("blank-track"); LoadTex("banner-bottom"); LoadTex("banner-top"); LoadTex("car-spot"); LoadTex("colors"); LoadTex("paintcar"); LoadTex("selectcup"); LoadTex("triangles"); LoadTex("cup-holder"); LoadTex("cuparrow"); LoadTex("cup"); for (int i = 1; i <= 3; i++) { LoadTex("cuptitle" + i.ToString()); } texCarDirections = new Texture2D[8]; for (int dir = 0; dir < 8; dir++) { texCarDirections[dir] = content.Load<Texture2D>("cars/0-" + dir + "-0"); } Parallax = new ParallaxManager(ScreenManager.Viewport); Camera = new Camera(ScreenManager.GraphicsDevice, ScreenManager.Viewport); Track = Track.Load("track000", content, Parallax, false); drawEffect = new BasicEffect(ScreenManager.GraphicsDevice) { World = Camera.worldMatrix, View = Camera.viewMatrix, Projection = Camera.projectionMatrix, TextureEnabled = true }; drawAlphaEffect = new AlphaTestEffect(ScreenManager.GraphicsDevice) { World = Camera.worldMatrix, View = Camera.viewMatrix, Projection = Camera.projectionMatrix, ReferenceAlpha = 254, AlphaFunction = CompareFunction.Greater }; // Initial positions bannerTop1Pos = new Vector2(150, -230); bannerTop2Pos = new Vector2(400, -230); CarPos = new Vector2(ScreenManager.Viewport.Width / 2, -250f); SpotPos = new Vector2(ScreenManager.Viewport.Width / 2, ScreenManager.Viewport.Height + 500f); PaintPos = new Vector2(ScreenManager.Viewport.Width / 2, ScreenManager.Viewport.Height + 500f); Cups.Add(new Cup()); Cups.Add(new Cup()); Cups.Add(new Cup()); //Cups.Add(new Cup()); //Cups.Add(new Cup()); cupPosition = new Vector2(ScreenManager.Viewport.Width + 500, ScreenManager.Viewport.Height / 2); for (int i = selectedCup - 2; i <= selectedCup + 2; i++) { if (i >= 0 && i < Cups.Count) { Cups[i].Position = cupPosition + new Vector2(i * 150, 0); Cups[i].Scale = 1f - (Math.Abs(i) * 0.25f); } } cupTrackRT[0] = new RenderTarget2D(ScreenManager.GraphicsDevice, 193, 108, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); cupTrackRT[1] = new RenderTarget2D(ScreenManager.GraphicsDevice, 193, 108, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); cupTrackRT[2] = new RenderTarget2D(ScreenManager.GraphicsDevice, 193, 108, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); trophyPos = new Vector2(- 400, (ScreenManager.Viewport.Height / 2) + 50); leftRect = new Rectangle(0, ScreenManager.Viewport.Height - 75, 150, 50); rightRect = new Rectangle(ScreenManager.Viewport.Width-150, ScreenManager.Viewport.Height - 75, 150, 50); leftCupRect = new Rectangle((int)cupPosition.X - 300, (int)cupPosition.Y - 100, 50, 200); rightCupRect = new Rectangle((int)cupPosition.X + 250, (int)cupPosition.Y - 100, 50, 200); LoadTracks(selectedCup); AudioController.PlayMusic("title"); ScreenManager.Game.ResetElapsedTime(); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { //if (content == null) // content = new ContentManager(ScreenManager.Game.Services, "Psuedo3DRacer.Content"); //AudioController.LoadContent(content); parallaxManager = new ParallaxManager(ScreenManager.Viewport); gameHud = new HUD(ScreenManager.Viewport); gameHud.LoadContent(ScreenManager.Game.Content); gameCamera = new Camera(ScreenManager.GraphicsDevice, ScreenManager.Viewport); gameCamera.AttachedToCar = true; gameTrack = Track.Load("track" + ((Cup * 3) + currentTrack).ToString("000"), ScreenManager.Game.Content, parallaxManager, false); gameFont = ScreenManager.Game.Content.Load<SpriteFont>("font"); texBlank = ScreenManager.Game.Content.Load<Texture2D>("blank"); if (gameCars.Count == 0) { gameCars.Add(new Car(gameTrack.Length - 10, -0.2f, gameTrack, Color.Red)); gameCars.Add(new Car(gameTrack.Length - 20, 0.2f, gameTrack, Color.Blue)); gameCars.Add(new Car(gameTrack.Length - 30, -0.2f, gameTrack, Color.Green)); gameCars.Add(new Car(gameTrack.Length - 40, 0.2f, gameTrack, Color.Gold)); gameCars.Add(new Car(gameTrack.Length - 50, -0.2f, gameTrack, Color.Pink)); gameCars.Add(new Car(gameTrack.Length - 60, 0.2f, gameTrack, Color.Purple)); gameCars.Add(new Car(gameTrack.Length - 70, -0.2f, gameTrack, Color.Orange)); gameCars.Add(new Car(gameTrack.Length - 80, 0.2f, gameTrack, playerColor)); // Select "awesome" driver int sel = Psuedo3DRacer.rand.Next(7); gameCars[sel].SpeedWhenTurning = 0.051f + (0.002f * Cup); gameCars[sel].ConcentrationLevel = 1500 + (200 * Cup); gameCars[sel].CorrectionTime = 900 - (200 * Cup); gameCars[sel].ReactionTime = 100; // and "bad" driver int sel2 = sel; while (sel2 == sel) { sel2 = Psuedo3DRacer.rand.Next(7); } gameCars[sel2].SpeedWhenTurning = 0.04f + (0.001f * Cup); gameCars[sel2].ConcentrationLevel = 50 + (200 * Cup); gameCars[sel2].CorrectionTime = 5000 - (200 * Cup); gameCars[sel2].ReactionTime = 2000 - (100 * Cup); } else { gameCars[0].Reset(gameTrack.Length - 10, -0.2f, gameTrack); gameCars[1].Reset(gameTrack.Length - 20, 0.2f, gameTrack); gameCars[2].Reset(gameTrack.Length - 30, -0.2f, gameTrack); gameCars[3].Reset(gameTrack.Length - 40, 0.2f, gameTrack); gameCars[4].Reset(gameTrack.Length - 50, -0.2f, gameTrack); gameCars[5].Reset(gameTrack.Length - 60, 0.2f, gameTrack); gameCars[6].Reset(gameTrack.Length - 70, -0.2f, gameTrack); gameCars[7].Reset(gameTrack.Length - 80, 0.2f, gameTrack); } gameCars[7].IsPlayerControlled = true; gameCars[7].camAttached = true; foreach (Car c in gameCars) { c.LoadContent(ScreenManager.Game.Content, 0); c.engineSound.Volume = 0.75f * AudioController.sfxvolume; c.Update(new GameTime(), gameTrack, gameCars); } foreach (Car c in gameCars) c.Update(new GameTime(), gameTrack, gameCars); drawEffect = new BasicEffect(ScreenManager.GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, TextureEnabled = true }; drawAlphaEffect = new AlphaTestEffect(ScreenManager.GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, ReferenceAlpha = 254, AlphaFunction = CompareFunction.Greater }; ScreenManager.Game.ResetElapsedTime(); trackFade = 0f; fadeTime = 0; startDelay = 6000; finishDelay = 3000; for (int i = 0; i < 8; i++) finishingPositions[i] = -1; mapRenderTarget = new RenderTarget2D(ScreenManager.GraphicsDevice, 300, 300, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); RenderMap(); steeringAmount = 0f; standingsShown = false; }
public override void LoadContent() { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Psuedo3DRacer.Content"); texLogo = content.Load<Texture2D>("title"); texBlank = content.Load<Texture2D>("blank"); gameFont = content.Load<SpriteFont>("font"); parallaxManager = new ParallaxManager(ScreenManager.Viewport); gameCamera = new Camera(ScreenManager.GraphicsDevice, ScreenManager.Viewport); gameCamera.AttachedToCar = true; // + ((Cup * 3) + currentTrack).ToString("000") gameTrack = Track.Load("track" + (rand.Next(9)).ToString("000"), content, parallaxManager, false); gameCars.Add(new Car(gameTrack.Length - 10, -0.2f, gameTrack, Color.Red)); gameCars.Add(new Car(gameTrack.Length - 20, 0.2f, gameTrack, Color.Blue)); gameCars.Add(new Car(gameTrack.Length - 30, -0.2f, gameTrack, Color.Green)); gameCars.Add(new Car(gameTrack.Length - 40, 0.2f, gameTrack, Color.Gold)); gameCars.Add(new Car(gameTrack.Length - 50, -0.2f, gameTrack, Color.Pink)); gameCars.Add(new Car(gameTrack.Length - 60, 0.2f, gameTrack, Color.Purple)); gameCars.Add(new Car(gameTrack.Length - 70, -0.2f, gameTrack, Color.Orange)); gameCars.Add(new Car(gameTrack.Length - 80, 0.2f, gameTrack, Color.White)); gameCamera.AttachedToCar = true; foreach (Car c in gameCars) { c.LoadContent(content, 0); c.Update(new GameTime(), gameTrack, gameCars); } foreach (Car c in gameCars) c.Update(new GameTime(), gameTrack, gameCars); drawEffect = new BasicEffect(ScreenManager.GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, TextureEnabled = true }; drawAlphaEffect = new AlphaTestEffect(ScreenManager.GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, ReferenceAlpha = 254, AlphaFunction = CompareFunction.Greater }; AudioController.RestartMusic("title"); base.LoadContent(); }
public void Draw(GraphicsDevice gd, AlphaTestEffect effect, Camera gameCamera) { int oldRefAlpha = effect.ReferenceAlpha; gd.BlendState = BlendState.AlphaBlend; //gd.DepthStencilState = DepthStencilState.Default; gd.SamplerStates[0] = SamplerState.LinearClamp; effect.ReferenceAlpha = 150; Vector3 finalFace = Vector3.Zero; Vector3 faceCam = gameCamera.Position - Position; float camAngle = Helper.WrapAngle((float)Math.Atan2(faceCam.X, faceCam.Z)); Matrix rot = Matrix.CreateRotationY(camAngle); finalFace = Vector3.Transform(Vector3.Forward, rot); faceCam.Normalize(); effect.Texture = GetTextureForDirection(faceCam, gameCamera.AttachedToCar); Quad quad; effect.DiffuseColor = Tint.ToVector3(); quad = new Quad(Position, finalFace, Vector3.Up, 0.4f, 0.15f); Drawing.DrawQuad(effect, quad, gd); effect.ReferenceAlpha = oldRefAlpha; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Camera = new Camera(GraphicsDevice, GraphicsDevice.Viewport); spriteBatch = new SpriteBatch(GraphicsDevice); texGrid = Content.Load<Texture2D>("grid"); texBlank = Content.Load<Texture2D>("blank"); handleSphere = Content.Load<Model>("spherelowpoly"); spriteFont = Content.Load<SpriteFont>("font"); sphereTransforms = new Matrix[handleSphere.Bones.Count]; handleSphere.CopyAbsoluteBoneTransformsTo(sphereTransforms); drawEffect = new BasicEffect(GraphicsDevice) { World = Camera.worldMatrix, View = Camera.viewMatrix, Projection = Camera.projectionMatrix, TextureEnabled = true }; drawAlphaEffect = new AlphaTestEffect(GraphicsDevice) { World = Camera.worldMatrix, View = Camera.viewMatrix, Projection = Camera.projectionMatrix, ReferenceAlpha = 254, AlphaFunction = CompareFunction.Greater }; Track = Track.BuildFromControlPoints(ControlPoints); Track.LoadContent(Content); parallaxManager = new ParallaxManager(GraphicsDevice.Viewport); Track.LoadHorizon(Content, parallaxManager); ResetCars(); //car = new Car(0, Track, Color.Red); //car.LoadContent(Content, 0); }