public void InputLogic(AdvancerConfigBasic2d config, InputBasic2d action, SnapHistory <NentBasic2d, NentStaticBasic2d> h, ref NentBasic2d snap, byte pid, float delta) { // process the inputs for this action snap.XVel = RMathF.Clamp(action.Horizontal, -1f, 1f) * config.PlayerSpeed; snap.YVel = RMathF.Clamp(action.Vertical, -1f, 1f) * config.PlayerSpeed; // set our rotation, but only if we're not mid-dash if (snap.Free1 <= 0) { snap.Rot = action.Rotation; } // dash action if ((action.Inputs & InputBasic2d.INPUT_A) != 0 && snap.Free1 == 0) { // if input A is pressed, dash forward according to rotation // we use Free1 to store the dash timer. We can only begin a // dash if Free1 is equal to 0 (e.g. dash is over). snap.Free1 = config.DashTimerMax; // we don't need to set XVel/YVel here because this is done // in AdvanceLogic } // finally, do AdvanceLogic over the delta window AdvanceLogic(config, h, ref snap, delta); }
private void InputLogic(InputBasic2d action, SnapHistory <NentBasic2d, NentStaticBasic2d> h, byte pid, float delta) { // process the inputs for this action h.Shots[h.CurrentIndex].XVel = RMathF.Clamp(action.Horizontal, -1f, 1f) * PlayerSpeed; h.Shots[h.CurrentIndex].YVel = RMathF.Clamp(action.Vertical, -1f, 1f) * PlayerSpeed; // set our rotation, but only if we're not mid-dash if (h.Shots[h.CurrentIndex].Free1 <= 0) { h.Shots[h.CurrentIndex].Rot = action.Rotation; } // dash action if ((action.Inputs & InputBasic2d.INPUT_A) != 0 && h.Shots[h.CurrentIndex].Free1 == 0) { // if input A is pressed, dash forward according to rotation // we use Free1 to store the dash timer. We can only begin a // dash if Free1 is equal to 0 (e.g. dash is over). h.Shots[h.CurrentIndex].Free1 = DashTimerMax; // we don't need to set XVel/YVel here because this is done // in AdvanceLogic } // finally, do AdvanceLogic over the delta window AdvanceLogic(h, delta); }
public void ClampTest() { Assert.AreEqual(30f, RMathF.Clamp(20f, 30f, 50f)); Assert.AreEqual(50f, RMathF.Clamp(90f, 30f, 50f)); Assert.AreEqual(40f, RMathF.Clamp(40f, 30f, 50f)); }