Skip to content

Commit

Permalink
Both Sides Mode done
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLikesKirby committed Jun 18, 2024
1 parent 529c0a6 commit ec899bd
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 17 deletions.
25 changes: 22 additions & 3 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class FreeplayState extends MusicBeatState
var keyOption:FlxText;
var cantEarnText:FlxText;
var rNText:FlxText;
var bothSidesText:FlxText;
var rPNT:Array<String> = ['Off', 'Low Chance', 'Medium Chance', 'High Chance', 'Unfair'];

var loadingPack:Bool = false;
Expand Down Expand Up @@ -545,6 +546,14 @@ class FreeplayState extends MusicBeatState
add(rNText);
modeArray.push(rNText);

bothSidesText = new FlxText(settingsBG.x, settingsBG.y + 150, FlxG.save.data.bothSides ? "Both Sides: On (S)" : "Both Sides: Off (S)", 20);
bothSidesText.setFormat(Paths.font("comic.ttf"), 24, FlxColor.WHITE, RIGHT);
bothSidesText.antialiasing = true;
bothSidesText.scrollFactor.set();
bothSidesText.alpha = 0;
add(bothSidesText);
modeArray.push(bothSidesText);

pModeOption = new FlxText(settingsBG.x, settingsBG.y + 230, FlxG.save.data.practiceMode ? "Practice Mode: On (P)" : "Practice Mode: Off (P)", 5);
pModeOption.setFormat(Paths.font("comic.ttf"), 24, FlxColor.WHITE, RIGHT);
pModeOption.antialiasing = true;
Expand Down Expand Up @@ -652,7 +661,7 @@ class FreeplayState extends MusicBeatState
bgShader.shader.uTime.value[0] += elapsed;
}
#end
cantEarn = FlxG.save.data.botplay || FlxG.save.data.practiceMode || FlxG.save.data.oppM || FlxG.save.data.randomNotes || rPNT[FlxG.save.data.randomNoteTypes] != 'Off';
cantEarn = FlxG.save.data.botplay || FlxG.save.data.practiceMode || FlxG.save.data.oppM || FlxG.save.data.randomNotes || rPNT[FlxG.save.data.randomNoteTypes] != 'Off' || FlxG.save.data.bothSides;

if (cantEarn && cantEarnText != null) {
cantEarnText.visible = true;
Expand Down Expand Up @@ -774,6 +783,17 @@ class FreeplayState extends MusicBeatState
FlxG.sound.playMusic(Paths.inst(songs[curSelected].songName), 0);
#end
}
if (FlxG.keys.justPressed.S)
{
FlxG.save.data.bothSides = !FlxG.save.data.bothSides;
bothSidesText.text = FlxG.save.data.bothSides ? "Both Sides: On (S)" : "Both Sides: Off (S)";
if (FlxG.save.data.bothSides) {
FlxG.save.data.maniabutyeah = 0;
keyOption.text = "Keys Added: " + FlxG.save.data.maniabutyeah + " (U)";
FlxG.save.data.randomNotes = false;
randomOption.text = FlxG.save.data.randomNotes ? "Randomize Notes: On (R)" : "Randomize Notes: Off (R)";
}
}
if (FlxG.keys.justPressed.O)
{
FlxG.save.data.oppM = !FlxG.save.data.oppM;
Expand Down Expand Up @@ -803,11 +823,10 @@ class FreeplayState extends MusicBeatState
FlxG.save.data.randomNoteTypes += 1;
if (FlxG.save.data.randomNoteTypes > 4)
FlxG.save.data.randomNoteTypes = 0;

trace(FlxG.save.data.randomNoteTypes);

rNText.text = "Randomly Place Note Types: " + rPNT[FlxG.save.data.randomNoteTypes] + " (I)";
}

