Skip to content

Commit

Permalink
lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshubs authored and Yoshubs committed Sep 29, 2021
1 parent 57e7324 commit a55d993
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 51 deletions.
5 changes: 4 additions & 1 deletion source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Main extends Sprite

public static var gameVersion:String = '0.2.4.1';

public static var loadedAssets:Array<FlxBasic> = [];
public static var loadedAssets:Array<Dynamic> = [];

var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
Expand Down Expand Up @@ -235,6 +235,9 @@ class Main extends Sprite

public static function dumpCache()
{
// dump saved frames and shit
loadedAssets = [];

///* SPECIAL THANKS TO HAYA
@:privateAccess
for (key in FlxG.bitmap._cache.keys())
Expand Down
12 changes: 10 additions & 2 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,19 @@ class Paths

inline static public function getSparrowAtlas(key:String, ?library:String)
{
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
return cast(returnCached(FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library))), FlxAtlasFrames);
}

inline static public function getPackerAtlas(key:String, ?library:String)
{
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
return cast(returnCached(FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library))), FlxAtlasFrames);
}

// cache bullshit

static public function returnCached(asset:Dynamic) {
if (!Main.loadedAssets.contains(asset))
Main.loadedAssets.push(asset);
return Main.loadedAssets[Main.loadedAssets.indexOf(asset)];
}
}
1 change: 0 additions & 1 deletion source/gameFolder/gameObjects/Stage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ class Stage extends FlxTypedGroup<FlxBasic>

override function add(Object:FlxBasic):FlxBasic
{
Main.loadedAssets.insert(Main.loadedAssets.length, Object);
if (Init.trueSettings.get('Disable Antialiasing') && Std.isOfType(Object, FlxSprite))
cast(Object, FlxSprite).antialiasing = false;
return super.add(Object);
Expand Down
11 changes: 6 additions & 5 deletions source/gameFolder/meta/InfoHud.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gameFolder.meta;

// import Main;
import flixel.FlxG;
import haxe.Timer;
import openfl.events.Event;
import openfl.system.System;
Expand Down Expand Up @@ -74,14 +75,14 @@ class InfoHud extends TextField
times.shift();
}

// according to google, if this is wrong blame google lmao

// pretty sure that was to avoid optimisation issues and shit but like I dunno man I'm not writing an if statement that updates all of these at once
// if (currentCount != cacheCount && display)
// u h
text = "";
if (displayFps)
{
currentFPS = Math.round((times.length + cacheCount) / 2);
if (Math.isNaN(FlxG.updateFramerate))
currentFPS = Math.round((times.length + cacheCount) / 2);
else
currentFPS = FlxG.updateFramerate;
text += "FPS: " + currentFPS + "\n";
cacheCount = times.length;
}
Expand Down
2 changes: 1 addition & 1 deletion source/gameFolder/meta/data/dependency/FNFSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FNFSprite extends FlxSprite
override public function loadGraphic(Graphic:FlxGraphicAsset, Animated:Bool = false, Width:Int = 0, Height:Int = 0, Unique:Bool = false,
?Key:String):FNFSprite
{
var graph:FlxGraphic = FlxG.bitmap.add(Graphic, Unique, Key);
var graph:FlxGraphic = cast(Paths.returnCached(FlxG.bitmap.add(Graphic, Unique, Key)), FlxGraphic);
if (graph == null)
return this;

Expand Down
68 changes: 38 additions & 30 deletions source/gameFolder/meta/state/CustomTitlescreen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gameFolder.meta.state;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.addons.display.FlxBackdrop;
import flixel.addons.display.FlxGridOverlay;
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
import flixel.addons.transition.FlxTransitionableState;
Expand Down Expand Up @@ -61,6 +62,7 @@ class CustomTitlescreen extends MusicBeatState

var initLogowidth:Float = 0;
var newLogoScale:Float = 0;
var backdrop:FlxSprite;

function startIntro()
{
Expand Down Expand Up @@ -95,6 +97,12 @@ class CustomTitlescreen extends MusicBeatState
// bg.updateHitbox();
add(bg);

// cool bg
backdrop = new FlxSprite().makeGraphic(100, 100, 0xFF84A682);
backdrop.setGraphicSize(Std.int(bg.width), Std.int(bg.height));
backdrop.screenCenter();
add(backdrop);

logoBl = new FlxSprite();
logoBl.frames = Paths.getSparrowAtlas('menus/base/title/foreverlogo');
logoBl.animation.addByPrefix('bumpin', 'forever bop', 16, false, false, false);
Expand Down Expand Up @@ -171,29 +179,15 @@ class CustomTitlescreen extends MusicBeatState
logoBl.scale.x = FlxMath.lerp(newLogoScale, logoBl.scale.x, 0.95);
logoBl.scale.y = FlxMath.lerp(newLogoScale, logoBl.scale.y, 0.95);

var pressedEnter:Bool = FlxG.keys.justPressed.ENTER;

#if mobile
for (touch in FlxG.touches.list)
{
if (touch.justPressed)
{
pressedEnter = true;
}
}
#end
FlxTween.color(backdrop, 1, backdrop.color, FlxColor.BLACK);

var pressedEnter:Bool = FlxG.keys.justPressed.ENTER;
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;

if (gamepad != null)
{
if (gamepad.justPressed.START)
pressedEnter = true;

#if switch
if (gamepad.justPressed.B)
pressedEnter = true;
#end
}

if (pressedEnter && !transitioning && skippedIntro)
Expand All @@ -212,23 +206,10 @@ class CustomTitlescreen extends MusicBeatState
{
// Check if version is outdated

var version:String = "v" + Application.current.meta.get('version');
/*
if (version.trim() != NGio.GAME_VER_NUMS.trim() && !OutdatedSubState.leftState)
{
FlxG.switchState(new OutdatedSubState());
trace('OLD VERSION!');
trace('old ver');
trace(version.trim());
trace('cur ver');
trace(NGio.GAME_VER_NUMS.trim());
}
else
{ */
//var version:String = "v" + Application.current.meta.get('version');
Main.switchState(this, new MainMenuState());
// }
});
// FlxG.sound.play(Paths.music('titleShoot'), 0.7);
}

