Skip to content

Commit 7019505

Browse files
committed
Zoom Multiplier for camZooming
1 parent 9570de7 commit 7019505

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

source/funkin/backend/system/Flags.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ class Flags {
136136
public static var DEFAULT_CAM_ZOOM_STRENGTH:Int = 1;
137137
public static var DEFAULT_CAM_ZOOM:Float = 1.05; // what zoom level it defaults to
138138
public static var DEFAULT_HUD_ZOOM:Float = 1.0;
139+
public static var DEFAULT_ZOOM:Float = 1.0;
140+
public static var DEFAULT_ZOOM_LERP:Float = 0.05;
141+
public static var USE_CAM_ZOOM_MULT:Bool = true;
139142
public static var MAX_CAMERA_ZOOM_MULT:Float = 1.35;
140143

141144
// to translate these you need to convert them into ids

source/funkin/game/PlayState.hx

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ class PlayState extends MusicBeatState
372372
*/
373373
public var camHUDZoomLerp:Float = Flags.DEFAULT_HUD_ZOOM_LERP;
374374

375+
/**
376+
* Camera zoom at which the cameras that zooms lerps to.
377+
* (Only used if useCamZoomMult is on).
378+
*/
379+
public var defaultZoom:Float = Flags.DEFAULT_ZOOM;
380+
/**
381+
* Speed at which the cameras that zooms zoom lerps to.
382+
* (Only used if useCamZoomMult is on).
383+
*/
384+
public var camZoomLerp:Float = Flags.DEFAULT_ZOOM_LERP;
385+
375386
/**
376387
* Whenever cam zooming is enabled, enables on a note hit if not cancelled.
377388
*/
@@ -401,12 +412,21 @@ class PlayState extends MusicBeatState
401412
*/
402413
public var camZoomingStrength:Float = Flags.DEFAULT_CAM_ZOOM_STRENGTH;
403414
/**
404-
* Default multiplier for `maxCamZoom`.
405-
*/
415+
* Default multiplier for `maxCamZoom`.
416+
*/
406417
public var maxCamZoomMult:Float = Flags.MAX_CAMERA_ZOOM_MULT;
407418
/**
408-
* Maximum amount of zoom for the camera (based on `maxCamZoomMult` and the camera's zoom IF not set).
409-
*/
419+
* Whether it should use a implementation where it multiplies the current camera zoom instead.
420+
*/
421+
public var useCamZoomMult:Bool = Flags.USE_CAM_ZOOM_MULT;
422+
/**
423+
* The current multiplier for cam zooming.
424+
* (Only used if useCamZoomMult is on).
425+
*/
426+
public var camZoomingMult:Float = Flags.DEFAULT_ZOOM;
427+
/**
428+
* Maximum amount of zoom for the camera (based on `maxCamZoomMult` and the camera's zoom IF not set).
429+
*/
410430
public var maxCamZoom(get, default):Float = Math.NaN;
411431

412432
private inline function get_maxCamZoom() return Math.isNaN(maxCamZoom) ? maxCamZoomMult * defaultCamZoom : maxCamZoom;
@@ -1324,12 +1344,15 @@ class PlayState extends MusicBeatState
13241344
if (canAccessDebugMenus && chartingMode && controls.DEV_ACCESS)
13251345
FlxG.switchState(new funkin.editors.charter.Charter(SONG.meta.name, difficulty, false));
13261346

1327-
if (Options.camZoomOnBeat && camZooming && FlxG.camera.zoom < maxCamZoom) {
1347+
if (Options.camZoomOnBeat && camZooming) {
13281348
var beat = Conductor.getBeats(camZoomingEvery, camZoomingInterval, camZoomingOffset);
13291349
if (camZoomingLastBeat != beat) {
13301350
camZoomingLastBeat = beat;
1331-
FlxG.camera.zoom += 0.015 * camZoomingStrength;
1332-
camHUD.zoom += 0.03 * camZoomingStrength;
1351+
if (useCamZoomMult) camZoomingMult = Math.min(camZoomingMult + camZoomingStrength, defaultZoom + camZoomingStrength);
1352+
else if (FlxG.camera.zoom < maxCamZoom) {
1353+
FlxG.camera.zoom += 0.015 * camZoomingStrength;
1354+
camHUD.zoom += 0.03 * camZoomingStrength;
1355+
}
13331356
}
13341357
}
13351358

@@ -1372,6 +1395,12 @@ class PlayState extends MusicBeatState
13721395
moveCamera();
13731396

13741397
if (camZooming) {
1398+
if (useCamZoomMult) {
1399+
camZoomingMult = lerp(camZoomingMult, defaultZoom, camZoomLerp) - defaultZoom;
1400+
FlxG.camera.zoomMultiplier = camZoomingMult * 0.015 + defaultZoom;
1401+
camHUD.zoomMultiplier = camZoomingMult * 0.03 + defaultZoom;
1402+
camZoomingMult += defaultZoom;
1403+
}
13751404
FlxG.camera.zoom = lerp(FlxG.camera.zoom, defaultCamZoom, camGameZoomLerp);
13761405
camHUD.zoom = lerp(camHUD.zoom, defaultHudZoom, camHUDZoomLerp);
13771406
}

0 commit comments

Comments
 (0)