camera target

This commit is contained in:
Yoshman29
2022-11-27 23:42:19 +01:00
parent 19c57d4141
commit 7e33aa9886
5 changed files with 67 additions and 55 deletions
+1 -1
View File
@@ -1 +1 @@
1312
1315
+23 -52
View File
@@ -727,11 +727,6 @@ class PlayState extends MusicBeatState
}
}
function tweenCamIn():Void
{
FlxTween.tween(FlxG.camera, {zoom: 1.3}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
override function openSubState(SubState:FlxSubState)
{
var event = scripts.event("onSubstateOpen", new StateEvent(SubState));
@@ -835,6 +830,12 @@ class PlayState extends MusicBeatState
public var startedCountdown:Bool = false;
public var canPause:Bool = true;
public var curSection(get, null):SwagSection;
public function get_curSection() {
return PlayState.SONG.notes[Std.int(curStep / 16)];
}
public function pauseGame() {
// TODO: Cancellable game pause
@@ -954,58 +955,28 @@ class PlayState extends MusicBeatState
}
}
if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null)
if (generatedMusic && curSection != null)
{
if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection)
{
var pos = boyfriend.getCameraPosition();
camFollow.setPosition(pos.x, pos.y);
var dadPos = dad.getCameraPosition();
var bfPos = boyfriend.getCameraPosition();
var section = curSection;
// switch (curStage)
// {
// case 'limo':
// camFollow.x = boyfriend.getMidpoint().x - 300;
// case 'mall':
// camFollow.y = boyfriend.getMidpoint().y - 200;
// case 'school':
// camFollow.x = boyfriend.getMidpoint().x - 200;
// camFollow.y = boyfriend.getMidpoint().y - 200;
// case 'schoolEvil':
// camFollow.x = boyfriend.getMidpoint().x - 200;
// camFollow.y = boyfriend.getMidpoint().y - 200;
// }
if (SONG.song.toLowerCase() == 'tutorial')
{
FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
} else {
var pos = dad.getCameraPosition();
camFollow.setPosition(pos.x, pos.y);
// from dad to bf
var ratio:Float = 0;
if (section.camTarget != null)
ratio = section.camTarget;
else
ratio = section.mustHitSection ? 1 : 0;
// camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
// camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210);
var event = scripts.event("onCameraMove", new CamMoveEvent(bfPos, dadPos, ratio, FlxPoint.get(FlxMath.lerp(dadPos.x, bfPos.x, ratio), FlxMath.lerp(dadPos.y, bfPos.y, ratio))));
// switch (dad.curCharacter)
// {
// case 'mom':
// camFollow.y = dad.getMidpoint().y;
// case 'senpai':
// camFollow.y = dad.getMidpoint().y - 430;
// camFollow.x = dad.getMidpoint().x - 100;
// case 'senpai-angry':
// camFollow.y = dad.getMidpoint().y - 430;
// camFollow.x = dad.getMidpoint().x - 100;
// }
if (dad.curCharacter == 'mom')
vocals.volume = 1;
if (SONG.song.toLowerCase() == 'tutorial')
{
tweenCamIn();
}
if (!event.cancelled) {
camFollow.setPosition(
event.position.x, event.position.y
);
}
for(e in [event.position, event.bfCamPos, event.dadCamPos])
e.put();
}
if (camZooming)
-2
View File
@@ -38,8 +38,6 @@ class ModSwitchMenu extends MusicBeatSubstate {
case 'zip':
// is a zip mod!!
mods.push(Path.withoutExtension(modFolder));
default:
trace('$modFolder is not a valid mod folder!!');
}
}
}
@@ -0,0 +1,42 @@
package funkin.scripting.events;
import flixel.math.FlxPoint;
class CamMoveEvent extends CancellableEvent {
/**
* Final camera position.
*/
public var position:FlxPoint;
/**
* Boyfriend's camera position.
*/
public var bfCamPos:FlxPoint;
/**
* Dad's camera position.
*/
public var dadCamPos:FlxPoint;
/**
* Ratio for lerping between Dad and BF.
* 0 = Camera focuses dad
* 0.5 = Duet Camera
* 1 = Camera focuses BF
*/
public var ratio:Float = 0;
/**
* Whenever the camera focuses BF more than dad.
*/
public var focusBF:Bool = false;
public function new(bfCamPos:FlxPoint, dadCamPos:FlxPoint, ratio:Float, position:FlxPoint) {
super();
this.bfCamPos = bfCamPos;
this.dadCamPos = dadCamPos;
this.ratio = ratio;
this.position = position;
this.focusBF = ratio >= 0.5;
}
}
+1
View File
@@ -9,6 +9,7 @@ typedef SwagSection =
var bpm:Float;
var changeBPM:Bool;
var altAnim:Bool;
@:optional var camTarget:Null<Float>;
}
class Section