Skip to content

Commit

Permalink
hmmmm
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed Apr 7, 2024
1 parent bb15635 commit 5887bd1
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 24 deletions.
40 changes: 40 additions & 0 deletions source/backend/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,46 @@ class CoolUtil
#end
}

/**
* Returns the most present color in a FlxSprite.
* @param sprite FlxSprite
* @param saturated Bool
* @return Int Color that is the most present.
*/
inline public static function getMostPresentColor(sprite:FlxSprite, saturated:Bool):FlxColor {
var colorMap:Map<FlxColor, Float> = [];
var color:FlxColor = 0;
var fixedColor:FlxColor = 0;
for(col in 0...sprite.frameWidth) {
for(row in 0...sprite.frameHeight) {
color = sprite.pixels.getPixel32(col, row);
fixedColor = FlxColor.BLACK + (color % 0x1000000);
if (colorMap[fixedColor] == null) colorMap[fixedColor] = 0;
if (saturated) colorMap[fixedColor] += color.alphaFloat * .33 + (.67 * (color.saturation * (2 * (color.lightness > .5 ? .5 - color.lightness : color.lightness))));
else colorMap[fixedColor] += color.alphaFloat;
}
}
var mostPresentColor:FlxColor = 0;
var mostPresentColorCount:Float = -1;
for(c => n in colorMap) {
if (n > mostPresentColorCount) {
mostPresentColorCount = n;
mostPresentColor = c;
}
}
return mostPresentColor;
}

public static function fastInverseSquareRoot(x:Float):Float {
var i:Int = cast(x);
var y:Float = x;
var x2:Float = x * .5;
i = 0x5f3759df - (i >> 1); // what the fuck?
y = cast(i);
y *= (1.5 - (x2 * y * y));
return y;
}

inline public static function sortByID(i:Int, basic1:FlxBasic, basic2:FlxBasic):Int {
return basic1.ID > basic2.ID ? -i : basic2.ID > basic1.ID ? i : 0;
}
Expand Down
16 changes: 7 additions & 9 deletions source/backend/HelperFunctions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import flixel.math.FlxMath;

class HelperFunctions
{
public static function truncateFloat( number : Float, precision : Int): Float {
var num = number;
num = num * Math.pow(10, precision);
num = Math.round( num ) / Math.pow(10, precision);
return num;
}
public static function truncateFloat(number:Float, ?precision:Int = 3):Float {
var num:Float = number;
num *= Math.pow(10, precision);
num = Math.round(num) / Math.pow(10, precision);
return num;
}

public static function GCD(a, b) {
return b == 0 ? FlxMath.absInt(a) : GCD(b, a % b);
}
public static function GCD(a, b) return b == 0 ? FlxMath.absInt(a) : GCD(b, a % b);
}
13 changes: 13 additions & 0 deletions source/debug/Argument.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ Usage:
${exeName} editmenuchar ["Mod Folder"]
${exeName} editsplash ["Mod Folder"]
${exeName} editcredits ["Mod Folder"]
${exeName} setupmod ["Mod Folder"]
${exeName} -h | --help
${exeName} -v | --version

Options:
-h --help Show this screen.
-v --version Show the current version of the engine.
-c --charsel Enables selecting a character when going to PlayState.
-s --story Enables story mode when in PlayState.
-d=<val> --diff=<val> Sets the difficulty for the song. [default: ${Difficulty.getDefault().toLowerCase().trim()}]
Expand All @@ -59,6 +62,16 @@ Options:
Sys.exit(0);
}


case '-v' | '--version':
{
Sys.println('Alleyway Engine v1.0 ALPHA
Psych Engine v1.0a
Friday Night Funkin\' v0.2.8');

Sys.exit(0);
}

case 'menu':
{
LoadingState.loadAndSwitchState(() -> new MainMenuState());
Expand Down
8 changes: 4 additions & 4 deletions source/debug/FPSCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ class FPSCounter extends TextField {

if (ClientPrefs.data.showTotalFPS) text += "\n" + totalFPS + " Total FPS";

if (ClientPrefs.data.memory) text += "\n" + CoolUtil.formatMemory(Std.int(currentlyMemory));
if (ClientPrefs.data.memory) text += "\n" + CoolUtil.formatMemory(Std.int(currentlyMemory)) + " RAM";

if (ClientPrefs.data.totalMemory) text += "\n" + CoolUtil.formatMemory(Std.int(maximumMemory));
if (ClientPrefs.data.totalMemory) text += "\n" + CoolUtil.formatMemory(Std.int(maximumMemory)) + " RAM (Peak)";

if (ClientPrefs.data.engineVersion) {
text += "\n[ALLEYWAY VER] 1.0b / [PE VER]" + MainMenuState.psychEngineVersion;
text += "\n[VS.FOXA VER] 3.0 SE";
text += "\nAlleyway 1.0b / [PE VER] " + MainMenuState.psychEngineVersion;
// text += "\n[VS.FOXA VER] 3.0 SE";
}

// #if debug
Expand Down
4 changes: 2 additions & 2 deletions source/options/VisualsUISubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ class VisualsUISubState extends BaseOptionsMenu
"If checked, shows the engine's version on the FPS Counter.", 'engineVersion', 'bool');
addOption(option);

#if debug
// #if debug
var option:Option = new Option('Debug Info Counter',
'If checked, shows debug info on the FPS Counter.', 'debugInfo', 'bool');
addOption(option);
#end
// #end

var option:Option = new Option('Rainbow FPS',
'If checked, gives the FPS counter a rainbow effect, like Kade Engine.', 'rainbowFPS', 'bool');
Expand Down
22 changes: 13 additions & 9 deletions source/states/editors/CharacterEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1056,18 +1056,22 @@ class CharacterEditorState extends MusicBeatState
{
var offX:Float = 0;
var offY:Float = 0;
if(!character.isPlayer){
offX = character.getMidpoint().x + 150 + character.cameraPosition[0];
offY = character.getMidpoint().y - 100 + character.cameraPosition[1];
}else{
offX = character.getMidpoint().x - 100 - character.cameraPosition[0];
offY = character.getMidpoint().y - 100 + character.cameraPosition[1];
final mid:FlxPoint = character.getMidpoint();
if(!character.isPlayer) {
offX = mid.x + 150 + character.cameraPosition[0];
offY = mid.y - 100 + character.cameraPosition[1];
} else {
offX = mid.x - 100 - character.cameraPosition[0];
offY = mid.y - 100 + character.cameraPosition[1];
}
cameraFollowPointer.setPosition(offX, offY);
mid.put();

if(snap){
FlxG.camera.scroll.x = cameraFollowPointer.getMidpoint().x - FlxG.width/2;
FlxG.camera.scroll.y = cameraFollowPointer.getMidpoint().y - FlxG.height/2;
if(snap) {
final midcam:FlxPoint = cameraFollowPointer.getMidpoint();
FlxG.camera.scroll.x = midcam.x - FlxG.width / 2;
FlxG.camera.scroll.y = midcam.y - FlxG.height / 2;
midcam.put();
}
}

Expand Down

0 comments on commit 5887bd1

Please sign in to comment.