private List<FingerTrace> GetTraces(CurrentNoteRendering r) { List<FingerTrace> traces = new List<FingerTrace>(); foreach (var trace in r.missed) { FingerTrace ft = new FingerTrace(); foreach (var p in trace.points) { CorePoint cp = new CorePoint(new Vector3(p.x, fallingSpeed * chart.bpm * (float)(p.time), 0), Vector3.UnitY, Vector3.UnitZ, p.force, new Color(0.5f, 0.5f, 0.5f, 0.7f)); ft.points.Add(cp); } traces.Add(ft); } foreach (var trace in r.inProgress) { FingerTrace ft = new FingerTrace(); foreach (var p in trace.points) { CorePoint cp = new CorePoint(new Vector3(p.x, fallingSpeed * chart.bpm * (float)(p.time), 0), Vector3.UnitY, Vector3.UnitZ, p.force, Color.Yellow); ft.points.Add(cp); } traces.Add(ft); } foreach (var trace in r.future) { FingerTrace ft = new FingerTrace(); foreach (var p in trace.points) { CorePoint cp = new CorePoint(new Vector3(p.x, fallingSpeed * chart.bpm * (float)(p.time), 0), Vector3.UnitY, Vector3.UnitZ, p.force, Color.LightBlue); ft.points.Add(cp); } traces.Add(ft); } return traces; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (IsActive) { int cx = Window.ClientBounds.Width/2; int cy = Window.ClientBounds.Height/2; Mouse.SetPosition(cx, cy); } time = (DateTime.Now - startingTime).TotalMinutes; // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); Finger[] f = fingers.getFingers(); List<float> fingerXs = new List<float>(); for (int i = 0; i < f.Length; i++) { if (f[i].Exists) { if (currentUserTraces[i] == null) { currentUserTraces[i] = new FingerTrace(); userTraces.Add(currentUserTraces[i]); if (userTraces.Count > 5) { userTraces.RemoveAt(0); } } float thickness = ForceToThickness(f[i].Force); currentUserTraces[i].points.Add(new CorePoint(new Vector3(f[i].X, (float) (time * chart.bpm), 0), -Vector3.UnitY, Vector3.UnitZ, thickness, new Color(1.0f, 0.0f, 0.0f, 0.3f))); fingerXs.Add(f[i].X); } else { currentUserTraces[i] = null; } } songTraces = GetTraces(session.FeedInstant(fingerXs.ToArray(), time, time + 100/chart.bpm, gameTime.ElapsedGameTime)); base.Update(gameTime); }