Skip to content

Commit

Permalink
more logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Jul 27, 2024
1 parent 4c679d6 commit 549ac03
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
5 changes: 3 additions & 2 deletions source/states/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import game.Conductor;
import game.Note;
import game.Section;
import game.Song;

import flixel.ui.FlxButton;
import flixel.addons.ui.FlxUINumericStepper;

Expand Down Expand Up @@ -70,7 +71,7 @@ class ChartingState extends ExtendableState {
add(saveButton);

bpmStepper = new FlxUINumericStepper(10, 70, 1, 1, 1, 9999, 3);
bpmStepper.value = Conductor.bpm;
bpmStepper.value = song.bpm;
add(bpmStepper);
}

Expand Down Expand Up @@ -142,7 +143,7 @@ class ChartingState extends ExtendableState {
+ "\nSection: "
+ curSection
+ "\nBPM: "
+ Conductor.bpm
+ song.bpm
+ "\nCurStep: "
+ curStep
+ "\nCurBeat: "
Expand Down
32 changes: 24 additions & 8 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlayState extends ExtendableState {
var ratingDisplay:Rating;

var score:Int = 0;
var misses:Int = 0;
var scoreTxt:FlxText;
var timeBar:Bar;

Expand All @@ -33,9 +34,9 @@ class PlayState extends ExtendableState {
bpm: 100,
timeSignature: [4, 4]
};
} // idk if i can uncomment this yet
/*else
song = Json.parse(Paths.file("songs/" + song.song.toLowerCase() + "chart.json"));*/
}
else
song = Json.parse(Paths.file("songs/" + song.song.toLowerCase() + "chart.json"));

instance = this;
}
Expand All @@ -55,9 +56,9 @@ class PlayState extends ExtendableState {

resetSongPos();

var text = new FlxText(0, 0, 0, "Hello World", 64);
text.screenCenter();
add(text);
var tempBG:FlxSprite = FlxGridOverlay.create(720, 720);
tempBG.screenCenter(XY);
add(tempBG);

strumline = new FlxTypedGroup<Note>();
add(strumline);
Expand All @@ -74,6 +75,11 @@ class PlayState extends ExtendableState {
strumline.add(note);
}

scoreTxt = new FlxText(0, (FlxG.height * 0.89) + 36, FlxG.height, "Score: 0 // Misses: 0", 20);
scoreTxt.setFormat(Paths.font('vcr.ttf'), 48, FlxColor.WHITE, FlxTextAlign.CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
scoreTxt.screenCenter(X);
add(scoreTxt);

timeBar = new Bar(0, 0, FlxG.width, 10, FlxColor.WHITE, FlxColor.fromRGB(30, 144, 255));
timeBar.screenCenter(X);
timeBar.y = FlxG.height + 10;
Expand All @@ -84,17 +90,21 @@ class PlayState extends ExtendableState {
ratingDisplay.alpha = 0;
add(ratingDisplay);

FlxG.sound.playMusic(Paths.song(song.song.toLowerCase()));
FlxG.sound.music.onComplete = () -> endSong;

generateNotes();
}

function resetSongPos()
{
function resetSongPos() {
Conductor.songPosition = 0 - (Conductor.crochet * 4.5);
}

override function update(elapsed:Float) {
super.update(elapsed);

scoreTxt.text = 'Score: $score // Misses: $misses';

if (FlxG.sound.music != null && FlxG.sound.music.active && FlxG.sound.music.playing) {
Conductor.songPosition = FlxG.sound.music.time;
timeBar.value = (Conductor.songPosition / FlxG.sound.music.length);
Expand All @@ -118,6 +128,7 @@ class PlayState extends ExtendableState {
note.y = strum.y - (0.45 * (Conductor.songPosition - note.strum) * FlxMath.roundDecimal(speed, 2));

if (Conductor.songPosition > note.strum + (120 * songMultiplier) && note != null) {
misses++;
notes.remove(note);
note.kill();
note.destroy();
Expand Down Expand Up @@ -247,6 +258,11 @@ class PlayState extends ExtendableState {
}
}

function endSong() {
ExtendableState.switchState(new MenuState());
// FlxG.sound.playMusic(Paths.music('Rhythmic_Odyssey'));
}

function generateNotes() {
for (section in song.notes) {
Conductor.recalculateStuff(songMultiplier);
Expand Down
2 changes: 1 addition & 1 deletion source/states/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TitleState extends ExtendableState {

// will use this later
/*
var audio:AudioDisplay = new AudioDisplay(FlxG.sound.music, 0, FlxG.height, FlxG.width, FlxG.height, 200, FlxColor.WHITE);
var audio:AudioDisplay = new AudioDisplay(FlxG.sound.music, 0, FlxG.height, FlxG.width, FlxG.height, 200, FlxColor.LIME);
add(audio);
*/

Expand Down

0 comments on commit 549ac03

Please sign in to comment.