Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Make Limo Ride car pause with game #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions preload/scripts/stages/limoRide.hxc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LimoRideStage extends Stage
super('limoRide');
}

function buildStage()
override function buildStage()
{
super.buildStage();

Expand All @@ -34,10 +34,11 @@ class LimoRideStage extends Stage
// I don't know what it's for, but it's not used in the game.
// If you want to re-add it, go find it in version control.

fastCarTimer = new FlxTimer();
resetFastCar();
}

function onBeatHit(event:SongTimeScriptEvent)
override function onBeatHit(event:SongTimeScriptEvent)
{
// When overriding onBeatHit, make sure to call super.onBeatHit,
// otherwise boppers will not work.
Expand All @@ -48,6 +49,8 @@ class LimoRideStage extends Stage
}

var fastCarCanDrive:Bool = false;
var fastCarTimer:FlxTimer;
var fastCarSound:FunkinSound;

function resetFastCar():Void
{
Expand All @@ -64,16 +67,17 @@ class LimoRideStage extends Stage
fastCar.y = FlxG.random.int(140, 250);
fastCar.velocity.x = 0;
fastCarCanDrive = true;
fastCarSound = null;
}

function fastCarDrive():Void
{
FunkinSound.playOnce(Paths.soundRandom('carPass', 0, 1), 0.7);
fastCarSound = FunkinSound.playOnce(Paths.soundRandom('carPass', 0, 1), 0.7);

var fastCar = getNamedProp('fastCar');
fastCar.velocity.x = (FlxG.random.int(170, 220) / FlxG.elapsed) * 3;
fastCarCanDrive = false;
new FlxTimer().start(2, function(tmr:FlxTimer)
fastCarTimer.start(2, function(tmr:FlxTimer)
{
resetFastCar();
});
Expand All @@ -83,7 +87,7 @@ class LimoRideStage extends Stage
* If your stage uses additional assets not specified in the JSON,
* make sure to specify them like this, or they won't get cached in the loading screen.
*/
function fetchAssetPaths():Array<String>
override function fetchAssetPaths():Array<String>
{
var results:Array<String> = super.fetchAssetPaths();

Expand All @@ -98,16 +102,30 @@ class LimoRideStage extends Stage
/**
* Make sure the fast car is reset when the song restarts.
*/
function onSongRetry(event:ScriptEvent) {
override function onSongRetry(event:ScriptEvent) {
super.onSongRetry(event);
resetFastCar();
}

/**
* Make sure the fast car is reset when the song restarts.
*/
function onCountdownStart(event:ScriptEvent) {
override function onCountdownStart(event:ScriptEvent) {
super.onCountdownStart(event);
resetFastCar();
}

override function onPause(event:PauseScriptEvent) {
super.onPause(event);

if (fastCarTimer != null) fastCarTimer.active = false;
if (fastCarSound != null) fastCarSound.pause();
}

override function onResume(event:ScriptEvent) {
super.onResume(event);

if (fastCarTimer != null) fastCarTimer.active = true;
if (fastCarSound != null) fastCarSound.resume();
}
}
95 changes: 55 additions & 40 deletions preload/scripts/stages/limoRideErect.hxc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LimoRideErectStage extends Stage
super('limoRideErect');
}

var colorShader:AdjustColorShader;
var colorShader:AdjustColorShader;
var mist1:FlxBackdrop;
var mist2:FlxBackdrop;
var mist3:FlxBackdrop;
Expand All @@ -25,7 +25,7 @@ class LimoRideErectStage extends Stage
var shootingStarBeat:Int = 0;
var shootingStarOffset:Int = 2;

function buildStage()
override function buildStage()
{
super.buildStage();

Expand All @@ -46,13 +46,13 @@ class LimoRideErectStage extends Stage
// I don't know what it's for, but it's not used in the game.
// If you want to re-add it, go find it in version control.

colorShader = new AdjustColorShader();
colorShader = new AdjustColorShader();

mist1 = new FlxBackdrop(Paths.image('limo/erect/mistMid'), 0x01);
mist1 = new FlxBackdrop(Paths.image('limo/erect/mistMid'), 0x01);
mist1.setPosition(-650, -100);
mist1.scrollFactor.set(1.1, 1.1);
mist1.zIndex = 400;
mist1.blend = 0;
mist1.blend = 0;
mist1.color = 0xFFc6bfde;
mist1.alpha = 0.4;
mist1.velocity.x = 1700;
Expand All @@ -64,7 +64,7 @@ class LimoRideErectStage extends Stage
mist2.setPosition(-650, -100);
mist2.scrollFactor.set(1.2, 1.2);
mist2.zIndex = 401;
mist2.blend = 0;
mist2.blend = 0;
mist2.color = 0xFF6a4da1;
mist2.alpha = 1;
mist2.velocity.x = 2100;
Expand All @@ -77,7 +77,7 @@ class LimoRideErectStage extends Stage
mist3.setPosition(-650, -100);
mist3.scrollFactor.set(0.8, 0.8);
mist3.zIndex = 99;
mist3.blend = 0;
mist3.blend = 0;
mist3.color = 0xFFa7d9be;
mist3.alpha = 0.5;
mist3.velocity.x = 900;
Expand All @@ -91,7 +91,7 @@ class LimoRideErectStage extends Stage
mist4.setPosition(-650, -380);
mist4.scrollFactor.set(0.6, 0.6);
mist4.zIndex = 98;
mist4.blend = 0;
mist4.blend = 0;
mist4.color = 0xFF9c77c7;
mist4.alpha = 1;
mist4.velocity.x = 700;
Expand All @@ -104,7 +104,7 @@ class LimoRideErectStage extends Stage
mist5.setPosition(-650, -400);
mist5.scrollFactor.set(0.2, 0.2);
mist5.zIndex = 15;
mist5.blend = 0;
mist5.blend = 0;
mist5.color = 0xFFE7A480;
mist5.alpha = 1;
mist5.velocity.x = 100;
Expand All @@ -115,12 +115,13 @@ class LimoRideErectStage extends Stage

getNamedProp('shootingStar').blend = 0;

fastCarTimer = new FlxTimer();
resetFastCar();
}

var _timer:Float = 0;

function onUpdate(event:UpdateScriptEvent):Void
override function onUpdate(event:UpdateScriptEvent):Void
{
super.onUpdate(event);

Expand All @@ -132,37 +133,37 @@ class LimoRideErectStage extends Stage
mist5.y = -450 + (Math.sin(_timer*0.2)*150);
//trace(mist1.y);

if(PlayState.instance.currentStage.getBoyfriend() != null && PlayState.instance.currentStage.getBoyfriend().shader == null){
PlayState.instance.currentStage.getBoyfriend().shader = colorShader;
PlayState.instance.currentStage.getGirlfriend().shader = colorShader;
PlayState.instance.currentStage.getDad().shader = colorShader;
getNamedProp('limoDancer1').shader = colorShader;
getNamedProp('limoDancer2').shader = colorShader;
getNamedProp('limoDancer3').shader = colorShader;
getNamedProp('limoDancer4').shader = colorShader;
getNamedProp('limoDancer5').shader = colorShader;
getNamedProp('fastCar').shader = colorShader;
if(PlayState.instance.currentStage.getBoyfriend() != null && PlayState.instance.currentStage.getBoyfriend().shader == null){
PlayState.instance.currentStage.getBoyfriend().shader = colorShader;
PlayState.instance.currentStage.getGirlfriend().shader = colorShader;
PlayState.instance.currentStage.getDad().shader = colorShader;
getNamedProp('limoDancer1').shader = colorShader;
getNamedProp('limoDancer2').shader = colorShader;
getNamedProp('limoDancer3').shader = colorShader;
getNamedProp('limoDancer4').shader = colorShader;
getNamedProp('limoDancer5').shader = colorShader;
getNamedProp('fastCar').shader = colorShader;

// PlayState.instance.currentStage.getBoyfriend().visible = false;
// PlayState.instance.currentStage.getGirlfriend().visible = false;
// PlayState.instance.currentStage.getDad().visible = false;
// PlayState.instance.currentStage.getGirlfriend().visible = false;
// PlayState.instance.currentStage.getDad().visible = false;
// getNamedProp('limo').visible = false;
// getNamedProp('limoDancer1').visible = false;
// getNamedProp('limoDancer2').visible = false;
// getNamedProp('limoDancer3').visible = false;
// getNamedProp('limoDancer4').visible = false;
// getNamedProp('limoDancer5').visible = false;
// getNamedProp('fastCar').visible = false;
// getNamedProp('limoDancer2').visible = false;
// getNamedProp('limoDancer3').visible = false;
// getNamedProp('limoDancer4').visible = false;
// getNamedProp('limoDancer5').visible = false;
// getNamedProp('fastCar').visible = false;
// getNamedProp('bgLimo').visible = false;
// getNamedProp('limoSunset').visible = false;
// getNamedProp('shootingStar').visible = false;

colorShader.hue = -30;
colorShader.saturation = -20;
colorShader.contrast = 0;
colorShader.brightness = -30;
}
}
colorShader.hue = -30;
colorShader.saturation = -20;
colorShader.contrast = 0;
colorShader.brightness = -30;
}
}

function doShootingStar(beat:Int):Void
{
Expand All @@ -173,10 +174,9 @@ class LimoRideErectStage extends Stage

shootingStarBeat = beat;
shootingStarOffset = FlxG.random.int(4, 8);

}

function onBeatHit(event:SongTimeScriptEvent)
override function onBeatHit(event:SongTimeScriptEvent)
{
// When overriding onBeatHit, make sure to call super.onBeatHit,
// otherwise boppers will not work.
Expand Down Expand Up @@ -208,16 +208,17 @@ class LimoRideErectStage extends Stage
fastCar.y = FlxG.random.int(140, 250);
fastCar.velocity.x = 0;
fastCarCanDrive = true;
fastCarSound = null;
}

function fastCarDrive():Void
{
FunkinSound.playOnce(Paths.soundRandom('carPass', 0, 1), 0.7);
fastCarSound = FunkinSound.playOnce(Paths.soundRandom('carPass', 0, 1), 0.7);

var fastCar = getNamedProp('fastCar');
fastCar.velocity.x = (FlxG.random.int(170, 220) / FlxG.elapsed) * 3;
fastCarCanDrive = false;
new FlxTimer().start(2, function(tmr:FlxTimer)
fastCarTimer.start(2, function(tmr:FlxTimer)
{
resetFastCar();
});
Expand All @@ -227,7 +228,7 @@ class LimoRideErectStage extends Stage
* If your stage uses additional assets not specified in the JSON,
* make sure to specify them like this, or they won't get cached in the loading screen.
*/
function fetchAssetPaths():Array<String>
override function fetchAssetPaths():Array<String>
{
var results:Array<String> = super.fetchAssetPaths();

Expand All @@ -242,7 +243,7 @@ class LimoRideErectStage extends Stage
/**
* Make sure the fast car is reset when the song restarts.
*/
function onSongRetry(event:ScriptEvent) {
override function onSongRetry(event:ScriptEvent) {
super.onSongRetry(event);
resetFastCar();
shootingStarBeat = 0;
Expand All @@ -252,8 +253,22 @@ class LimoRideErectStage extends Stage
/**
* Make sure the fast car is reset when the song restarts.
*/
function onCountdownStart(event:ScriptEvent) {
override function onCountdownStart(event:ScriptEvent) {
super.onCountdownStart(event);
resetFastCar();
}

override function onPause(event:PauseScriptEvent) {
super.onPause(event);

if (fastCarTimer != null) fastCarTimer.active = false;
if (fastCarSound != null) fastCarSound.pause();
}

override function onResume(event:ScriptEvent) {
super.onResume(event);

if (fastCarTimer != null) fastCarTimer.active = true;
if (fastCarSound != null) fastCarSound.resume();
}
}