// window events public void handleInput(object sender, EventArgs e) { int to_i(bool b) => b ? 1 : 0; var movement = UVector2.Normalized(new Vector2( to_i(this.input["left"]) - to_i(this.input["right"]), to_i(this.input["up"]) - to_i(this.input["down"]) )) * this.camera_speed; if (movement != Vector2.Zero) { Universe.camera.position += (10 / Universe.camera.zoom) * movement; } if (this.input.Values.Contains(true)) { // redraw only when needed this.redraw(); } }
public static Vector2 mod2(Vector2 a, float b) => a - b * UVector2.Floor(a / b);
public static Vector2 mod3(Vector2 a, float b) => a - new Vector2(Math.Abs(b)) * UVector2.Floor(a / Math.Abs(b));
public static Vector2 mod3(Vector2 a, Vector2 b) => a - Vector2.Abs(b) * UVector2.Floor(a / Vector2.Abs(b));