Skip to content

Commit 3f5ef4a

Browse files
BurgerballsEliteMasterEric
authored andcommitted
Camera bop offset
1 parent 75d8c5c commit 3f5ef4a

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

source/funkin/play/PlayState.hx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ class PlayState extends MusicBeatSubState
320320
*/
321321
public var cameraZoomRate:Int = Constants.DEFAULT_ZOOM_RATE;
322322

323+
/**
324+
* How many beats (quarter notes) the zoom rate is offset.
325+
* For if you want the zoom to happen off-beat.
326+
* @default Zero beats (on-beat).
327+
*/
328+
public var cameraZoomRateOffset:Int = Constants.DEFAULT_ZOOM_OFFSET;
329+
323330
/**
324331
* Whether the game is currently in the countdown before the song resumes.
325332
*/
@@ -1779,7 +1786,7 @@ class PlayState extends MusicBeatSubState
17791786
if (Preferences.zoomCamera
17801787
&& FlxG.camera.zoom < (1.35 * FlxCamera.defaultZoom)
17811788
&& cameraZoomRate > 0
1782-
&& Conductor.instance.currentBeat % cameraZoomRate == 0)
1789+
&& (Conductor.instance.currentBeat + cameraZoomRateOffset) % cameraZoomRate == 0)
17831790
{
17841791
// Set zoom multiplier for camera bop.
17851792
cameraBopMultiplier = cameraBopIntensity;

source/funkin/play/event/SetCameraBopSongEvent.hx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ class SetCameraBopSongEvent extends SongEvent
4242

4343
var rate:Null<Int> = data.getInt('rate');
4444
if (rate == null) rate = Constants.DEFAULT_ZOOM_RATE;
45+
var offset:Null<Int> = data.getInt('offset');
46+
if (rate == null) offset = Constants.DEFAULT_ZOOM_OFFSET;
4547
var intensity:Null<Float> = data.getFloat('intensity');
4648
if (intensity == null) intensity = 1.0;
4749

4850
PlayState.instance.cameraBopIntensity = (Constants.DEFAULT_BOP_INTENSITY - 1.0) * intensity + 1.0;
4951
PlayState.instance.hudCameraZoomIntensity = (Constants.DEFAULT_BOP_INTENSITY - 1.0) * intensity * 2.0;
5052
PlayState.instance.cameraZoomRate = rate;
53+
PlayState.instance.cameraZoomRateOffset = offset;
5154
trace('Set camera zoom rate to ${PlayState.instance.cameraZoomRate}');
5255
}
5356

@@ -77,6 +80,14 @@ class SetCameraBopSongEvent extends SongEvent
7780
type: SongEventFieldType.FLOAT,
7881
units: 'x'
7982
},
83+
{
84+
name: 'offset',
85+
title: 'Offset',
86+
defaultValue: 0,
87+
step: 1,
88+
type: SongEventFieldType.INTEGER,
89+
units: 'beats'
90+
},
8091
{
8192
name: 'rate',
8293
title: 'Rate',

source/funkin/util/Constants.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ class Constants
237237
*/
238238
public static final DEFAULT_ZOOM_RATE:Int = 4;
239239

240+
/**
241+
* The default offset of camera zooms (in beats).
242+
*/
243+
public static final DEFAULT_ZOOM_OFFSET:Int = 0;
244+
240245
/**
241246
* The default BPM for charts, so things don't break if none is specified.
242247
*/

0 commit comments

Comments
 (0)