train in progress

This commit is contained in:
Cameron Taylor 2020-12-10 18:23:53 -05:00
parent 5e948de074
commit f8dd35fc3a
17 changed files with 141 additions and 2 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Binary file not shown.

View File

@ -12,7 +12,7 @@ import lime.utils.Assets;
class FreeplayState extends MusicBeatState
{
var songs:Array<String> = ["Pico", "Bopeebo", "Dadbattle", "Fresh", "Tutorial"];
var songs:Array<String> = ["Pico", "Blammed", "Bopeebo", "Dadbattle", "Fresh", "Tutorial"];
var selector:FlxText;
var curSelected:Int = 0;

View File

@ -35,6 +35,7 @@ using StringTools;
class PlayState extends MusicBeatState
{
public static var curLevel:String = 'Tutorial';
public static var curStage:String = '';
public static var SONG:SwagSong;
public static var isStoryMode:Bool = false;
public static var storyWeek:Int = 0;
@ -81,6 +82,10 @@ class PlayState extends MusicBeatState
var halloweenBG:FlxSprite;
var isHalloween:Bool = false;
var phillyCityLights:FlxTypedGroup<FlxSprite>;
var phillyTrain:FlxSprite;
var trainSound:FlxSound;
var talking:Bool = true;
var songScore:Int = 0;
var scoreTxt:FlxText;
@ -144,6 +149,47 @@ class PlayState extends MusicBeatState
isHalloween = true;
}
else if (SONG.song.toLowerCase() == 'pico' || SONG.song.toLowerCase() == 'blammed')
{
curStage = 'philly';
var bg:FlxSprite = new FlxSprite(-100).loadGraphic(AssetPaths.sky__png);
bg.scrollFactor.set(0.1, 0.1);
add(bg);
var city:FlxSprite = new FlxSprite(-10).loadGraphic(AssetPaths.city__png);
city.scrollFactor.set(0.3, 0.3);
city.setGraphicSize(Std.int(city.width * 0.85));
city.updateHitbox();
add(city);
phillyCityLights = new FlxTypedGroup<FlxSprite>();
add(phillyCityLights);
for (i in 0...5)
{
var light:FlxSprite = new FlxSprite(city.x).loadGraphic('assets/images/philly/win' + i + '.png');
light.scrollFactor.set(0.3, 0.3);
light.visible = false;
light.setGraphicSize(Std.int(light.width * 0.85));
light.updateHitbox();
phillyCityLights.add(light);
}
var streetBehind:FlxSprite = new FlxSprite(-40, 50).loadGraphic(AssetPaths.behindTrain__png);
add(streetBehind);
phillyTrain = new FlxSprite(2000, 300).loadGraphic(AssetPaths.train__png);
add(phillyTrain);
trainSound = new FlxSound().loadEmbedded('assets/sounds/train_passes' + TitleState.soundExt);
FlxG.sound.list.add(trainSound);
// var cityLights:FlxSprite = new FlxSprite().loadGraphic(AssetPaths.win0__png);
var street:FlxSprite = new FlxSprite(-40, streetBehind.y).loadGraphic(AssetPaths.street__png);
add(street);
}
else
{
var bg:FlxSprite = new FlxSprite(-600, -200).loadGraphic(AssetPaths.stageback__png);
@ -200,6 +246,7 @@ class PlayState extends MusicBeatState
case 'dad':
camPos.x += 400;
case 'pico':
camPos.x += 600;
dad.y += 300;
}
@ -598,6 +645,23 @@ class PlayState extends MusicBeatState
override public function update(elapsed:Float)
{
switch (curStage)
{
case 'philly':
if (trainMoving)
{
trainFrameTiming += elapsed;
if (trainFrameTiming >= 1 / 24)
{
updateTrainPos();
trainFrameTiming = 0;
}
}
phillyCityLights.members[curLight].alpha -= (Conductor.crochet / 1000) * FlxG.elapsed;
}
super.update(elapsed);
scoreTxt.text = "Score:" + songScore;
@ -1308,6 +1372,56 @@ class PlayState extends MusicBeatState
}
}
var trainMoving:Bool = false;
var trainFrameTiming:Float = 0;
var trainCars:Int = 8;
var trainFinishing:Bool = false;
function trainStart():Void
{
trainMoving = true;
if (!trainSound.playing)
trainSound.play(true);
}
var startedMoving:Bool = false;
function updateTrainPos():Void
{
if (trainSound.time >= 4700)
{
startedMoving = true;
}
if (startedMoving)
{
phillyTrain.x -= 400;
if (phillyTrain.x < -2000 && !trainFinishing)
{
phillyTrain.x = -1150;
trainCars -= 1;
if (trainCars <= 0)
trainFinishing = true;
}
if (phillyTrain.x < 0 && trainFinishing)
trainReset();
}
}
function trainReset():Void
{
phillyTrain.x = FlxG.width + 200;
trainMoving = false;
// trainSound.stop();
// trainSound.time = 0;
trainCars = 8;
startedMoving = false;
}
function lightningStrikeShit():Void
{
FlxG.sound.play('assets/sounds/thunder_' + FlxG.random.int(1, 2) + TitleState.soundExt);
@ -1396,9 +1510,33 @@ class PlayState extends MusicBeatState
}
}
switch (curStage)
{
case "philly":
if (totalBeats % 4 == 0)
{
phillyCityLights.forEach(function(light:FlxSprite)
{
light.visible = false;
});
curLight = FlxG.random.int(0, phillyCityLights.length - 1);
phillyCityLights.members[curLight].visible = true;
phillyCityLights.members[curLight].alpha = 1;
}
if (totalBeats % 8 == 4 && FlxG.random.bool(40) && !trainMoving)
{
trainStart();
}
}
if (isHalloween && FlxG.random.bool(10) && curBeat > lightningStrikeBeat + lightningOffset)
{
lightningStrikeShit();
}
}
var curLight:Int = 0;
}

View File

@ -69,7 +69,7 @@ class TitleState extends MusicBeatState
}
#if SKIP_TO_PLAYSTATE
FlxG.switchState(new ChartingState());
FlxG.switchState(new FreeplayState());
#else
startIntro();
#end