2022-03-08 03:13:53 -05:00
|
|
|
package funkin.play;
|
2022-02-16 16:31:20 -05:00
|
|
|
|
2022-02-18 16:29:29 -05:00
|
|
|
import flixel.FlxObject;
|
2022-02-16 16:31:20 -05:00
|
|
|
import flixel.FlxSprite;
|
2022-02-18 16:29:29 -05:00
|
|
|
import flixel.addons.effects.FlxTrail;
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
import flixel.math.FlxMath;
|
|
|
|
import flixel.util.FlxColor;
|
2022-04-18 19:36:09 -04:00
|
|
|
import funkin.Note.NoteData;
|
|
|
|
import funkin.audiovis.PolygonSpectogram;
|
2022-06-12 00:02:49 -04:00
|
|
|
import flixel.util.FlxDirectionFlags;
|
2022-02-16 16:31:20 -05:00
|
|
|
|
|
|
|
class PicoFight extends MusicBeatState
|
|
|
|
{
|
|
|
|
var picoHealth:Float = 1;
|
|
|
|
var darnellHealth:Float = 1;
|
|
|
|
|
2022-02-18 16:29:29 -05:00
|
|
|
var pico:Fighter;
|
|
|
|
var darnell:Fighter;
|
|
|
|
var darnellGhost:Fighter;
|
|
|
|
|
|
|
|
var nextHitTmr:FlxSprite;
|
|
|
|
|
|
|
|
var funnyWave:PolygonSpectogram;
|
|
|
|
|
|
|
|
var noteQueue:Array<NoteData> = [];
|
|
|
|
var noteSpawner:FlxTypedGroup<FlxSprite>;
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
override function create()
|
|
|
|
{
|
2022-02-18 16:29:29 -05:00
|
|
|
Paths.setCurrentLevel("week8");
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height);
|
|
|
|
bg.scrollFactor.set();
|
|
|
|
add(bg);
|
|
|
|
|
|
|
|
FlxG.sound.playMusic(Paths.inst("blazin"));
|
2022-02-18 16:29:29 -05:00
|
|
|
|
|
|
|
SongLoad.loadFromJson('blazin', "blazin");
|
2022-03-29 21:56:04 -04:00
|
|
|
Conductor.bpm = SongLoad.songData.bpm;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
|
|
|
for (dumbassSection in SongLoad.songData.noteMap['hard'])
|
|
|
|
{
|
|
|
|
for (noteStuf in dumbassSection.sectionNotes)
|
|
|
|
{
|
|
|
|
noteQueue.push(noteStuf);
|
|
|
|
trace(noteStuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
funnyWave = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height);
|
|
|
|
funnyWave.x = (FlxG.width / 2);
|
|
|
|
funnyWave.realtimeVisLenght = 0.6;
|
|
|
|
add(funnyWave);
|
|
|
|
|
|
|
|
noteSpawner = new FlxTypedGroup<FlxSprite>();
|
|
|
|
add(noteSpawner);
|
|
|
|
|
|
|
|
makeNotes();
|
|
|
|
|
|
|
|
nextHitTmr = new FlxSprite((FlxG.width / 2) - 5).makeGraphic(10, FlxG.height, FlxColor.BLACK);
|
|
|
|
add(nextHitTmr);
|
|
|
|
|
|
|
|
var trailShit:FlxTrail = new FlxTrail(nextHitTmr);
|
|
|
|
add(trailShit);
|
|
|
|
|
|
|
|
pico = new Fighter(0, 300, "pico-fighter");
|
|
|
|
add(pico);
|
|
|
|
|
|
|
|
darnell = new Fighter(0, 300, "darnell-fighter");
|
|
|
|
add(darnell);
|
|
|
|
|
|
|
|
darnellGhost = new Fighter(0, 300, "darnell-fighter");
|
|
|
|
darnellGhost.alpha = 0.5;
|
|
|
|
add(darnellGhost);
|
|
|
|
|
|
|
|
mid = (FlxG.width / 2) - (pico.width / 2);
|
|
|
|
resetPositions();
|
|
|
|
|
|
|
|
// fuk u, hardcoded bullshit bitch
|
2022-02-16 16:31:20 -05:00
|
|
|
|
|
|
|
super.create();
|
|
|
|
}
|
|
|
|
|
2022-02-18 16:29:29 -05:00
|
|
|
function makeNotes()
|
|
|
|
{
|
|
|
|
for (notes in noteQueue)
|
|
|
|
{
|
|
|
|
if (notes.strumTime < Conductor.songPosition + (Conductor.crochet * 4))
|
|
|
|
{
|
|
|
|
spawnNote(notes);
|
2022-06-12 00:02:49 -04:00
|
|
|
spawnNote(notes, FlxDirectionFlags.RIGHT);
|
2022-02-18 16:29:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-12 00:02:49 -04:00
|
|
|
function spawnNote(note:NoteData, facing:Int = FlxDirectionFlags.LEFT)
|
2022-02-18 16:29:29 -05:00
|
|
|
{
|
|
|
|
var spr:FlxSprite = new FlxSprite(0, (FlxG.height / 2) - 60).makeGraphic(10, 120, Note.codeColors[note.noteData]);
|
|
|
|
spr.ID = Std.int(note.strumTime); // using ID as strum, lol!
|
|
|
|
spr.facing = facing;
|
|
|
|
noteSpawner.add(spr);
|
|
|
|
}
|
|
|
|
|
|
|
|
var mid:Float = (FlxG.width * 0.5) - 200;
|
|
|
|
|
|
|
|
function resetPositions()
|
|
|
|
{
|
|
|
|
resetPicoPos();
|
|
|
|
resetDarnell();
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetPicoPos()
|
|
|
|
{
|
|
|
|
pico.x = mid + pico.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetDarnell()
|
|
|
|
{
|
|
|
|
darnell.x = mid - darnell.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
var prevNoteHit:Float = 0;
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2022-02-18 16:29:29 -05:00
|
|
|
darnellGhost.x = darnell.x;
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
Conductor.songPosition = FlxG.sound.music.time;
|
|
|
|
|
2022-02-18 16:29:29 -05:00
|
|
|
funnyWave.thickness = CoolUtil.coolLerp(funnyWave.thickness, 2, 0.5);
|
|
|
|
funnyWave.waveAmplitude = Std.int(CoolUtil.coolLerp(funnyWave.waveAmplitude, 100, 0.1));
|
|
|
|
funnyWave.realtimeVisLenght = CoolUtil.coolLerp(funnyWave.realtimeVisLenght, 0.6, 0.1);
|
|
|
|
|
|
|
|
noteSpawner.forEachAlive((nt:FlxSprite) ->
|
|
|
|
{
|
|
|
|
// i forget how to make rhythm games
|
|
|
|
nt.x = (nt.ID - Conductor.songPosition) * (nt.ID / (Conductor.songPosition * 0.8));
|
|
|
|
|
|
|
|
if (nt.facing == FlxObject.RIGHT)
|
|
|
|
{
|
|
|
|
nt.x = FlxMath.remapToRange(nt.x, 0, FlxG.width, FlxG.width, 0);
|
|
|
|
nt.x -= FlxG.width / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nt.x += FlxG.width / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
nt.scale.x = FlxMath.remapToRange(nt.ID - Conductor.songPosition, 0, Conductor.crochet * 3, 0.2, 2);
|
|
|
|
nt.scale.y = FlxMath.remapToRange((nt.ID - Conductor.songPosition), 0, Conductor.crochet * 2, 6, 0.2);
|
|
|
|
|
|
|
|
if (nt.ID < Conductor.songPosition)
|
|
|
|
nt.kill();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (noteQueue.length > 0)
|
|
|
|
{
|
|
|
|
nextHitTmr.scale.y = FlxMath.remapToRange(Conductor.songPosition, prevNoteHit, noteQueue[0].strumTime, 1, 0);
|
|
|
|
|
|
|
|
darnellGhost.scale.x = darnellGhost.scale.y = FlxMath.remapToRange(Conductor.songPosition, prevNoteHit, noteQueue[0].strumTime, 2, 1);
|
|
|
|
darnellGhost.alpha = FlxMath.remapToRange(Conductor.songPosition, prevNoteHit, noteQueue[0].strumTime, 0.3, 0.1);
|
|
|
|
|
|
|
|
if (Conductor.songPosition >= noteQueue[0].strumTime)
|
|
|
|
{
|
|
|
|
prevNoteHit = noteQueue[0].strumTime;
|
|
|
|
|
|
|
|
noteQueue.shift();
|
|
|
|
|
|
|
|
darnell.doSomething(darnellGhost.curAction);
|
|
|
|
|
|
|
|
darnellGhost.doSomething();
|
|
|
|
darnellGhost.animation.curAnim.frameRate = 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (controls.NOTE_LEFT_P)
|
|
|
|
{
|
|
|
|
pico.punch();
|
|
|
|
}
|
|
|
|
if (controls.NOTE_LEFT_R)
|
2022-03-23 01:18:23 -04:00
|
|
|
pico.playAnimation('idle');
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
override function stepHit():Bool
|
2022-02-18 16:29:29 -05:00
|
|
|
{
|
2022-03-29 21:56:04 -04:00
|
|
|
return super.stepHit();
|
2022-02-18 16:29:29 -05:00
|
|
|
}
|
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
override function beatHit():Bool
|
2022-02-16 16:31:20 -05:00
|
|
|
{
|
2022-03-29 21:56:04 -04:00
|
|
|
// super.beatHit() returns false if a module cancelled the event.
|
|
|
|
if (!super.beatHit())
|
|
|
|
return false;
|
|
|
|
|
2022-02-18 16:29:29 -05:00
|
|
|
funnyWave.thickness = 10;
|
|
|
|
funnyWave.waveAmplitude = 300;
|
|
|
|
funnyWave.realtimeVisLenght = 0.1;
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
picoHealth += 1;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
|
|
|
makeNotes();
|
2022-03-29 21:56:04 -04:00
|
|
|
return true;
|
2022-02-16 16:31:20 -05:00
|
|
|
}
|
|
|
|
}
|