Skip to content

Commit

Permalink
convert to roll, fix rendering of SUS note
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDrawingCoder-Gamer committed Jul 9, 2024
1 parent 5dc0170 commit 120988d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 61 deletions.
Binary file modified art/arrowendsnew.aseprite
Binary file not shown.
Binary file modified assets/images/arrowends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 25 additions & 56 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ class PlayState extends UIState{
strumLine = new StrumLine();
curRenderedNotes = new FlxTypedSpriteGroup<Note>();
curRenderedSus = new FlxTypedSpriteGroup<SusNote>();
// make it ridulously big
// TODO: Camera scrolling
// staffLines = new FlxSprite().makeGraphic(FlxG.width, 1000 * LINE_SPACING, FlxColor.BLACK);
staffLineGroup = new FlxTypedSpriteGroup<Line>();
staffLineGroup.setPosition(0, 0);
strumLine.setup(Gamemode.gamemodes["dance-single"]);
Expand Down Expand Up @@ -225,9 +223,6 @@ class PlayState extends UIState{
selectBox.visible = false;
selectBox.scrollFactor.set();
// addUI();
add(strumLine);
add(curRenderedNotes);
add(curRenderedSus);
add(chart);
add(snaptext);
add(curMeasureTxt);
Expand Down Expand Up @@ -670,12 +665,10 @@ class PlayState extends UIState{
{
selectNote(i);
}
/*
else if (FlxG.keys.pressed.A)
else if (FlxG.keys.pressed.GRAVEACCENT)
{
convertToRoll(i);
}
*/
else
{
addNote(i);
Expand Down Expand Up @@ -707,13 +700,6 @@ class PlayState extends UIState{
if (change != 0)
strumLine.y = Math.round(strumLine.y / curSnap) * curSnap;
var strumRow = getRow(strumLine.y);
/*
if (curSelectedNote != null)
{
curSelectedNote.length = strumTime - curSelectedNote.time;
curSelectedNote.length = FlxMath.bound(curSelectedNote.length, 0);
}
*/
if (curHoldSelect != null)
{
curHoldSelect.length = strumRow - curHoldSelect.rowTime;
Expand Down Expand Up @@ -757,49 +743,16 @@ class PlayState extends UIState{
m += 1;
}
}
/*
function convertToRoll(id:Int)
function convertToRoll(id:Int): Void
{
selectNote(id);
var sections = [];
// nothing fancy, just generate rolls
if (curSelectedNote != null)
{
if (curSelectedNote[2] > 0)
{
for (sussy in 0...Math.floor(curSelectedNote[2] / Conductor.stepCrochet))
{
var goodSection = getSussySectionFromY(getSussyYPos(curSelectedNote[0] + sussy * Conductor.stepCrochet));
sections.push(goodSection);
var noteData = id;
if (_song.notes[goodSection].mustHitSection)
{
var sussyInfo = 0;
if (noteData > 3)
{
sussyInfo = noteData % 4;
}
else
{
sussyInfo = noteData + 4;
}
noteData = sussyInfo;
}
_song.notes[goodSection].sectionNotes.push([
curSelectedNote[0] + sussy * Conductor.stepCrochet,
noteData,
0,
curSelectedNote[3],
curSelectedNote[4]
]);
}
}
curSelectedNote[2] = 0;
switch (getNoteAt(id)) {
case null: return;
case note:
if (note.length <= 0) return;
note.isRoll = !note.isRoll;
noteDisplayDirty = true;
}
deselectNote();
updateNotes(sections);
}
*/

private function addNote(id:Int):Void
{
Expand Down Expand Up @@ -938,6 +891,18 @@ class PlayState extends UIState{
// noteInfo.visible = false;
}

private function getNoteAt(id: Int): Null<SongNoteData> {
if (songData == null) return null;
if (currentSongChart?.notes == null) return null;
final noteRow = getRow(strumLine.members[id].y);
final noteData = id;
for (note in currentSongChart.notes) {
if (note.rowTime == noteRow && note.data == noteData) {
return note;
}
}
return null;
}
private function selectNote(id:Int):Void
{
if (songData == null) return;
Expand Down Expand Up @@ -1028,14 +993,16 @@ class PlayState extends UIState{
holdNoteSprite.kill();
} else {
displayedHoldNoteData.push(holdNoteSprite.noteData);
holdNoteSprite.sustainLength = holdNoteSprite.noteData.length;
holdNoteSprite.updateHoldNotePosition();
}
}
displayedHoldNoteData.insertionSort((a, b) -> FlxSort.byValues(FlxSort.ASCENDING, a.rowTime, b.rowTime));
for (noteData in currentSongChart.notes) {
if (noteData == null) continue;

if (displayedNoteData.fastContains(noteData)) {

if (displayedNoteData.fastContains(noteData) && (noteData.length == 0 || displayedHoldNoteData.fastContains(noteData))) {
continue;
}

Expand All @@ -1052,6 +1019,8 @@ class PlayState extends UIState{
final holdNoteSprite = curRenderedSus.recycle(() -> new SusNote(this));
noteSprite.childSus = holdNoteSprite;

holdNoteSprite.parentState = this;

holdNoteSprite.noteData = noteSprite.noteData;

holdNoteSprite.sustainLength = noteSprite.noteData.length;
Expand Down
11 changes: 6 additions & 5 deletions source/SustainTrail.hx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SustainTrail extends FlxSprite
* At what point the bottom for the trail's end should be clipped off.
* Used in cases where there's an extra bit of the graphic on the bottom to avoid antialiasing issues with overflow.
*/
public var bottomClip:Float = 1;
public var bottomClip:Float = 15 / 16;

public var isPixel:Bool;

Expand Down Expand Up @@ -126,6 +126,7 @@ class SustainTrail extends FlxSprite
indices = new DrawData<Int>(12, true, TRIANGLE_VERTEX_INDICES);

this.active = true; // This NEEDS to be true for the note to be drawn!
this.useFramePixels = true;
}

function getBaseScrollSpeed()
Expand Down Expand Up @@ -232,7 +233,7 @@ class SustainTrail extends FlxSprite
// We are expecting an image containing 8 horizontal segments, each representing a different colored hold note followed by its end cap.

uvtData[0 * 2] = 0; // 0%/25%/50%/75% of the way through the image
uvtData[0 * 2 + 1] = isRoll ? 1 : 0.5; // top bound
uvtData[0 * 2 + 1] = 1; // top bound
// Top left

// Top right
Expand All @@ -241,7 +242,7 @@ class SustainTrail extends FlxSprite

// Bottom left
uvtData[2 * 2] = uvtData[0 * 2]; // 0%/25%/50%/75% of the way through the image
uvtData[2 * 2 + 1] = isRoll ? 0.5 : 0; // bottom bound
uvtData[2 * 2 + 1] = 0; // bottom bound

// Bottom right
uvtData[3 * 2] = uvtData[1 * 2]; // 12.5%/37.5%/62.5%/87.5% of the way through the image (1/8th past the top left)
Expand All @@ -267,15 +268,15 @@ class SustainTrail extends FlxSprite
// === END CAP UVs ===
// Top left
uvtData[4 * 2] = 0.5; // 12.5%/37.5%/62.5%/87.5% of the way through the image (1/8th past the top left of hold)
uvtData[4 * 2 + 1] = isRoll ? 0.5 : 0;
uvtData[4 * 2 + 1] = 0;

// Top right
uvtData[5 * 2] = 1; // right edge
uvtData[5 * 2 + 1] = uvtData[4 * 2 + 1]; // top bound

// Bottom left
uvtData[6 * 2] = uvtData[4 * 2]; // center
uvtData[6 * 2 + 1] = bottomClip * (isRoll ? 1 : 0.5); // bottom bound
uvtData[6 * 2 + 1] = bottomClip; // bottom bound

// Bottom right
uvtData[7 * 2] = uvtData[5 * 2]; // right Edge
Expand Down

0 comments on commit 120988d

Please sign in to comment.