This commit is contained in:
Yoshman29
2022-10-30 20:30:24 +01:00
parent 9c07bb26b7
commit fd2667bfa6
4 changed files with 111 additions and 74 deletions
+48 -74
View File
@@ -510,97 +510,65 @@ class PlayState extends MusicBeatState
for (i in 0...4)
{
// FlxG.log.add(i);
var babyArrow:Strum = new Strum(0, strumLine.y);
var babyArrow:Strum = new Strum((FlxG.width * 0.25) + (Note.swagWidth * (i - 2)) + ((FlxG.width / 2) * player), strumLine.y);
babyArrow.ID = i + (player * 4);
switch (curStage)
{
case 'school' | 'schoolEvil':
babyArrow.loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels'), true, 17, 17);
babyArrow.animation.add('green', [6]);
babyArrow.animation.add('red', [7]);
babyArrow.animation.add('blue', [5]);
babyArrow.animation.add('purplel', [4]);
var event = scripts.event("onStrumCreation", new StrumCreationEvent(babyArrow, player, i));
babyArrow.setGraphicSize(Std.int(babyArrow.width * daPixelZoom));
babyArrow.updateHitbox();
babyArrow.antialiasing = false;
switch (Math.abs(i))
{
case 0:
babyArrow.animation.add('static', [0]);
babyArrow.animation.add('pressed', [4, 8], 12, false);
babyArrow.animation.add('confirm', [12, 16], 24, false);
case 1:
babyArrow.animation.add('static', [1]);
babyArrow.animation.add('pressed', [5, 9], 12, false);
babyArrow.animation.add('confirm', [13, 17], 24, false);
case 2:
babyArrow.animation.add('static', [2]);
babyArrow.animation.add('pressed', [6, 10], 12, false);
babyArrow.animation.add('confirm', [14, 18], 12, false);
case 3:
babyArrow.animation.add('static', [3]);
babyArrow.animation.add('pressed', [7, 11], 12, false);
babyArrow.animation.add('confirm', [15, 19], 24, false);
}
default:
babyArrow.frames = Paths.getSparrowAtlas('NOTE_assets');
babyArrow.animation.addByPrefix('green', 'arrowUP');
babyArrow.animation.addByPrefix('blue', 'arrowDOWN');
babyArrow.animation.addByPrefix('purple', 'arrowLEFT');
babyArrow.animation.addByPrefix('red', 'arrowRIGHT');
babyArrow.antialiasing = true;
babyArrow.setGraphicSize(Std.int(babyArrow.width * 0.7));
switch (Math.abs(i))
{
case 0:
babyArrow.animation.addByPrefix('static', 'arrowLEFT');
babyArrow.animation.addByPrefix('pressed', 'left press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'left confirm', 24, false);
case 1:
babyArrow.animation.addByPrefix('static', 'arrowDOWN');
babyArrow.animation.addByPrefix('pressed', 'down press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'down confirm', 24, false);
case 2:
babyArrow.animation.addByPrefix('static', 'arrowUP');
babyArrow.animation.addByPrefix('pressed', 'up press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'up confirm', 24, false);
case 3:
babyArrow.animation.addByPrefix('static', 'arrowRIGHT');
babyArrow.animation.addByPrefix('pressed', 'right press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'right confirm', 24, false);
}
if (!event.cancelled) {
switch (curStage)
{
// case "school":
default:
babyArrow.frames = Paths.getSparrowAtlas('NOTE_assets');
babyArrow.animation.addByPrefix('green', 'arrowUP');
babyArrow.animation.addByPrefix('blue', 'arrowDOWN');
babyArrow.animation.addByPrefix('purple', 'arrowLEFT');
babyArrow.animation.addByPrefix('red', 'arrowRIGHT');
babyArrow.antialiasing = true;
babyArrow.setGraphicSize(Std.int(babyArrow.width * 0.7));
switch (babyArrow.ID % 4)
{
case 0:
babyArrow.animation.addByPrefix('static', 'arrowLEFT');
babyArrow.animation.addByPrefix('pressed', 'left press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'left confirm', 24, false);
case 1:
babyArrow.animation.addByPrefix('static', 'arrowDOWN');
babyArrow.animation.addByPrefix('pressed', 'down press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'down confirm', 24, false);
case 2:
babyArrow.animation.addByPrefix('static', 'arrowUP');
babyArrow.animation.addByPrefix('pressed', 'up press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'up confirm', 24, false);
case 3:
babyArrow.animation.addByPrefix('static', 'arrowRIGHT');
babyArrow.animation.addByPrefix('pressed', 'right press', 24, false);
babyArrow.animation.addByPrefix('confirm', 'right confirm', 24, false);
}
}
}
// babyArrow.x += Note.swagWidth * 1;
babyArrow.x = (FlxG.width * 0.25) + (Note.swagWidth * (i - 2));
babyArrow.updateHitbox();
babyArrow.scrollFactor.set();
if (!isStoryMode)
if (event.__doAnimation)
{
babyArrow.y -= 10;
babyArrow.alpha = 0;
FlxTween.tween(babyArrow, {y: babyArrow.y + 10, alpha: 1}, 1, {ease: FlxEase.circOut, startDelay: 0.5 + (0.2 * i)});
}
babyArrow.ID = i;
if (player == 1)
{
if (event.player == 1)
playerStrums.add(babyArrow);
} else {
else {
babyArrow.cpu = true;
cpuStrums.add(babyArrow);
}
babyArrow.animation.play('static');
babyArrow.x += ((FlxG.width / 2) * player);
strumLineNotes.add(babyArrow);
}
}
@@ -613,7 +581,10 @@ class PlayState extends MusicBeatState
override function openSubState(SubState:FlxSubState)
{
// TODO: Cancellable substate opening.
scripts.call("onSubstateOpen", [SubState]);
var event = scripts.event("onSubstateOpen", new SubstateEvent(SubState));
if (event.cancelled) return;
if (paused)
{
if (FlxG.sound.music != null)
@@ -631,7 +602,10 @@ class PlayState extends MusicBeatState
override function closeSubState()
{
scripts.call("onSubstateClose");
// TODO: Cancellable substate opening.
var event = scripts.event("onSubstateClose", new SubstateEvent(subState));
if (event.cancelled) return;
if (paused)
{
if (FlxG.sound.music != null && !startingSong)
@@ -0,0 +1,33 @@
package funkin.scripting.events;
class StrumCreationEvent extends CancellableEvent {
@:dox(hide) public var __doAnimation = !PlayState.isStoryMode;
/**
* The strum that is being created
*/
public var strum:Strum;
/**
* Player ID
*/
public var player:Int;
/**
* Strum ID, for the sprite.
*/
public var strumID:Int;
public function new(strum:Strum, player:Int, strumID:Int) {
this.strum = strum;
this.player = player;
this.strumID = strumID;
}
/**
* Cancels the animation that makes the strum "land" in the strumline.
*/
public function cancelAnimation() {__doAnimation = false;}
@:dox(hide) public function preventAnimation() {cancelAnimation();}
}
@@ -0,0 +1,12 @@
package funkin.scripting.events;
class SubstateEvent {
/**
* Substate that is about to be opened/closed
*/
public var substate:FlxSubState;
public function new(substate:FlxSubState) {
this.substate = substate;
}
}
+18
View File
@@ -87,4 +87,22 @@ interface PlayStateScript {
* @param event Event object containing information about the note.
*/
public function onNoteCreation(event:NoteCreationEvent):Void;
/**
* Triggered on each strum creation
* @param event Event object containing information about the strum.
*/
public function onStrumCreation(event:StrumCreationEvent):Void;
/**
* Triggered on substate open.
* @param event Event object containing the substate, which is cancellable.
*/
public function onSubstateOpen(event:SubstateEvent):Void;
/**
* Triggered on substate close.
* @param event Event object containing the substate, which is cancellable.
*/
public function onSubstateClose(event:SubstateEvent):Void;
}