mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-01-30 16:36:55 +00:00
dir/color note helpers
This commit is contained in:
parent
fc2a20a1fd
commit
2aee6bcab8
216
source/Note.hx
216
source/Note.hx
|
@ -16,12 +16,7 @@ import polymod.format.ParseRules.TargetSignatureElement;
|
|||
|
||||
class Note extends FlxSprite
|
||||
{
|
||||
public var data:NoteData = {
|
||||
strumTime: 0,
|
||||
noteData: 0,
|
||||
sustainLength: 0,
|
||||
altNote: false
|
||||
};
|
||||
public var data = new NoteData();
|
||||
|
||||
public var mustPress:Bool = false;
|
||||
public var followsTime:Bool = true; // used if you want the note to follow the time shit!
|
||||
|
@ -38,6 +33,28 @@ class Note extends FlxSprite
|
|||
|
||||
public var colorSwap:ColorSwap;
|
||||
|
||||
/** the lowercase name of the note, for anim control, i.e. left right up down */
|
||||
public var dirName(get, never):String;
|
||||
inline function get_dirName() return data.dirName;
|
||||
|
||||
/** the uppercase name of the note, for anim control, i.e. left right up down */
|
||||
public var dirNameUpper(get, never):String;
|
||||
inline function get_dirNameUpper() return data.dirNameUpper;
|
||||
|
||||
/** the lowercase name of the note's color, for anim control, i.e. purple blue green red */
|
||||
public var colorName(get, never):String;
|
||||
inline function get_colorName() return data.colorName;
|
||||
|
||||
/** the lowercase name of the note's color, for anim control, i.e. purple blue green red */
|
||||
public var colorNameUpper(get, never):String;
|
||||
inline function get_colorNameUpper() return data.colorNameUpper;
|
||||
|
||||
public var highStakes(get, never):Bool;
|
||||
inline function get_highStakes() return data.highStakes;
|
||||
|
||||
public var lowStakes(get, never):Bool;
|
||||
inline function get_lowStakes() return data.lowStakes;
|
||||
|
||||
public static var swagWidth:Float = 160 * 0.7;
|
||||
public static var PURP_NOTE:Int = 0;
|
||||
public static var GREEN_NOTE:Int = 2;
|
||||
|
@ -58,7 +75,7 @@ class Note extends FlxSprite
|
|||
// anything below sick threshold is sick
|
||||
public static var arrowColors:Array<Float> = [1, 1, 1, 1];
|
||||
|
||||
public function new(strumTime:Float = 0, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false)
|
||||
public function new(strumTime:Float = 0, noteData:NoteType, ?prevNote:Note, ?sustainNote:Bool = false)
|
||||
{
|
||||
super();
|
||||
|
||||
|
@ -139,21 +156,8 @@ class Note extends FlxSprite
|
|||
shader = colorSwap.shader;
|
||||
updateColors();
|
||||
|
||||
switch (noteData)
|
||||
{
|
||||
case 0:
|
||||
x += swagWidth * 0;
|
||||
animation.play('purpleScroll');
|
||||
case 1:
|
||||
x += swagWidth * 1;
|
||||
animation.play('blueScroll');
|
||||
case 2:
|
||||
x += swagWidth * 2;
|
||||
animation.play('greenScroll');
|
||||
case 3:
|
||||
x += swagWidth * 3;
|
||||
animation.play('redScroll');
|
||||
}
|
||||
x += swagWidth * data.int;
|
||||
animation.play(data.colorName + 'Scroll');
|
||||
|
||||
// trace(prevNote);
|
||||
|
||||
|
@ -166,17 +170,7 @@ class Note extends FlxSprite
|
|||
|
||||
x += width / 2;
|
||||
|
||||
switch (noteData)
|
||||
{
|
||||
case 2:
|
||||
animation.play('greenholdend');
|
||||
case 3:
|
||||
animation.play('redholdend');
|
||||
case 1:
|
||||
animation.play('blueholdend');
|
||||
case 0:
|
||||
animation.play('purpleholdend');
|
||||
}
|
||||
animation.play(data.colorName + 'holdend');
|
||||
|
||||
updateHitbox();
|
||||
|
||||
|
@ -187,18 +181,7 @@ class Note extends FlxSprite
|
|||
|
||||
if (prevNote.isSustainNote)
|
||||
{
|
||||
switch (prevNote.data.noteData)
|
||||
{
|
||||
case 0:
|
||||
prevNote.animation.play('purplehold');
|
||||
case 1:
|
||||
prevNote.animation.play('bluehold');
|
||||
case 2:
|
||||
prevNote.animation.play('greenhold');
|
||||
case 3:
|
||||
prevNote.animation.play('redhold');
|
||||
}
|
||||
|
||||
prevNote.animation.play(prevNote.colorName + 'hold');
|
||||
prevNote.updateHitbox();
|
||||
|
||||
var scaleThing:Float = Math.round((Conductor.stepCrochet) * (0.45 * FlxMath.roundDecimal(SongLoad.getSpeed(), 2)));
|
||||
|
@ -269,12 +252,151 @@ class Note extends FlxSprite
|
|||
alpha = 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
static public function fromData(data:NoteData, prevNote:Note, isSustainNote = false)
|
||||
{
|
||||
return new Note(data.strumTime, data.noteData, prevNote, isSustainNote);
|
||||
}
|
||||
}
|
||||
|
||||
typedef NoteData =
|
||||
typedef RawNoteData =
|
||||
{
|
||||
var strumTime:Float;
|
||||
var noteData:Int;
|
||||
var noteData:NoteType;
|
||||
var sustainLength:Float;
|
||||
var altNote:Bool;
|
||||
}
|
||||
|
||||
@:forward
|
||||
abstract NoteData(RawNoteData)
|
||||
{
|
||||
public function new (strumTime = 0.0, noteData:NoteType = 0, sustainLength = 0.0, altNote = false)
|
||||
{
|
||||
this =
|
||||
{ strumTime : strumTime
|
||||
, noteData : noteData
|
||||
, sustainLength : sustainLength
|
||||
, altNote : altNote
|
||||
}
|
||||
}
|
||||
|
||||
public var note(get, never):NoteType;
|
||||
inline function get_note() return this.noteData.value;
|
||||
|
||||
public var int(get, never):Int;
|
||||
inline function get_int() return this.noteData.int;
|
||||
|
||||
public var dir(get, never):NoteDir;
|
||||
inline function get_dir() return this.noteData.value;
|
||||
|
||||
public var dirName(get, never):String;
|
||||
inline function get_dirName() return dir.name;
|
||||
|
||||
public var dirNameUpper(get, never):String;
|
||||
inline function get_dirNameUpper() return dir.nameUpper;
|
||||
|
||||
public var color(get, never):NoteColor;
|
||||
inline function get_color() return this.noteData.value;
|
||||
|
||||
public var colorName(get, never):String;
|
||||
inline function get_colorName() return color.name;
|
||||
|
||||
public var colorNameUpper(get, never):String;
|
||||
inline function get_colorNameUpper() return color.nameUpper;
|
||||
|
||||
public var highStakes(get, never):Bool;
|
||||
inline function get_highStakes() return this.noteData.highStakes;
|
||||
|
||||
public var lowStakes(get, never):Bool;
|
||||
inline function get_lowStakes() return this.noteData.lowStakes;
|
||||
}
|
||||
|
||||
enum abstract NoteType(Int) from Int to Int
|
||||
{
|
||||
// public var raw(get, never):Int;
|
||||
// inline function get_raw() return this;
|
||||
|
||||
public var int(get, never):Int;
|
||||
inline function get_int() return this < 0 ? -this : this % 4;
|
||||
|
||||
public var value(get, never):NoteType;
|
||||
inline function get_value() return int;
|
||||
|
||||
public var highStakes(get, never):Bool;
|
||||
inline function get_highStakes() return this > 3;
|
||||
|
||||
public var lowStakes(get, never):Bool;
|
||||
inline function get_lowStakes() return this < 0;
|
||||
}
|
||||
|
||||
@:forward
|
||||
enum abstract NoteDir(NoteType) from Int to Int from NoteType
|
||||
{
|
||||
var LEFT = 0;
|
||||
var DOWN = 1;
|
||||
var UP = 2;
|
||||
var RIGHT = 3;
|
||||
|
||||
var value(get, never):NoteDir;
|
||||
inline function get_value() return this.value;
|
||||
|
||||
public var name(get, never):String;
|
||||
function get_name()
|
||||
{
|
||||
return switch(value)
|
||||
{
|
||||
case LEFT : "left" ;
|
||||
case DOWN : "down" ;
|
||||
case UP : "up" ;
|
||||
case RIGHT: "right";
|
||||
}
|
||||
}
|
||||
|
||||
public var nameUpper(get, never):String;
|
||||
function get_nameUpper()
|
||||
{
|
||||
return switch(value)
|
||||
{
|
||||
case LEFT : "LEFT" ;
|
||||
case DOWN : "DOWN" ;
|
||||
case UP : "UP" ;
|
||||
case RIGHT: "RIGHT";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@:forward
|
||||
enum abstract NoteColor(NoteType) from Int to Int from NoteType
|
||||
{
|
||||
var PURPLE = 0;
|
||||
var BLUE = 1;
|
||||
var GREEN = 2;
|
||||
var RED = 3;
|
||||
|
||||
var value(get, never):NoteColor;
|
||||
inline function get_value() return this.value;
|
||||
|
||||
public var name(get, never):String;
|
||||
function get_name()
|
||||
{
|
||||
return switch(value)
|
||||
{
|
||||
case PURPLE: "purple";
|
||||
case BLUE : "blue" ;
|
||||
case GREEN : "green" ;
|
||||
case RED : "red" ;
|
||||
}
|
||||
}
|
||||
|
||||
public var nameUpper(get, never):String;
|
||||
function get_nameUpper()
|
||||
{
|
||||
return switch(value)
|
||||
{
|
||||
case PURPLE: "PURPLE";
|
||||
case BLUE : "BLUE" ;
|
||||
case GREEN : "GREEN" ;
|
||||
case RED : "RED" ;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package;
|
||||
|
||||
import Note;
|
||||
import Section.SwagSection;
|
||||
import SongLoad.SwagSong;
|
||||
import charting.ChartingState;
|
||||
|
@ -1592,7 +1593,7 @@ class PlayState extends MusicBeatState
|
|||
|
||||
var gottaHitNote:Bool = section.mustHitSection;
|
||||
|
||||
if (songNotes.noteData > 3)
|
||||
if (songNotes.highStakes)
|
||||
gottaHitNote = !section.mustHitSection;
|
||||
|
||||
var oldNote:Note;
|
||||
|
@ -2195,17 +2196,7 @@ class PlayState extends MusicBeatState
|
|||
|
||||
if (!daNote.isSustainNote)
|
||||
{
|
||||
switch (Math.abs(daNote.data.noteData))
|
||||
{
|
||||
case 0:
|
||||
dad.playAnim('singLEFT' + altAnim, true);
|
||||
case 1:
|
||||
dad.playAnim('singDOWN' + altAnim, true);
|
||||
case 2:
|
||||
dad.playAnim('singUP' + altAnim, true);
|
||||
case 3:
|
||||
dad.playAnim('singRIGHT' + altAnim, true);
|
||||
}
|
||||
dad.playAnim('sing' + daNote.dirNameUpper + altAnim, true);
|
||||
}
|
||||
|
||||
dad.holdTimer = 0;
|
||||
|
@ -2429,10 +2420,10 @@ class PlayState extends MusicBeatState
|
|||
|
||||
var healthMulti:Float = 1;
|
||||
|
||||
if (daNote.data.noteData >= 0)
|
||||
healthMulti *= 0.033;
|
||||
else
|
||||
if (daNote.lowStakes)
|
||||
healthMulti *= 0.002;
|
||||
else
|
||||
healthMulti *= 0.033;
|
||||
|
||||
if (noteDiff > Note.HIT_WINDOW * Note.BAD_THRESHOLD)
|
||||
{
|
||||
|
@ -2852,7 +2843,7 @@ class PlayState extends MusicBeatState
|
|||
return super.switchTo(nextState);
|
||||
}
|
||||
|
||||
function noteMiss(direction:Int = 1):Void
|
||||
function noteMiss(direction:NoteDir = 1):Void
|
||||
{
|
||||
// whole function used to be encased in if (!boyfriend.stunned)
|
||||
health -= 0.07;
|
||||
|
@ -2872,17 +2863,7 @@ class PlayState extends MusicBeatState
|
|||
boyfriend.stunned = false;
|
||||
});*/
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
boyfriend.playAnim('singLEFTmiss', true);
|
||||
case 1:
|
||||
boyfriend.playAnim('singDOWNmiss', true);
|
||||
case 2:
|
||||
boyfriend.playAnim('singUPmiss', true);
|
||||
case 3:
|
||||
boyfriend.playAnim('singRIGHTmiss', true);
|
||||
}
|
||||
boyfriend.playAnim('sing' + direction.nameUpper + 'miss', true);
|
||||
}
|
||||
|
||||
/* not used anymore lol
|
||||
|
@ -2915,17 +2896,7 @@ class PlayState extends MusicBeatState
|
|||
popUpScore(note.data.strumTime, note);
|
||||
}
|
||||
|
||||
switch (note.data.noteData)
|
||||
{
|
||||
case 0:
|
||||
boyfriend.playAnim('singLEFT', true);
|
||||
case 1:
|
||||
boyfriend.playAnim('singDOWN', true);
|
||||
case 2:
|
||||
boyfriend.playAnim('singUP', true);
|
||||
case 3:
|
||||
boyfriend.playAnim('singRIGHT', true);
|
||||
}
|
||||
boyfriend.playAnim('sing' + note.dirNameUpper, true);
|
||||
|
||||
playerStrums.forEach(function(spr:FlxSprite)
|
||||
{
|
||||
|
|
|
@ -161,12 +161,7 @@ class SongLoad
|
|||
|
||||
public static function getDefaultNoteData():NoteData
|
||||
{
|
||||
return {
|
||||
strumTime: 0,
|
||||
altNote: false,
|
||||
sustainLength: 0,
|
||||
noteData: 0
|
||||
}
|
||||
return new NoteData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue