stages now works without xmls

This commit is contained in:
Yoshman29
2022-10-07 19:20:31 +02:00
parent 666c7fa7e0
commit fa681da310
4 changed files with 159 additions and 81 deletions
+72
View File
@@ -1,4 +1,9 @@
import funkin.game.PlayState;
// phillyTrain is automatically added by Stage.hx
var curColor:Int = 0;
var trainSound:FlxSound;
var colors = [
0xFF31A2FD,
0xFF31FD8C,
@@ -6,9 +11,16 @@ var colors = [
0xFFFD4531,
0xFFFBA633
];
var trainMoving:Bool = false;
var trainFrameTiming:Float = 0;
var trainCars:Int = 8;
var trainFinishing:Bool = false;
var trainCooldown:Int = 0;
function create() {
// defaultCamZoom = 0.5;
light.color = colors[curColor];
trainSound = FlxG.sound.load(Paths.sound("train_passes"));
}
function beatHit(curBeat:Int) {
@@ -19,6 +31,15 @@ function beatHit(curBeat:Int) {
curColor = newColor;
light.color = colors[curColor];
}
if (!trainMoving)
trainCooldown += 1;
if (curBeat % 8 == 4 && FlxG.random.bool(30) && !trainMoving && trainCooldown > 8 && !trainSound.playing)
{
trainCooldown = FlxG.random.int(-4, 0);
trainStart();
}
}
function update(elapsed:Float) {
@@ -26,4 +47,55 @@ function update(elapsed:Float) {
light.alpha = 1 - (FlxEase.cubeIn((curBeatFloat / 4) % 1) * 0.85);
else
light.alpha = 0;
if (trainMoving) {
updateTrainPos();
}
}
function trainStart():Void
{
trainMoving = true;
if (!trainSound.playing)
trainSound.play(true);
}
var startedMoving:Bool = false;
function updateTrainPos():Void
{
if (trainSound.time >= 4700)
{
startedMoving = true;
gf.playAnim('hairBlow');
}
if (startedMoving)
{
phillyTrain.velocity.x = -400 * 24;
if (phillyTrain.x < -2000 && !trainFinishing)
{
phillyTrain.x = -1150;
trainCars -= 1;
if (trainCars <= 0)
trainFinishing = true;
}
if (phillyTrain.x < -4000 && trainFinishing)
trainReset();
}
}
function trainReset():Void
{
gf.playAnim('hairFall');
phillyTrain.x = FlxG.width + 200;
trainMoving = false;
// trainSound.stop();
// trainSound.time = 0;
trainCars = 8;
trainFinishing = false;
startedMoving = false;
phillyTrain.velocity.x = 0;
}
+1 -1
View File
@@ -1 +1 @@
205
209
+15 -11
View File
@@ -91,6 +91,7 @@ class PlayState extends MusicBeatState
public var cpuStrums:FlxTypedGroup<Strum>;
public var camZooming:Bool = false;
public var camZoomingInterval:Int = 4;
public var curSong:String = "";
public var curStage:String = "";
@@ -777,8 +778,9 @@ class PlayState extends MusicBeatState
// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
// FlxG.watch.addQuick('VOLRight', vocals.amplitudeRight);
iconP1.setGraphicSize(Std.int(FlxMath.lerp(150, iconP1.width, 0.50)));
iconP2.setGraphicSize(Std.int(FlxMath.lerp(150, iconP2.width, 0.50)));
// TODO: FPS-compatible lerping
iconP1.scale.set(FlxMath.lerp(iconP1.scale.x, 1, 0.33), FlxMath.lerp(iconP1.scale.y, 1, 0.33));
iconP2.scale.set(FlxMath.lerp(iconP2.scale.x, 1, 0.33), FlxMath.lerp(iconP2.scale.y, 1, 0.33));
iconP1.updateHitbox();
iconP2.updateHitbox();
@@ -1336,6 +1338,7 @@ class PlayState extends MusicBeatState
{
if (!note.wasGoodHit)
{
camZooming = true;
if (note.mustPress) {
// TODO: See TODO above
scripts.call("onPlayerHit", [note]);
@@ -1434,20 +1437,21 @@ class PlayState extends MusicBeatState
}
// HARDCODING FOR MILF ZOOMS!
if (curSong.toLowerCase() == 'milf' && curBeat >= 168 && curBeat < 200 && camZooming && FlxG.camera.zoom < 1.35)
// if (curSong.toLowerCase() == 'milf' && curBeat >= 168 && curBeat < 200 && camZooming && FlxG.camera.zoom < 1.35)
// {
// FlxG.camera.zoom += 0.015;
// camHUD.zoom += 0.03;
// }
if (camZoomingInterval < 1) camZoomingInterval = 1;
if (camZooming && FlxG.camera.zoom < 1.35 && curBeat % camZoomingInterval == 0)
{
FlxG.camera.zoom += 0.015;
camHUD.zoom += 0.03;
}
if (camZooming && FlxG.camera.zoom < 1.35 && curBeat % 4 == 0)
{
FlxG.camera.zoom += 0.015;
camHUD.zoom += 0.03;
}
iconP1.setGraphicSize(Std.int(iconP1.width + 30));
iconP2.setGraphicSize(Std.int(iconP2.width + 30));
iconP1.scale.set(1.2, 1.2);
iconP2.scale.set(1.2, 1.2);
iconP1.updateHitbox();
iconP2.updateHitbox();
+71 -69
View File
@@ -27,79 +27,81 @@ class Stage extends FlxBasic implements IBeatReceiver {
} catch(e) {
// TODO: handler
trace(e.details());
return;
}
var spritesParentFolder = "";
if (stageXML.has.zoom) {
var parsed:Null<Float> = Std.parseFloat(stageXML.att.zoom);
if (parsed != null) PlayState.instance.defaultCamZoom = parsed;
}
if (stageXML.has.folder) {
spritesParentFolder = stageXML.att.folder;
if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/";
}
if (stageXML.has.name) PlayState.instance.curStage = stageXML.att.name;
if (stageXML != null) {
var spritesParentFolder = "";
if (stageXML.has.zoom) {
var parsed:Null<Float> = Std.parseFloat(stageXML.att.zoom);
if (parsed != null) PlayState.instance.defaultCamZoom = parsed;
}
if (stageXML.has.folder) {
spritesParentFolder = stageXML.att.folder;
if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/";
}
if (stageXML.has.name) PlayState.instance.curStage = stageXML.att.name;
for(node in stageXML.elements) {
switch(node.name) {
case "sprite" | "spr" | "sparrow":
var spr = new FlxSprite();
spr.antialiasing = true;
if (!node.has.sprite || !node.has.name || !node.has.x || !node.has.y) continue;
for(node in stageXML.elements) {
switch(node.name) {
case "sprite" | "spr" | "sparrow":
var spr = new FlxSprite();
spr.antialiasing = true;
if (!node.has.sprite || !node.has.name || !node.has.x || !node.has.y) continue;
if (Assets.exists(Paths.file('images/$spritesParentFolder${node.att.sprite}', TEXT))) {
spr.frames = Paths.getSparrowAtlas('$spritesParentFolder${node.att.sprite}');
} else {
spr.loadGraphic(Paths.image('$spritesParentFolder${node.att.sprite}'));
}
var x:Null<Float> = Std.parseFloat(node.att.x);
var y:Null<Float> = Std.parseFloat(node.att.y);
if (x != null) spr.x = x;
if (y != null) spr.y = y;
if (node.has.scroll) {
var scroll:Null<Float> = Std.parseFloat(node.att.scroll);
if (scroll != null) spr.scrollFactor.set(scroll, scroll);
}
if (node.has.scale) {
var scale:Null<Float> = Std.parseFloat(node.att.scale);
if (scale != null) spr.scale.set(scale, scale);
}
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
for(anim in node.nodes.anim) CoolUtil.addXMLAnimation(spr, anim);
stageSprites.set(node.att.name, spr);
PlayState.instance.add(spr);
case "boyfriend" | "bf":
if (node.has.x) {
if (Assets.exists(Paths.file('images/$spritesParentFolder${node.att.sprite}', TEXT))) {
spr.frames = Paths.getSparrowAtlas('$spritesParentFolder${node.att.sprite}');
} else {
spr.loadGraphic(Paths.image('$spritesParentFolder${node.att.sprite}'));
}
var x:Null<Float> = Std.parseFloat(node.att.x);
if (x != null) PlayState.instance.boyfriend.x = x;
}
if (node.has.y) {
var y:Null<Float> = Std.parseFloat(node.att.y);
if (y != null) PlayState.instance.boyfriend.y = y;
}
PlayState.instance.add(PlayState.instance.boyfriend);
case "girlfriend" | "gf":
if (node.has.x) {
var x:Null<Float> = Std.parseFloat(node.att.x);
if (x != null) PlayState.instance.gf.x = x;
}
if (node.has.y) {
var y:Null<Float> = Std.parseFloat(node.att.y);
if (y != null) PlayState.instance.gf.y = y;
}
PlayState.instance.add(PlayState.instance.gf);
case "dad" | "opponent":
if (node.has.x) {
var x:Null<Float> = Std.parseFloat(node.att.x);
if (x != null) PlayState.instance.dad.x = x;
}
if (node.has.y) {
var y:Null<Float> = Std.parseFloat(node.att.y);
if (y != null) PlayState.instance.dad.y = y;
}
PlayState.instance.add(PlayState.instance.dad);
if (x != null) spr.x = x;
if (y != null) spr.y = y;
if (node.has.scroll) {
var scroll:Null<Float> = Std.parseFloat(node.att.scroll);
if (scroll != null) spr.scrollFactor.set(scroll, scroll);
}
if (node.has.scale) {
var scale:Null<Float> = Std.parseFloat(node.att.scale);
if (scale != null) spr.scale.set(scale, scale);
}
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
for(anim in node.nodes.anim) CoolUtil.addXMLAnimation(spr, anim);
stageSprites.set(node.att.name, spr);
PlayState.instance.add(spr);
case "boyfriend" | "bf":
if (node.has.x) {
var x:Null<Float> = Std.parseFloat(node.att.x);
if (x != null) PlayState.instance.boyfriend.x = x;
}
if (node.has.y) {
var y:Null<Float> = Std.parseFloat(node.att.y);
if (y != null) PlayState.instance.boyfriend.y = y;
}
PlayState.instance.add(PlayState.instance.boyfriend);
case "girlfriend" | "gf":
if (node.has.x) {
var x:Null<Float> = Std.parseFloat(node.att.x);
if (x != null) PlayState.instance.gf.x = x;
}
if (node.has.y) {
var y:Null<Float> = Std.parseFloat(node.att.y);
if (y != null) PlayState.instance.gf.y = y;
}
PlayState.instance.add(PlayState.instance.gf);
case "dad" | "opponent":
if (node.has.x) {
var x:Null<Float> = Std.parseFloat(node.att.x);
if (x != null) PlayState.instance.dad.x = x;
}
if (node.has.y) {
var y:Null<Float> = Std.parseFloat(node.att.y);
if (y != null) PlayState.instance.dad.y = y;
}
PlayState.instance.add(PlayState.instance.dad);
}
}
}
stageScript = Script.create(Paths.script('data/stages/$stage'));