1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-26 15:07:14 +00:00

rippin my hair out at programming right now

This commit is contained in:
Cameron Taylor 2020-10-16 04:03:10 -07:00
parent f3fb40dc5e
commit 78ec82d953
3 changed files with 118 additions and 56 deletions

View file

@ -62,7 +62,11 @@ class ChartingState extends MusicBeatState
var _song:Song;
var typingShit:FlxInputText;
var gridSectionOffset:Int = 1;
/**
* What part of the SECTION it's on, relative to the grid.
*/
var page:Int = 1;
override function create()
{
@ -87,7 +91,8 @@ class ChartingState extends MusicBeatState
loadSong(_song.song);
Conductor.changeBPM(_song.bpm);
bpmTxt = new FlxText(450, 20, 0, "", 16);
bpmTxt = new FlxText(1000, 50, 0, "", 16);
bpmTxt.scrollFactor.set();
add(bpmTxt);
strumLine = new FlxSprite(0, 50).makeGraphic(Std.int(FlxG.width / 2), 4);
@ -150,6 +155,9 @@ class ChartingState extends MusicBeatState
tab_group_song.add(reloadSong);
UI_box.addGroup(tab_group_song);
UI_box.scrollFactor.set();
FlxG.camera.follow(strumLine);
}
var stepperLength:FlxUINumericStepper;
@ -233,23 +241,30 @@ class ChartingState extends MusicBeatState
if (wname == 'section_length')
{
_song.notes[curSection].lengthInSteps = Std.int(nums.value);
updateGrid();
}
}
// FlxG.log.add(id + " WEED " + sender + " WEED " + data + " WEED " + params);
}
var updatedSection:Bool = false;
override function update(elapsed:Float)
{
Conductor.songPosition = FlxG.sound.music.time;
_song.song = typingShit.text;
strumLine.y = getYfromStrum(Conductor.songPosition % (Conductor.stepCrochet * 16));
strumLine.y = getYfromStrum(Conductor.songPosition % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps));
if (curBeat % 4 == 0)
{
if (curStep > (_song.notes[curSection].lengthInSteps * 2) * (curSection + 1))
if (curStep > (_song.notes[curSection].lengthInSteps) * (curSection + 1))
{
trace(curStep);
trace((_song.notes[curSection].lengthInSteps) * (curSection + 1));
trace('DUMBSHIT');
if (_song.notes[curSection + 1] == null)
{
addSection();
@ -259,7 +274,10 @@ class ChartingState extends MusicBeatState
}
}
if (FlxG.mouse.overlaps(gridBG))
if (FlxG.mouse.x > gridBG.x
&& FlxG.mouse.x < gridBG.x + gridBG.width
&& FlxG.mouse.y > gridBG.y
&& FlxG.mouse.y < gridBG.y + (GRID_SIZE * _song.notes[curSection].lengthInSteps))
{
dummyArrow.x = Math.floor(FlxG.mouse.x / GRID_SIZE) * GRID_SIZE;
if (FlxG.keys.pressed.SHIFT)
@ -347,6 +365,8 @@ class ChartingState extends MusicBeatState
function changeSection(sec:Int = 0, ?updateMusic:Bool = true):Void
{
trace('changing section' + sec);
if (_song.notes[sec] != null)
{
curSection = sec;
@ -360,11 +380,12 @@ class ChartingState extends MusicBeatState
var daLength:Int = 0;
while (daNum <= sec)
{
daLength += _song.notes[daNum].lengthInSteps * 2;
daLength += _song.notes[daNum].lengthInSteps;
daNum++;
}
FlxG.sound.music.time = (daLength - (_song.notes[sec].lengthInSteps * 2)) * Conductor.stepCrochet;
FlxG.sound.music.time = (daLength - (_song.notes[sec].lengthInSteps)) * Conductor.stepCrochet;
updateCurStep();
}
updateSectionUI();
@ -444,6 +465,29 @@ class ChartingState extends MusicBeatState
return FlxMath.remapToRange(strumTime, 0, 16 * Conductor.stepCrochet, gridBG.y, gridBG.y + gridBG.height);
}
function calculateSectionLengths(?sec:Section):Int
{
var daLength:Int = 0;
for (i in _song.notes)
{
var swagLength = i.lengthInSteps;
if (i.typeOfSection == Section.COPYCAT)
swagLength * 2;
daLength += swagLength;
if (sec != null && sec == i)
{
trace('swag loop??');
break;
}
}
return daLength;
}
private var daSpacing:Float = 0.3;
function loadLevel():Void

View file

@ -1,5 +1,6 @@
package;
import flixel.FlxG;
import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.ui.FlxUIState;
@ -23,7 +24,7 @@ class MusicBeatState extends FlxUIState
{
everyStep();
curStep = Math.floor(Conductor.songPosition / Conductor.stepCrochet);
updateCurStep();
curBeat = Math.floor(curStep / 4);
super.update(elapsed);
@ -44,6 +45,12 @@ class MusicBeatState extends FlxUIState
}
}
private function updateCurStep():Void
{
Conductor.songPosition = FlxG.sound.music.time;
curStep = Math.floor(Conductor.songPosition / Conductor.stepCrochet);
}
public function stepHit():Void
{
totalSteps += 1;

View file

@ -259,66 +259,77 @@ class PlayState extends MusicBeatState
var playerCounter:Int = 0;
while (playerCounter < 2)
var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped
var totalLength:Int = 0; // Total length of the song, in beats;
for (section in noteData)
{
var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped
var totalLength:Int = 0; // Total length of the song, in beats;
for (section in noteData)
var dumbassSection:Array<Dynamic> = section.notes;
var coolSection:Int = Std.int(section.lengthInSteps / 4);
if (coolSection <= 4) // FIX SINCE MOST THE SHIT I MADE WERE ONLY 3 HTINGS LONG LOl
coolSection = 4;
else if (coolSection <= 8)
coolSection = 8;
for (songNotes in dumbassSection)
{
var dumbassSection:Array<Dynamic> = section.notes;
sectionScores[0].push(0);
sectionScores[1].push(0);
var coolSection:Int = Std.int(section.lengthInSteps / 4);
var daStrumTime:Float = songNotes[0] + (Conductor.stepCrochet * section.lengthInSteps);
trace(daStrumTime);
var daNoteData:Int = songNotes[1];
if (coolSection <= 4) // FIX SINCE MOST THE SHIT I MADE WERE ONLY 3 HTINGS LONG LOl
coolSection = 4;
else if (coolSection <= 8)
coolSection = 8;
var daStrumTime:Float = daStrumTime;
for (songNotes in dumbassSection)
var oldNote:Note;
if (unspawnNotes.length > 0)
oldNote = unspawnNotes[Std.int(unspawnNotes.length - 1)];
else
oldNote = null;
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote);
swagNote.scrollFactor.set(0, 0);
unspawnNotes.push(swagNote);
swagNote.mustPress = section.mustHitSection;
if (swagNote.mustPress)
{
swagNote.x += (FlxG.width / 2); // general offset
}
else
{
sectionScores[0].push(0);
sectionScores[1].push(0);
var daStrumTime:Float = songNotes[0] + ((Conductor.stepCrochet * 16) * playerCounter);
trace(daStrumTime);
var daNoteData:Int = songNotes[1];
var daStrumTime:Float = daStrumTime;
var oldNote:Note;
if (unspawnNotes.length > 0)
oldNote = unspawnNotes[Std.int(unspawnNotes.length - 1)];
else
oldNote = null;
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote);
swagNote.scrollFactor.set(0, 0);
unspawnNotes.push(swagNote);
swagNote.x += ((FlxG.width / 2) * playerCounter); // general offset
if (playerCounter == 1) // is the player
{
swagNote.mustPress = true;
}
else
{
sectionScores[0][daBeats] += swagNote.noteScore;
}
}
// only need to do it once
if (playerCounter == 0)
sectionLengths.push(Math.round(coolSection / 4));
totalLength += Math.round(coolSection / 4);
daBeats += 1;
// WILL HAVE TO REDO SCORE SYSTEM
/* if (section.mustHitSection)
{
if (playerCounter == 1) // is the player
{
swagNote.mustPress = true;
}
else
{
//sectionScores[0][daBeats] += swagNote.noteScore;
}
}
*/
}
trace(unspawnNotes.length);
playerCounter += 1;
/* // only need to do it once
if (section.mustHitSection)
sectionLengths.push(Math.round(coolSection / 4));
*/
totalLength += Math.round(coolSection / 4);
daBeats += 1;
}
trace(unspawnNotes.length);
// playerCounter += 1;
unspawnNotes.sort(sortByShit);
}