Skip to content

Commit

Permalink
vc is weird
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 30, 2023
1 parent a86d660 commit 6525680
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 21 deletions.
2 changes: 2 additions & 0 deletions assets/preload/data/eventList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Change Scroll Speed~Scroll Speed~Time To Change In Seconds (default is 0)
Change Character Alpha~Character (BF, Dad, GF)~Alpha to change to. (default is 0.5)
Change Keycount~Player 1 Keycount~Player 2 Keycount
Change Ui Skin~Ui Skin~Nothing
Change Camera Speed~Speed~Nothing
Change Camera Zoom Speed~Speed~Nothing
Play Character Animation~Character (Dad, BF, GF)~Animation to play
Hey!~BF = Only BF, GF = Only GF, anything else = Both~Nothing
Character Will Idle~Character (BF, Dad, GF)~"true" or "false"
Expand Down
10 changes: 10 additions & 0 deletions source/game/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,14 @@ class Character extends FlxSprite {
public function addOffset(name:String, x:Float = 0, y:Float = 0) {
animOffsets.set(name, [(isPlayer && offsetsFlipWhenPlayer) || (!isPlayer && offsetsFlipWhenEnemy) ? -x : x, y]);
}
public var followMainCharacter:Bool = false;
public function getMainCharacter():Character
{
if (otherCharacters != null && otherCharacters.length > 0)
{
if (followMainCharacter)
return otherCharacters[0];
}
return this;
}
}
16 changes: 16 additions & 0 deletions source/modding/ModchartUtilities.hx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ class ModchartUtilities {
return lua_Cameras.get("game");
}

public static function killShaders(){
for (cam in lua_Cameras){
cam.shaders = [];
cam.shaderNames = [];
}
}

public function die() {
PlayState.songMultiplier = oldMultiplier;

Expand Down Expand Up @@ -2744,6 +2751,15 @@ class ModchartUtilities {
}
});

setLuaFunction("tweenShaderProperty", function(id:String, property:String, value:Float, duration:Float, ?ease:String = "linear", ?startDelay:Float = 0.0, ?onComplete:Dynamic) {
var shader:CustomShader = lua_Custom_Shaders.get(id);
if (shader != null) {
shader.tween(property, value, duration, easeFromString(ease), startDelay, onComplete);
} else {
trace('Shader named $shader doesn\'t exist!', ERROR);
}
});