// hi game, please stop crashing its kinda annoyin, thanks!
Expand Down Expand Up @@ -273,7 +254,9 @@ class CustomTitlescreen extends MusicBeatState
override function beatHit()
{
super.beatHit();

logoBl.animation.play('bumpin');
backdrop.color = 0x84A682;

switch (curBeat)
{
Expand All @@ -282,6 +265,31 @@ class CustomTitlescreen extends MusicBeatState
}
}

override function stepHit()
{
super.stepHit();

switch (curStep)
{
case 4:
createCoolText(['Yoshubs']);
case 6:
addMoreText('Neolixn');
case 8:
addMoreText('Gedehari');
case 10:
addMoreText('Tsuraran');
case 12:
addMoreText('FlopDoodle');
case 16:
addMoreText('');
addMoreText('PRESENT');

case 24:
deleteCoolText();
}
}

var skippedIntro:Bool = false;

function skipIntro():Void
Expand Down
12 changes: 6 additions & 6 deletions source/gameFolder/meta/state/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,10 @@ class PlayState extends MusicBeatState
///*
if (daNote.isSustainNote
&& (((daNote.y + daNote.offset.y <= (strumline.receptors.members[Math.floor(daNote.noteData)].y + Note.swagWidth / 2))
&& !Init.trueSettings.get('Downscroll'))
|| (((daNote.y - (daNote.offset.y * daNote.scale.y) + daNote.height) >= (strumline.receptors.members[Math.floor(daNote.noteData)].y
+ Note.swagWidth / 2))
&& Init.trueSettings.get('Downscroll')))
&& !Init.trueSettings.get('Downscroll'))
|| (((daNote.y - (daNote.offset.y * daNote.scale.y) + daNote.height)
>= (strumline.receptors.members[Math.floor(daNote.noteData)].y + Note.swagWidth / 2))
&& Init.trueSettings.get('Downscroll')))
&& (autoplay || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit))))
{
var swagRectY = ((strumline.receptors.members[Math.floor(daNote.noteData)].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y);
Expand All @@ -955,7 +955,8 @@ class PlayState extends MusicBeatState
if (Init.trueSettings.get('Downscroll'))
{
swagRect.height = swagRectY;
swagRect.y -= swagRect.height - daNote.height;
// I'm literally a dumbass
swagRect.y += swagRect.height - daNote.height;
}
else
{
Expand Down Expand Up @@ -1728,7 +1729,6 @@ class PlayState extends MusicBeatState

override function add(Object:FlxBasic):FlxBasic
{
Main.loadedAssets.insert(Main.loadedAssets.length, Object);
if (Init.trueSettings.get('Disable Antialiasing') && Std.isOfType(Object, FlxSprite))
cast(Object, FlxSprite).antialiasing = false;
return super.add(Object);
Expand Down
80 changes: 75 additions & 5 deletions source/gameFolder/meta/state/charting/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import flixel.addons.ui.FlxUIDropDownMenu;
import flixel.addons.ui.FlxUIInputText;
import flixel.addons.ui.FlxUINumericStepper;
import flixel.addons.ui.FlxUITabMenu;
import flixel.graphics.FlxGraphic;
import flixel.group.FlxGroup;
import flixel.group.FlxSpriteGroup;
import flixel.math.FlxMath;
Expand Down Expand Up @@ -213,19 +214,25 @@ class ChartingState extends MusicBeatState
ForeverTools.killMusic([songMusic, vocals]);
Main.switchState(this, new PlayState());
}
}

override public function stepHit() {
// call all rendered notes lol
curRenderedNotes.forEach(function(epicNote:Note){
curRenderedNotes.forEach(function(epicNote:Note)
{
if ((epicNote.y < (strumLineCam.y - (FlxG.height / 2) - epicNote.height))
|| (epicNote.y > (strumLineCam.y + (FlxG.height / 2)))) {
|| (epicNote.y > (strumLineCam.y + (FlxG.height / 2))))
{
// do epic note calls for strum stuffs
if (Math.floor(Conductor.songPosition / Conductor.stepCrochet) == Math.floor(epicNote.strumTime / Conductor.stepCrochet)
&& (!hitSoundsPlayed.contains(epicNote))) {
if (Math.floor(Conductor.songPosition / Conductor.stepCrochet) == Math.floor(epicNote.strumTime / Conductor.stepCrochet)
&& (!hitSoundsPlayed.contains(epicNote)))
{
hitSoundsPlayed.push(epicNote);
}
}
});

super.stepHit();
}

function getStrumTime(yPos:Float):Float
Expand Down Expand Up @@ -255,6 +262,58 @@ class ChartingState extends MusicBeatState
fullGrid.height = (songMusic.length / Conductor.stepCrochet) * gridSize;

add(fullGrid);

}

public var sectionLineGraphic:FlxGraphic;
public var sectionCameraGraphic:FlxGraphic;
public var sectionStepGraphic:FlxGraphic;

private function regenerateSection(section:Int, placement:Float)
{
// this will be used to regenerate a box that shows what section the camera is focused on

// oh and section information lol
var sectionLine:FlxSprite = new FlxSprite(FlxG.width / 2 - (gridSize * (keysTotal / 2)) - (extraSize / 2), placement);
sectionLine.frames = sectionLineGraphic.imageFrame;
sectionLine.alpha = (88 / 255);

// section camera
var sectionExtend:Float = 0;
if (_song.notes[section].mustHitSection)
sectionExtend = (gridSize * (keysTotal / 2));

var sectionCamera:FlxSprite = new FlxSprite(FlxG.width / 2 - (gridSize * (keysTotal / 2)) + (sectionExtend), placement);
sectionCamera.frames = sectionCameraGraphic.imageFrame;
sectionCamera.alpha = (88 / 255);
curRenderedSections.add(sectionCamera);

// set up section numbers
for (i in 0...2)
{
var sectionNumber:FlxText = new FlxText(0, sectionLine.y - 12, 0, Std.string(section), 20);
// set the x of the section number
sectionNumber.x = sectionLine.x - sectionNumber.width - 5;
if (i == 1)
sectionNumber.x = sectionLine.x + sectionLine.width + 5;

sectionNumber.setFormat(Paths.font("vcr.ttf"), 24, FlxColor.WHITE);
sectionNumber.antialiasing = false;
sectionNumber.alpha = sectionLine.alpha;
curRenderedSections.add(sectionNumber);
}

for (i in 1...Std.int(_song.notes[section].lengthInSteps / 4))
{
// create a smaller section stepper
var sectionStep:FlxSprite = new FlxSprite(FlxG.width / 2 - (gridSize * (keysTotal / 2)) - (extraSize / 2),
placement + (i * (gridSize * 4)));
sectionStep.frames = sectionStepGraphic.imageFrame;
sectionStep.alpha = sectionLine.alpha;
curRenderedSections.add(sectionStep);
}

curRenderedSections.add(sectionLine);
}

var sectionsMax = 0;
Expand All @@ -266,9 +325,11 @@ class ChartingState extends MusicBeatState
curRenderedSustains.clear();

//sectionsMax = 1;
generateSection();
for (section in 0..._song.notes.length)
{
sectionsMax = section;
regenerateSection(section, 16 * gridSize * section);
for (i in _song.notes[section].sectionNotes)
{
// note stuffs
Expand All @@ -283,6 +344,15 @@ class ChartingState extends MusicBeatState
//sectionsMax--;
}

var extraSize = 6;

function generateSection() {
// pregenerate assets so it doesnt destroy your ram later
sectionLineGraphic = FlxG.bitmap.create(gridSize * keysTotal + extraSize, 2, FlxColor.WHITE);
sectionCameraGraphic = FlxG.bitmap.create(Std.int(gridSize * (keysTotal / 2)), 16 * gridSize, FlxColor.fromRGB(43, 116, 219));
sectionStepGraphic = FlxG.bitmap.create(gridSize * keysTotal + extraSize, 1, FlxColor.WHITE);
}

function loadSong(daSong:String):Void
{
if (songMusic != null)
Expand Down

0 comments on commit a55d993

Please sign in to comment.