hold notes and temp bg

This commit is contained in:
Cameron Taylor 2020-10-04 22:13:12 -07:00
parent b4bfdb1a69
commit 3068e91ff7
2 changed files with 78 additions and 16 deletions

View file

@ -19,10 +19,12 @@ class Note extends FlxSprite
public static var swagWidth:Float = 160 * 0.7; public static var swagWidth:Float = 160 * 0.7;
public function new(strumTime:Float, noteData:Int) public function new(strumTime:Float, noteData:Int, prevNote:Note)
{ {
super(); super();
this.prevNote = prevNote;
x += 50; x += 50;
this.strumTime = strumTime; this.strumTime = strumTime;
@ -35,6 +37,16 @@ class Note extends FlxSprite
animation.addByPrefix('blueScroll', 'blue0'); animation.addByPrefix('blueScroll', 'blue0');
animation.addByPrefix('purpleScroll', 'purple0'); 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');
setGraphicSize(Std.int(width * 0.7)); setGraphicSize(Std.int(width * 0.7));
updateHitbox(); updateHitbox();
antialiasing = true; antialiasing = true;
@ -55,10 +67,49 @@ class Note extends FlxSprite
animation.play('purpleScroll'); animation.play('purpleScroll');
} }
if (noteData < 0) trace(prevNote);
if (noteData < 0 && prevNote != null)
{ {
noteScore * 0.2; noteScore * 0.2;
alpha = 0.6; alpha = 0.6;
x += width / 2;
switch (noteData)
{
case -1:
animation.play('greenholdend');
case -2:
animation.play('redholdend');
case -3:
animation.play('blueholdend');
case -4:
animation.play('purpleholdend');
}
updateHitbox();
x -= width / 2;
if (prevNote.noteData < 0)
{
switch (prevNote.noteData)
{
case -1:
prevNote.animation.play('greenhold');
case -2:
prevNote.animation.play('redhold');
case -3:
prevNote.animation.play('bluehold');
case -4:
prevNote.animation.play('purplehold');
}
prevNote.offset.y = -19;
prevNote.scale.y *= 2.25;
// prevNote.setGraphicSize();
}
} }
} }

View file

@ -13,6 +13,7 @@ import flixel.text.FlxText;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.util.FlxCollision; import flixel.util.FlxCollision;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import flixel.util.FlxSort;
import flixel.util.FlxStringUtil; import flixel.util.FlxStringUtil;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
import haxe.Json; import haxe.Json;
@ -50,8 +51,11 @@ class PlayState extends FlxState
override public function create() override public function create()
{ {
var bg:FlxSprite = FlxGridOverlay.create(50, 50); var bg:FlxSprite = new FlxSprite(-600, -200).loadGraphic(AssetPaths.bg__png);
bg.scrollFactor.set(0.5, 0.5); bg.setGraphicSize(Std.int(bg.width * 2.5));
bg.updateHitbox();
bg.antialiasing = true;
bg.scrollFactor.set(0.9, 0.9);
add(bg); add(bg);
dad = new Dad(100, 100); dad = new Dad(100, 100);
@ -69,7 +73,7 @@ class PlayState extends FlxState
playerStrums = new FlxTypedGroup<FlxSprite>(); playerStrums = new FlxTypedGroup<FlxSprite>();
generateSong('assets/data/fresh/fresh.json'); generateSong('bopeebo');
canHitText = new FlxText(10, 10, 0, "weed"); canHitText = new FlxText(10, 10, 0, "weed");
@ -98,7 +102,7 @@ class PlayState extends FlxState
generateStaticArrows(0); generateStaticArrows(0);
generateStaticArrows(1); generateStaticArrows(1);
var songData = Json.parse(Assets.getText(dataPath)); var songData = Json.parse(Assets.getText('assets/data/' + dataPath + '/' + dataPath + '.json'));
Conductor.changeBPM(songData.bpm); Conductor.changeBPM(songData.bpm);
FlxG.sound.playMusic("assets/music/" + songData.song + "_Inst.mp3"); FlxG.sound.playMusic("assets/music/" + songData.song + "_Inst.mp3");
@ -144,7 +148,13 @@ class PlayState extends FlxState
var daStrumTime:Float = ((daStep * Conductor.stepCrochet) + (Conductor.crochet * 8 * totalLength)) var daStrumTime:Float = ((daStep * Conductor.stepCrochet) + (Conductor.crochet * 8 * totalLength))
+ ((Conductor.crochet * coolSection) * playerCounter); + ((Conductor.crochet * coolSection) * playerCounter);
var swagNote:Note = new Note(daStrumTime, songNotes); var oldNote:Note;
if (notes.members.length > 0)
oldNote = notes.members[notes.members.length - 1];
else
oldNote = null;
var swagNote:Note = new Note(daStrumTime, songNotes, oldNote);
swagNote.scrollFactor.set(0, 0); swagNote.scrollFactor.set(0, 0);
swagNote.x += ((FlxG.width / 2) * playerCounter); // general offset swagNote.x += ((FlxG.width / 2) * playerCounter); // general offset
@ -158,11 +168,6 @@ class PlayState extends FlxState
sectionScores[0][daBeats] += swagNote.noteScore; sectionScores[0][daBeats] += swagNote.noteScore;
} }
if (notes.members.length > 0)
swagNote.prevNote = notes.members[notes.members.length - 1];
else
swagNote.prevNote = swagNote;
notes.add(swagNote); notes.add(swagNote);
} }
@ -180,6 +185,8 @@ class PlayState extends FlxState
} }
} }
var sortedNotes:Bool = false;
private function generateStaticArrows(player:Int):Void private function generateStaticArrows(player:Int):Void
{ {
for (i in 0...4) for (i in 0...4)
@ -319,6 +326,10 @@ class PlayState extends FlxState
} }
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * 0.45); daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * 0.45);
// one time sort
if (!sortedNotes)
notes.sort(FlxSort.byY, FlxSort.DESCENDING);
}); });
} }
@ -420,22 +431,22 @@ class PlayState extends FlxState
switch (spr.ID) switch (spr.ID)
{ {
case 1: case 1:
if (upP && spr.animation.curAnim.name != 'confirm' && !boyfriend.stunned) if (upP && spr.animation.curAnim.name != 'confirm')
spr.animation.play('pressed'); spr.animation.play('pressed');
if (upR) if (upR)
spr.animation.play('static'); spr.animation.play('static');
case 2: case 2:
if (rightP && spr.animation.curAnim.name != 'confirm' && !boyfriend.stunned) if (rightP && spr.animation.curAnim.name != 'confirm')
spr.animation.play('pressed'); spr.animation.play('pressed');
if (rightR) if (rightR)
spr.animation.play('static'); spr.animation.play('static');
case 3: case 3:
if (downP && spr.animation.curAnim.name != 'confirm' && !boyfriend.stunned) if (downP && spr.animation.curAnim.name != 'confirm')
spr.animation.play('pressed'); spr.animation.play('pressed');
if (downR) if (downR)
spr.animation.play('static'); spr.animation.play('static');
case 4: case 4:
if (leftP && spr.animation.curAnim.name != 'confirm' && !boyfriend.stunned) if (leftP && spr.animation.curAnim.name != 'confirm')
spr.animation.play('pressed'); spr.animation.play('pressed');
if (leftR) if (leftR)
spr.animation.play('static'); spr.animation.play('static');