setLuaFunction("updateRating", function() {
PlayState.instance.updateRating();
});
Expand Down
134 changes: 113 additions & 21 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ class PlayState extends MusicBeatState {
**/
public var camFollow:FlxObject;


/**
* Should the camera be centered?
*/
public var centerCamera:Bool = false;

/**
Copy of `camFollow` used for transitioning between songs smoother.
**/
Expand All @@ -197,6 +203,16 @@ class PlayState extends MusicBeatState {
**/
public var camZooming:Bool = false;

/**
Speed of camera.
**/
public var cameraSpeed:Float = 1;

/**
Speed of camera zooming.
**/
public var cameraZoomSpeed:Float = 1;

/**
Shortner for `SONG.song`.
**/
Expand Down Expand Up @@ -2251,10 +2267,10 @@ class PlayState extends MusicBeatState {

tweenManager.update(elapsed);

FlxG.camera.followLerp = elapsed * 2.4;
FlxG.camera.followLerp = (elapsed * 2.4) *cameraSpeed;

var icon_Zoom_Lerp = elapsed * 9;
var camera_Zoom_Lerp = elapsed * 3;
var camera_Zoom_Lerp = (elapsed * 3) * cameraZoomSpeed;

iconP1.scale.set(FlxMath.lerp(iconP1.scale.x, iconP1.startSize, icon_Zoom_Lerp * songMultiplier),
FlxMath.lerp(iconP1.scale.y, iconP1.startSize, icon_Zoom_Lerp * songMultiplier));
Expand Down Expand Up @@ -2386,12 +2402,15 @@ class PlayState extends MusicBeatState {
// offsetY = luaModchart.getVar("followYOffset", "float");

setLuaVar("mustHit", PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection);

if(!PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection)
{
var midPos = dad.getMainCharacter().getMidpoint();

if (!PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) {
var midPos = dad.getMidpoint();

if (Options.getData("cameraTracksDirections") && dad.animation.curAnim != null) {
switch (dad.animation.curAnim.name.toLowerCase()) {
if(utilities.Options.getData("cameraTracksDirections") && dad.animation.curAnim != null)
{
switch(dad.animation.curAnim.name.toLowerCase())
{
case "singleft":
midPos.x -= 50;
case "singright":
Expand All @@ -2406,10 +2425,12 @@ class PlayState extends MusicBeatState {
midPos.x += stage.p2_Cam_Offset.x;
midPos.y += stage.p2_Cam_Offset.y;

if (camFollow.x != midPos.x + 150 + dad.cameraOffset[0] || camFollow.y != midPos.y + -100 + dad.cameraOffset[1]) {
camFollow.setPosition(midPos.x + 150 + dad.cameraOffset[0], midPos.y - 100 + dad.cameraOffset[1]);

switch (dad.curCharacter) {
//if(camFollow.x != midPos.x + 150 + dad.cameraOffset[0] || camFollow.y != midPos.y + - 100 + dad.cameraOffset[1])
//{
camFollow.setPosition(midPos.x + 150 + dad.getMainCharacter().cameraOffset[0], midPos.y - 100 + dad.getMainCharacter().cameraOffset[1]);

switch (dad.curCharacter)
{
case 'mom':
camFollow.y = midPos.y;
case 'senpai':
Expand All @@ -2424,14 +2445,17 @@ class PlayState extends MusicBeatState {
executeALuaState("turnChange", ['dad']);
allScriptCall("playerTwoTurn");
allScriptCall("turnChange", ['dad']);
}
//}
}

if (PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) {
var midPos = boyfriend.getMidpoint();
if(PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection)
{
var midPos = boyfriend.getMainCharacter().getMidpoint();

if (Options.getData("cameraTracksDirections") && boyfriend.animation.curAnim != null) {
switch (boyfriend.animation.curAnim.name) {
if(Options.getData("cameraTracksDirections") && boyfriend.animation.curAnim != null)
{
switch(boyfriend.animation.curAnim.name)
{
case "singLEFT":
midPos.x -= 50;
case "singRIGHT":
Expand All @@ -2446,11 +2470,12 @@ class PlayState extends MusicBeatState {
midPos.x += stage.p1_Cam_Offset.x;
midPos.y += stage.p1_Cam_Offset.y;

if (camFollow.x != midPos.x - 100 + boyfriend.cameraOffset[0]
|| camFollow.y != midPos.y - 100 + boyfriend.cameraOffset[1]) {
camFollow.setPosition(midPos.x - 100 + boyfriend.cameraOffset[0], midPos.y - 100 + boyfriend.cameraOffset[1]);

switch (curStage) {
//if(camFollow.x != midPos.x - 100 + boyfriend.cameraOffset[0] || camFollow.y != midPos.y - 100 + boyfriend.cameraOffset[1])
//{
camFollow.setPosition(midPos.x - 100 + boyfriend.getMainCharacter().cameraOffset[0], midPos.y - 100 + boyfriend.getMainCharacter().cameraOffset[1]);

switch (curStage)
{
case 'limo':
camFollow.x = midPos.x - 300;
case 'mall':
Expand All @@ -2461,6 +2486,55 @@ class PlayState extends MusicBeatState {
executeALuaState("turnChange", ['bf']);
allScriptCall("playerOneTurn");
allScriptCall("turnChange", ['bf']);
//}
}

if (centerCamera)
{
var midPos = boyfriend.getMainCharacter().getMidpoint();
midPos.x += stage.p1_Cam_Offset.x;
midPos.y += stage.p1_Cam_Offset.y;
camFollow.setPosition(midPos.x - 100 + boyfriend.getMainCharacter().cameraOffset[0], midPos.y - 100 + boyfriend.getMainCharacter().cameraOffset[1]);
midPos = dad.getMainCharacter().getMidpoint();
midPos.x += stage.p2_Cam_Offset.x;
midPos.y += stage.p2_Cam_Offset.y;
camFollow.x += midPos.x + 150 + dad.getMainCharacter().cameraOffset[0];
camFollow.y += midPos.y - 100 + dad.getMainCharacter().cameraOffset[1];
camFollow.x *= 0.5;
camFollow.y *= 0.5;
if(PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection)
{
if(Options.getData("cameraTracksDirections") && boyfriend.getMainCharacter().animation.curAnim != null)
{
switch(boyfriend.getMainCharacter().animation.curAnim.name)
{
case "singLEFT":
camFollow.x -= 50;
case "singRIGHT":
camFollow.x += 50;
case "singUP":
camFollow.y -= 50;
case "singDOWN":
camFollow.y += 50;
}
}
}
else
{
if(Options.getData("cameraTracksDirections") && dad.getMainCharacter().animation.curAnim != null)
{
switch(dad.getMainCharacter().animation.curAnim.name.toLowerCase())
{
case "singleft":
camFollow.x -= 50;
case "singright":
camFollow.x += 50;
case "singup":
camFollow.y -= 50;
case "singdown":
camFollow.y += 50;
}
}
}
}
}
Expand Down Expand Up @@ -2997,6 +3071,14 @@ class PlayState extends MusicBeatState {
executeALuaState("updatePost", [elapsed]);
}

override function destroy()
{
#if linc_luajit
ModchartUtilities.killShaders();
#end
super.destroy();
}

function endSong():Void {
canPause = false;
FlxG.sound.music.volume = 0;
Expand Down Expand Up @@ -4791,6 +4873,16 @@ class PlayState extends MusicBeatState {
else
speed = funnySpeed;
}
case "change camera speed":
var speed:Float = Std.parseFloat(event[2]);
if(Math.isNaN(speed))
speed = 1;
cameraSpeed = speed;
case "change camera zoom speed":
var speed:Float = Std.parseFloat(event[2]);
if(Math.isNaN(speed))
speed = 1;
cameraZoomSpeed = speed;
case "character will idle?":
var char = getCharFromEvent(event[2]);

Expand Down

0 comments on commit 6525680

Please sign in to comment.