if (FlxG.keys.justPressed.B)
{
FlxG.save.data.botplay = !FlxG.save.data.botplay;
Expand Down
5 changes: 4 additions & 1 deletion source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ class Note extends FlxSprite
public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?musthit:Bool = true, noteStyle:String = "normal", inCharter:Bool = false, guitarSection:Bool = false)
{
mania = PlayState.SONG.mania;
if (FlxG.save.data.maniabutyeah > 0 && FlxG.save.data.randomNotes) {
if (FlxG.save.data.maniabutyeah > 0 && FlxG.save.data.randomNotes && !FlxG.save.data.bothSides) {
mania = FlxG.save.data.maniabutyeah;
}
if (FlxG.save.data.bothSides) {
mania = 4;
}

swagWidth = widths[mania] * 0.7; //factor not the same as noteScale

Expand Down
100 changes: 88 additions & 12 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class PlayState extends MusicBeatState

var oppM:Bool;

var bothS:Bool;

var tweenTime:Float;

var songPosBar:FlxBar;
Expand Down Expand Up @@ -538,6 +540,8 @@ class PlayState extends MusicBeatState

oppM = FlxG.save.data.oppM && SONG.song.toLowerCase() != 'shredder' && !isStoryMode;

bothS = FlxG.save.data.bothSides && SONG.song.toLowerCase() != 'shredder' && !isStoryMode;

settingsExist = FileSystem.exists(TitleState.modFolder + '/data/charts/' + PlayState.SONG.song.toLowerCase() + '-settings.json');

resetShader();
Expand Down Expand Up @@ -596,11 +600,14 @@ class PlayState extends MusicBeatState
scrollType = FlxG.save.data.downscroll ? 'downscroll' : 'upscroll';

mania = SONG.mania;
if (FlxG.save.data.maniabutyeah > 0 && FlxG.save.data.randomNotes) {
trace('uhh ' + FlxG.save.data.maniabutyeah);
if (FlxG.save.data.maniabutyeah > 0 && FlxG.save.data.randomNotes && !bothS) {
mania = FlxG.save.data.maniabutyeah;
}

if (bothS) {
mania = 4;
}

if (mania == 1) {
notestuffs = ['LEFT', 'DOWN', 'UP', 'UP', 'RIGHT'];
curmultDefine = [curmult[0], curmult[1], curmult[2], curmult[2], curmult[3]];
Expand Down Expand Up @@ -634,6 +641,10 @@ class PlayState extends MusicBeatState

pMode = FlxG.save.data.practiceMode;

if (FlxG.save.data.randomNoteTypes > 0 || bothS || chartEditorMode) {
cantSaveScore = true;
}

notbeingalittleCheater = !botPlay && !pMode && !oppM && !cantSaveScore && !FlxG.save.data.randomNotes;
trace(notbeingalittleCheater);

Expand Down Expand Up @@ -2431,7 +2442,7 @@ class PlayState extends MusicBeatState
Conductor.songPosition -= Conductor.crochet * 5;
var swagCounter:Int = 0;

if (FlxG.save.data.middleScroll && !noMiddleScrollSongs.contains(SONG.song.toLowerCase())) {
if (FlxG.save.data.middleScroll || bothS && !noMiddleScrollSongs.contains(SONG.song.toLowerCase())) {
playerStrums.forEach(function(spr:StrumNote)
{
spr.centerStrum();
Expand Down Expand Up @@ -2851,7 +2862,6 @@ class PlayState extends MusicBeatState
}

if (FlxG.save.data.randomNoteTypes > 0) {
cantSaveScore = true;

var random = 0;
if (FlxG.save.data.randomNoteTypes = 1) {
Expand Down Expand Up @@ -2881,7 +2891,7 @@ class PlayState extends MusicBeatState
gottaHitNote = !section.mustHitSection;
}

if(FlxG.save.data.randomNotes){
if(FlxG.save.data.randomNotes && !bothS){
if (mania == 1)
daNoteData = FlxG.random.int(0, 4);
else if (mania == 2)
Expand All @@ -2896,9 +2906,71 @@ class PlayState extends MusicBeatState
daNoteData = FlxG.random.int(0, 3);
}

if (oppM) {
if (bothS)
{
if (!gottaHitNote)
{
switch(daNoteData)
{
case 0:
trace('0');
daNoteData = 5;
case 1:
trace('1');
daNoteData = 6;
case 2:
trace('2');
daNoteData = 7;
case 3:
trace('3');
daNoteData = 12;
case 4:
trace('4');
daNoteData = 0;
case 5:
trace('5');
daNoteData = 1;
case 6:
trace('6');
daNoteData = 2;
case 7:
trace('7');
daNoteData = 4;
}
}
else
{
switch(daNoteData)
{
case 0:
daNoteData = 0;
case 1:
daNoteData = 1;
case 2:
daNoteData = 2;
case 3:
daNoteData = 3;
case 4:
daNoteData = 4;
case 5:
daNoteData = 5;
case 6:
daNoteData = 6;
case 7:
daNoteData = 7;
}
}
if (daNoteData > 7)
daNoteData -= 4;
}

if (oppM && !bothS) {
gottaHitNote = !gottaHitNote;
}
if (bothS)
{
gottaHitNote = true;
}

var oldNote:Note;
if (unspawnNotes.length > 0)
Expand Down Expand Up @@ -3337,7 +3409,7 @@ class PlayState extends MusicBeatState
{

var scrollSpeed = 150;
if (FlxG.save.data.randomNoteTypes < 0 && SONG.song.toLowerCase() != 'recursed') {
if (curStage == 'freeplay') {
charBackdrop.x -= scrollSpeed * elapsed;
charBackdrop.y += scrollSpeed * elapsed;

Expand Down Expand Up @@ -3944,6 +4016,9 @@ class PlayState extends MusicBeatState
{
scoreTxt.text += " | NO MISS!!";
}
if (!notbeingalittleCheater) {
scoreTxt.text += " | Can\'t Save Score";
}
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
{
persistentUpdate = false;
Expand Down Expand Up @@ -4077,7 +4152,6 @@ class PlayState extends MusicBeatState
return;
default:
chartEditorMode = true;
cantSaveScore = true;
#if SHADERS_ENABLED
resetShader();
#end
Expand All @@ -4092,7 +4166,6 @@ class PlayState extends MusicBeatState
if (FlxG.keys.justPressed.THREE)
{
chartEditorMode = true;
cantSaveScore = true;
if(FlxTransitionableState.skipNextTransIn)
{
Transition.nextCamera = null;
Expand Down Expand Up @@ -4193,7 +4266,7 @@ class PlayState extends MusicBeatState
FlxG.switchState(new AnimationDebug(boyfriend.curCharacter));
if (FlxG.keys.justPressed.TWO) //Go 10 seconds into the future :O
{
cantSaveScore = true;
chartEditorMode = true;
FlxG.sound.music.pause();
vocals.pause();
boyfriend.stunned = true;
Expand Down Expand Up @@ -6644,7 +6717,6 @@ if (oppM) {
}
}


switch (note.noteStyle)
{
default:
Expand Down Expand Up @@ -8290,7 +8362,9 @@ if (oppM) {
switch (curStep)
{
case 60:

switchNoteSide();

case 64 | 320 | 480 | 576 | 704 | 832 | 1024:
nofriendAttack();
case 992:
Expand Down Expand Up @@ -9474,6 +9548,7 @@ if (oppM) {

function switchNoteSide()
{
if (!FlxG.save.data.middleScroll && !bothS) {
for (i in 0...Main.keyAmmo[mania])
{
var curOpponentNote = dadStrums.members[i];
Expand All @@ -9484,6 +9559,7 @@ if (oppM) {
}
switchSide = !switchSide;
}
}

function switchNotePositions(order:Array<Int>)
{
Expand Down Expand Up @@ -9590,7 +9666,7 @@ if (oppM) {

function makeInvisibleNotes(invisible:Bool)
{
if (!oppM) {
if (!oppM && !bothS) {
if (invisible)
{
for (strumNote in strumLineNotes)
Expand Down
3 changes: 3 additions & 0 deletions source/SaveDataHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@ class SaveDataHandler

if (FlxG.save.data.randomNoteTypes == null)
FlxG.save.data.randomNoteTypes = 0;

if (FlxG.save.data.bothSides == null)
FlxG.save.data.bothSides = false;
}
}
5 changes: 4 additions & 1 deletion source/StrumNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ class StrumNote extends FlxSprite

alittleThing = PlayState.SONG.mania;

if (FlxG.save.data.maniabutyeah > 0 && FlxG.save.data.randomNotes) {
if (FlxG.save.data.maniabutyeah > 0 && FlxG.save.data.randomNotes && !FlxG.save.data.bothSides) {
alittleThing = FlxG.save.data.maniabutyeah;
}
if (FlxG.save.data.bothSides) {
alittleThing = 4;
}

// get the frames and stuff
switch (type)
Expand Down

0 comments on commit ec899bd

Please sign in to comment.