From 97ba544409c4a1d6da279aada4ea7d303ea1f15e Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 1 Nov 2020 01:55:02 -0800 Subject: [PATCH] scores in progress --- CHANGELOG.md | 6 +- Project.xml | 2 +- source/GameOverSubstate.hx | 2 + source/MainMenuState.hx | 116 +++++++++++++++++++------------------ source/NGio.hx | 18 ++++++ source/PlayState.hx | 20 ++++++- source/TitleState.hx | 7 +++ 7 files changed, 112 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3898230a1..875bc460f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,16 @@ # Changelog All notable changes will be documented in this file. -## [Unreleased] +## [1.1.0] ### Added - 32bit support - Controller (dancepads) support - Pause screen - Main Menu overhaul - Cool intro screen thing +- Uh lots of bullshit +- Remind me to actually add this later lmaooo -## [0.1.0] - 2020-10-05 +## [1.0.0] - 2020-10-05 ### Added - Uh, everything. This the game's initial gamejam release. We put it out \ No newline at end of file diff --git a/Project.xml b/Project.xml index 32f3299ca..566ccbcc8 100644 --- a/Project.xml +++ b/Project.xml @@ -95,5 +95,5 @@ - + diff --git a/source/GameOverSubstate.hx b/source/GameOverSubstate.hx index e07074ec8..54df50cdd 100644 --- a/source/GameOverSubstate.hx +++ b/source/GameOverSubstate.hx @@ -12,6 +12,8 @@ class GameOverSubstate extends MusicBeatSubstate var bf:Boyfriend; var camFollow:FlxObject; + // var + public function new(x:Float, y:Float) { super(); diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 687f6191b..19ddb46bb 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -73,70 +73,76 @@ class MainMenuState extends MusicBeatState super.create(); } + var selectedSomethin:Bool = false; + override function update(elapsed:Float) { - if (controls.UP_P) + if (!selectedSomethin) { - FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt); - changeItem(-1); - } + if (controls.UP_P) + { + FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt); + changeItem(-1); + } - if (controls.DOWN_P) - { - FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt); - changeItem(1); - } + if (controls.DOWN_P) + { + FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt); + changeItem(1); + } - if (controls.BACK) - { - FlxG.switchState(new TitleState()); + if (controls.BACK) + { + FlxG.switchState(new TitleState()); + } + + if (controls.ACCEPT) + { + if (optionShit[curSelected] == 'donate') + { + FlxG.openURL('https://ninja-muffin24.itch.io/funkin'); + } + else + { + selectedSomethin = true; + FlxG.sound.play('assets/sounds/confirmMenu' + TitleState.soundExt); + + FlxFlicker.flicker(magenta, 1.1, 0.15, false); + + menuItems.forEach(function(spr:FlxSprite) + { + if (curSelected != spr.ID) + { + FlxTween.tween(spr, {alpha: 0}, 0.4, { + ease: FlxEase.quadOut, + onComplete: function(twn:FlxTween) + { + spr.kill(); + } + }); + } + else + { + FlxFlicker.flicker(spr, 1, 0.06, false, false, function(flick:FlxFlicker) + { + var daChoice:String = optionShit[curSelected]; + + switch (daChoice) + { + case 'story mode': + FlxG.switchState(new StoryMenuState()); + case 'freeplay': + FlxG.switchState(new FreeplayState()); + } + }); + } + }); + } + } } super.update(elapsed); - if (controls.ACCEPT) - { - if (optionShit[curSelected] == 'donate') - { - FlxG.openURL('https://ninja-muffin24.itch.io/funkin'); - } - else - { - FlxG.sound.play('assets/sounds/confirmMenu' + TitleState.soundExt); - - FlxFlicker.flicker(magenta, 1.1, 0.15, false); - - menuItems.forEach(function(spr:FlxSprite) - { - if (curSelected != spr.ID) - { - FlxTween.tween(spr, {alpha: 0}, 0.4, { - ease: FlxEase.quadOut, - onComplete: function(twn:FlxTween) - { - spr.kill(); - } - }); - } - else - { - FlxFlicker.flicker(spr, 1, 0.06, false, false, function(flick:FlxFlicker) - { - var daChoice:String = optionShit[curSelected]; - - switch (daChoice) - { - case 'story mode': - FlxG.switchState(new StoryMenuState()); - case 'freeplay': - FlxG.switchState(new FreeplayState()); - } - }); - } - }); - } - } - menuItems.forEach(function(spr:FlxSprite) { spr.screenCenter(X); diff --git a/source/NGio.hx b/source/NGio.hx index 9e350e258..f90bca4c4 100644 --- a/source/NGio.hx +++ b/source/NGio.hx @@ -109,6 +109,24 @@ class NGio // more info on scores --- http://www.newgrounds.io/help/components/#scoreboard-getscores } + inline static public function postScore(score:Int = 0, song:String) + { + if (isLoggedIn) + { + for (id in NG.core.scoreBoards.keys()) + { + var board = NG.core.scoreBoards.get(id); + + if (song == board.name) + { + board.postScore(score, "Uhh meow?"); + } + + // trace('loaded scoreboard id:$id, name:${board.name}'); + } + } + } + function onNGScoresFetch():Void { scoreboardsLoaded = true; diff --git a/source/PlayState.hx b/source/PlayState.hx index 785859183..2130a37bf 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -80,6 +80,7 @@ class PlayState extends MusicBeatState var halloweenBG:FlxSprite; var talking:Bool = true; + var songScore:Int = 0; override public function create() { @@ -808,6 +809,8 @@ class PlayState extends MusicBeatState { trace('SONG DONE' + isStoryMode); + NGio.postScore(songScore, SONG.song); + if (isStoryMode) { storyPlaylist.remove(storyPlaylist[0]); @@ -819,6 +822,11 @@ class PlayState extends MusicBeatState FlxG.switchState(new StoryMenuState()); StoryMenuState.weekUnlocked[1] = true; + + NGio.unlockMedal(60961); + + FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked; + FlxG.save.flush(); } else { @@ -856,22 +864,28 @@ class PlayState extends MusicBeatState // var rating:FlxSprite = new FlxSprite(); + var score:Int = 350; var daRating:String = "sick"; if (noteDiff > Conductor.safeZoneOffset * 0.9) { daRating = 'shit'; + score = 50; } else if (noteDiff > Conductor.safeZoneOffset * 0.75) { daRating = 'bad'; + score = 100; } else if (noteDiff > Conductor.safeZoneOffset * 0.2) { daRating = 'good'; + score = 200; } + songScore += score; + /* if (combo > 60) daRating = 'sick'; else if (combo > 12) @@ -921,7 +935,9 @@ class PlayState extends MusicBeatState numScore.acceleration.y = FlxG.random.int(200, 300); numScore.velocity.y -= FlxG.random.int(140, 160); numScore.velocity.x = FlxG.random.float(-5, 5); - add(numScore); + + if (combo >= 10 || combo == 0) + add(numScore); FlxTween.tween(numScore, {alpha: 0}, 0.2, { onComplete: function(tween:FlxTween) @@ -1107,6 +1123,8 @@ class PlayState extends MusicBeatState } combo = 0; + songScore -= 10; + FlxG.sound.play('assets/sounds/missnote' + FlxG.random.int(1, 3) + TitleState.soundExt, FlxG.random.float(0.1, 0.2)); // FlxG.sound.play('assets/sounds/missnote1' + TitleState.soundExt, 1, false); // FlxG.log.add('played imss note'); diff --git a/source/TitleState.hx b/source/TitleState.hx index 58611fdc6..12faa41c1 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -92,6 +92,13 @@ class TitleState extends MusicBeatState FlxG.sound.playMusic('assets/music/freakyMenu' + TitleState.soundExt, 0); FlxG.sound.music.fadeIn(4, 0, 0.7); + + FlxG.save.bind('funkin', 'ninjamuffin99'); + + if (FlxG.save.data.weekUnlocked != null) + { + StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked; + } } Conductor.changeBPM(102);