private double wheelRadius = 0.45; // IN METERS, NEEDS TO BE PART OF CLASS #endregion Fields #region Constructors public Physics(Display display, UserDisplay readout) { dataReadout = readout; mainDisplay = display; inputChanged(); carMass = 1347; transmissionEfficiency = display.transmissionEfficiency; oldRpm = 0; torqueCurve = car.torqueCurve; gearRatio = car.gearRatios; selectedGear = 1; // CAUSES STARTUP INPUT BUGS *ToDo neutral = true; soundInit = false; try { sound = SoundEffect.FromStream(TitleContainer.OpenStream("engineIdleLoopAmp1.wav")); soundInstance = sound.CreateInstance(); soundInstance.IsLooped = true; soundInstance.Volume = 0.5F; soundInstance.Play(); soundInit = true; } catch (Exception err) { } }
public Display() { InitializeComponent(); filePathSet = false; LastWindowState = WindowState; oldWidth = this.Size.Width; oldHeight = this.Size.Height; this.DoubleBuffered = true; degree = 0; degreeR = (degree * Math.PI) / 180; reverse = 0; driveGear = 0; accelValue = 0; brakeValue = 0; triggerType = 0; object_iD = 0; rTriggerMax = 10; rTriggerMin = 2; cognitiveLoadTest = false; carBrakeBitmap = new Bitmap("frontCar_Braking.png"); ; cogLoadIndex = -1; cogLoadActions = new System.Action[5] { cogLeft, cogRight, cogBrake, cogBrakeAndLeft, cogBrakeAndRight }; cogLoad = new bool[5]; for (int i = 0; i < 5; i++) { cogLoad[i] = false; } transmissionEfficiency = 0.75; steeringSensitivity = 50; currentTrial = -1; setInputSource((int)inputSelection.keyboard); //Set Keyboard as input trigger = false; randomNum = -1; trialCount = 0; UserDisplay = new UserDisplay(this); UserDisplay.Show(); if (!isHighPrecision) UserDisplay.HighPrecision.Text = "WARNING: Stopwatch is not high resolution"; else { long frequency = Stopwatch.Frequency; long nanosecPerTick = (1000000000L) / frequency; UserDisplay.HighPrecision.Text = " Timer reported " + nanosecPerTick + " ns"; } Restart(); physicsEngine = new Physics(this, UserDisplay); if (UserDisplay.saveData.ShowDialog() == DialogResult.Cancel) { Environment.Exit(0); return; } //fileName = DateTime.Today.Month + "-" + DateTime.Today.Day + "-" + DateTime.Today.Year + "_" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + "Trial.txt"; System.IO.File.WriteAllText(fileName, "Trail started at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + "." + DateTime.Now.Second + " on " + DateTime.Today.Month + "/" + DateTime.Today.Day + "/" + DateTime.Today.Year + "\r\n" + UserDisplay.HighPrecision.Text + "\r\n"); //fileNameRaw = DateTime.Today.Month + "-" + DateTime.Today.Day + "-" + DateTime.Today.Year + "_" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + "Trial_RAW.txt"; System.IO.File.WriteAllText(fileNameRaw, "Trial\tType\tStartSpeed\tGasMRel\tGasTRel\tGasMBrake\tGasTBrake\tTrialTBrake\tTotalStop\tWheelTurn\tError\t\r\n"); System.IO.File.WriteAllText(fileNameDumpPerTrial, "Thrtl\tBrke\tWjlDeg\tDGear\tRGear\tVel\tLaneDev\tRT\tCol\tTime\r\n"); filePathSet = true; speedometer = new Bitmap("SpeedometerBlankScaled.png"); tachometer = new Bitmap("TachometerBlankScaled.png"); stopSign = new Bitmap("stop_sign.jpg"); deer = new Bitmap("deer.jpg"); pedestrian = new Bitmap("pedestrian.jpg"); car = new Bitmap("Car.png"); leadCar = new Bitmap("frontCar.png"); Brush brush = new SolidBrush(Color.Green); pen = new Pen(brush, 5); initialized = true; trialTime.Start(); tick = true; Application.Idle += HandleApplicationIdle; }