Cleaned up direction animation code in:

Playstate.hx (player 1 & 2)
Note.hx (gfx load code & playAnim's)
This commit is contained in:
sperez
2021-07-09 17:44:50 -04:00
parent 690579843a
commit 54ba25145b
5 changed files with 120 additions and 147 deletions

View File

@ -38,6 +38,8 @@ class Note extends FlxSprite
public var rating:String = "shit";
public var dataColor:Array<String> = ['purple', 'blue', 'green', 'red'];
public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?inCharter:Bool = false)
{
super();
@ -73,26 +75,15 @@ class Note extends FlxSprite
switch (noteTypeCheck)
{
case 'pixel':
loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels','week6'), true, 17, 17);
animation.add('greenScroll', [6]);
animation.add('redScroll', [7]);
animation.add('blueScroll', [5]);
animation.add('purpleScroll', [4]);
loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels', 'week6'), true, 17, 17);
if (isSustainNote)
loadGraphic(Paths.image('weeb/pixelUI/arrowEnds', 'week6'), true, 7, 6);
for (i in 0...4)
{
loadGraphic(Paths.image('weeb/pixelUI/arrowEnds','week6'), true, 7, 6);
animation.add('purpleholdend', [4]);
animation.add('greenholdend', [6]);
animation.add('redholdend', [7]);
animation.add('blueholdend', [5]);
animation.add('purplehold', [0]);
animation.add('greenhold', [2]);
animation.add('redhold', [3]);
animation.add('bluehold', [1]);
animation.add(dataColor[i] + 'Scroll', [i + 4]); // Normal notes
animation.add(dataColor[i] + 'hold', [i]); // Holds
animation.add(dataColor[i] + 'holdend', [i + 4]); // Tails
}
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
@ -100,47 +91,27 @@ class Note extends FlxSprite
default:
frames = Paths.getSparrowAtlas('NOTE_assets');
animation.addByPrefix('greenScroll', 'green0');
animation.addByPrefix('redScroll', 'red0');
animation.addByPrefix('blueScroll', 'blue0');
animation.addByPrefix('purpleScroll', 'purple0');
animation.addByPrefix('purpleholdend', 'pruple end hold');
animation.addByPrefix('greenholdend', 'green hold end');
animation.addByPrefix('redholdend', 'red hold end');
animation.addByPrefix('blueholdend', 'blue hold end');
animation.addByPrefix('purplehold', 'purple hold piece');
animation.addByPrefix('greenhold', 'green hold piece');
animation.addByPrefix('redhold', 'red hold piece');
animation.addByPrefix('bluehold', 'blue hold piece');
for (i in 0...4)
{
animation.addByPrefix(dataColor[i] + 'Scroll', dataColor[i] + ' alone'); // Normal notes
animation.addByPrefix(dataColor[i] + 'hold', dataColor[i] + ' hold'); // Hold
animation.addByPrefix(dataColor[i] + 'holdend', dataColor[i] + ' tail'); // Tails
}
setGraphicSize(Std.int(width * 0.7));
updateHitbox();
antialiasing = true;
}
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 * noteData;
animation.play(dataColor[noteData] + 'Scroll');
// trace(prevNote);
// we make sure its downscroll and its a SUSTAIN NOTE (aka a trail, not a note)
// and flip it so it doesn't look weird.
// THIS DOESN'T FUCKING FLIP THE NOTE, CONTRIBUTERS DON'T JUST COMMENT THIS OUT JESUS
// then what is this lol
if (FlxG.save.data.downscroll && sustainNote)
flipY = true;
@ -151,17 +122,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(dataColor[noteData] + 'holdend');
updateHitbox();
@ -172,18 +133,7 @@ class Note extends FlxSprite
if (prevNote.isSustainNote)
{
switch (prevNote.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(dataColor[prevNote.noteData] + 'hold');
if(FlxG.save.data.scrollSpeed != 1)
prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * FlxG.save.data.scrollSpeed;

View File

@ -228,6 +228,9 @@ class PlayState extends MusicBeatState
private var executeModchart = false;
// Animation common suffixes
private var dataSuffix:Array<String> = ['LEFT', 'DOWN', 'UP', 'RIGHT'];
// API stuff
public function addObject(object:FlxBasic) { add(object); }
@ -2582,18 +2585,10 @@ class PlayState extends MusicBeatState
if (SONG.notes[Math.floor(curStep / 16)].altAnim)
altAnim = '-alt';
}
switch (Math.abs(daNote.noteData))
{
case 2:
dad.playAnim('singUP' + altAnim, true);
case 3:
dad.playAnim('singRIGHT' + altAnim, true);
case 1:
dad.playAnim('singDOWN' + altAnim, true);
case 0:
dad.playAnim('singLEFT' + altAnim, true);
}
// Accessing the animation name directly to play it
var singData:Int = Std.int(Math.abs(daNote.noteData));
dad.playAnim('sing' + dataSuffix[singData] + altAnim, true);
if (FlxG.save.data.cpuStrums)
{
@ -3530,17 +3525,8 @@ class PlayState extends MusicBeatState
// FlxG.sound.play(Paths.sound('missnote1'), 1, false);
// FlxG.log.add('played imss note');
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);
}
// Hole switch statement replaced with a single line :)
boyfriend.playAnim('sing' + dataSuffix[direction] + 'miss', true);
#if windows
if (luaModchart != null)
@ -3688,19 +3674,9 @@ class PlayState extends MusicBeatState
}
else
totalNotesHit += 1;
switch (note.noteData)
{
case 2:
boyfriend.playAnim('singUP', true);
case 3:
boyfriend.playAnim('singRIGHT', true);
case 1:
boyfriend.playAnim('singDOWN', true);
case 0:
boyfriend.playAnim('singLEFT', true);
}
var singData:Int = Std.int(note.noteData);
boyfriend.playAnim('sing' + dataSuffix[singData], true);
#if windows
if (luaModchart != null)