1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-25 16:24:40 +00:00

WIP on hold covers

This commit is contained in:
EliteMasterEric 2023-07-04 16:38:10 -04:00
parent 100565f9fc
commit b615fbf82a
6 changed files with 160 additions and 25 deletions

View file

@ -145,9 +145,9 @@ class InitState extends FlxTransitionableState
// NOTE: tileData is ignored if TransitionData.type is FADE instead of TILES.
var tileData:TransitionTileData = {asset: diamond, width: 32, height: 32};
FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(1, 1), tileData,
FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(0, -1), tileData,
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(1, 1), tileData,
FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(0, 1), tileData,
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
// Don't play transition in when entering the title state.
FlxTransitionableState.skipNextTransIn = true;

View file

@ -2190,6 +2190,11 @@ class PlayState extends MusicBeatState
playerStrumline.playNoteSplash(daNote.noteData.getDirection());
}
if (daNote.noteData.isHoldNote)
{
playerStrumline.playNoteHoldCover(daNote.noteData.getDirection());
}
// Only add the score if you're not on practice mode
if (!isPracticeMode)
{

View file

@ -0,0 +1,75 @@
package funkin.play.notes;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import funkin.play.notes.NoteDirection;
import flixel.graphics.frames.FlxFramesCollection;
import flixel.FlxG;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.FlxSprite;
class NoteHoldCover extends FlxTypedSpriteGroup<FlxSprite>
{
static final FRAMERATE_DEFAULT:Int = 24;
static var glowFrames:FlxAtlasFrames;
var glow:FlxSprite;
var sparks:FlxSprite;
public static function preloadFrames():Void
{
glowFrames = Paths.getSparrowAtlas('holdCoverRed');
}
public function new()
{
super(0, 0);
setup();
}
/**
* Add ALL the animations to this sprite. We will recycle and reuse the FlxSprite multiple times.
*/
function setup():Void
{
glow = new FlxSprite();
add(glow);
if (glowFrames == null) preloadFrames();
glow.frames = glowFrames;
glow.animation.addByPrefix('holdCoverRed', 'holdCoverRed0', FRAMERATE_DEFAULT, true, false, false);
glow.animation.addByPrefix('holdCoverEndRed', 'holdCoverEndRed0', FRAMERATE_DEFAULT, true, false, false);
glow.animation.finishCallback = this.onAnimationFinished;
if (glow.animation.getAnimationList().length < 2)
{
trace('WARNING: NoteHoldCover failed to initialize all animations.');
}
}
public function playStart(direction:NoteDirection):Void
{
glow.animation.play('holdCoverRed');
}
public function playContinue(direction:NoteDirection):Void
{
glow.animation.play('holdCoverRed');
}
public function playEnd(direction:NoteDirection):Void
{
glow.animation.play('holdCoverEndRed');
}
public function onAnimationFinished(animationName:String):Void
{
if (animationName.startsWith('holdCoverEnd'))
{
// *lightning* *zap* *crackle*
this.kill();
}
}
}

View file

@ -21,19 +21,6 @@ class NoteSprite extends FlxSprite
return this.strumTime;
}
/**
* The length of the note's sustain, in milliseconds.
* If 0, the note is a tap note.
*/
public var length(default, set):Float;
function set_length(value:Float):Float
{
this.length = value;
this.isSustainNote = (this.length > 0);
return this.length;
}
/**
* The time at which the note should be hit, in steps.
*/

View file

@ -1,16 +1,18 @@
package funkin.play.notes;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import funkin.ui.PreferencesMenu;
import funkin.play.notes.NoteSprite;
import flixel.util.FlxSort;
import funkin.play.notes.SustainTrail;
import funkin.util.SortUtil;
import funkin.play.song.SongData.SongNoteData;
import flixel.FlxG;
import flixel.group.FlxSpriteGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.util.FlxSort;
import funkin.play.notes.NoteHoldCover;
import funkin.play.notes.NoteSplash;
import funkin.play.notes.NoteSprite;
import funkin.play.notes.SustainTrail;
import funkin.play.song.SongData.SongNoteData;
import funkin.ui.PreferencesMenu;
import funkin.util.SortUtil;
/**
* A group of sprites which handles the receptor, the note splashes, and the notes (with sustains) for a given player.
@ -48,7 +50,7 @@ class Strumline extends FlxSpriteGroup
var strumlineNotes:FlxTypedSpriteGroup<StrumlineNote>;
var noteSplashes:FlxTypedSpriteGroup<NoteSplash>;
var sustainSplashes:FlxTypedSpriteGroup<NoteSplash>;
var noteHoldCovers:FlxTypedSpriteGroup<NoteHoldCover>;
var noteData:Array<SongNoteData> = [];
var nextNoteIndex:Int = -1;
@ -74,8 +76,12 @@ class Strumline extends FlxSpriteGroup
this.notes.zIndex = 30;
this.add(this.notes);
this.noteHoldCovers = new FlxTypedSpriteGroup<NoteHoldCover>(0, 0, 4);
this.noteHoldCovers.zIndex = 40;
this.add(this.noteHoldCovers);
this.noteSplashes = new FlxTypedSpriteGroup<NoteSplash>(0, 0, NOTE_SPLASH_CAP);
this.noteSplashes.zIndex = 40;
this.noteSplashes.zIndex = 50;
this.add(this.noteSplashes);
for (i in 0...KEY_COUNT)
@ -450,6 +456,27 @@ class Strumline extends FlxSpriteGroup
}
}
public function playNoteHoldCover(direction:NoteDirection):Void
{
// TODO: Add a setting to disable note splashes.
// if (Settings.noSplash) return;
var cover:NoteHoldCover = this.constructNoteHoldCover();
if (cover != null)
{
cover.playStart(direction);
cover.x = this.x;
cover.x += getXPos(direction);
cover.x -= cover.width / 8;
cover.x += INITIAL_OFFSET;
cover.y = this.y;
cover.y -= cover.height / 4;
//
}
}
public function buildNoteSprite(note:SongNoteData):NoteSprite
{
var noteSprite:NoteSprite = constructNoteSprite();
@ -530,6 +557,40 @@ class Strumline extends FlxSpriteGroup
return result;
}
/**
* Custom recycling behavior.
*/
function constructNoteHoldCover():NoteHoldCover
{
var result:NoteHoldCover = null;
// If we haven't filled the pool yet...
if (noteHoldCovers.length < noteHoldCovers.maxSize)
{
// Create a new note hold cover.
result = new NoteHoldCover();
this.noteHoldCovers.add(result);
}
else
{
// Else, find a note splash which is inactive so we can revive it.
result = this.noteHoldCovers.getFirstAvailable();
if (result != null)
{
result.revive();
}
else
{
// The note hold cover pool is full and all note hold covers are active,
// so we just pick one at random to destroy and restart.
result = FlxG.random.getObject(this.noteHoldCovers.members);
}
}
return result;
}
/**
* Custom recycling behavior.
*/

View file

@ -450,6 +450,13 @@ abstract SongNoteData(RawSongNoteData)
return this.l = value;
}
public var isHoldNote(get, never):Bool;
public function get_isHoldNote():Bool
{
return this.l > 0;
}
public var kind(get, set):String;
public function get_kind():String