Skip to content

Commit

Permalink
hmmm
Browse files Browse the repository at this point in the history
* rebuilt health icons (also perhaps new winning icon support, will test in a bit)
* character editor scale fix
  • Loading branch information
charlesisfeline committed Aug 3, 2023
1 parent d3e83f8 commit f131058
Show file tree
Hide file tree
Showing 3 changed files with 1,032 additions and 636 deletions.
30 changes: 25 additions & 5 deletions source/objects/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class HealthIcon extends FlxSprite
private var isOldIcon:Bool = false;
private var isPlayer:Bool = false;
private var char:String = '';
private var defChar:String = '';

public function new(char:String = 'bf', isPlayer:Bool = false, ?allowGPU:Bool = true)
{
Expand All @@ -25,6 +26,14 @@ class HealthIcon extends FlxSprite
setPosition(sprTracker.x + sprTracker.width + 12, sprTracker.y - 30);
}

public function swapOldIcon()
{
if (isOldIcon = !isOldIcon)
changeIcon('bf-old');
else
changeIcon(defChar);
}

private var iconOffsets:Array<Float> = [0, 0];

public function changeIcon(char:String, ?allowGPU:Bool = true)
Expand All @@ -38,19 +47,30 @@ class HealthIcon extends FlxSprite
name = 'icons/icon-face'; // Prevents crash from missing icon

var graphic = Paths.image(name, allowGPU);
loadGraphic(graphic, true, Math.floor(graphic.width / 2), Math.floor(graphic.height));
var ratio = graphic.width / graphic.height;
if (ratio == 3 || ratio == 2 || ratio == 1)
loadGraphic(graphic, true, Math.floor(graphic.width / ratio), Math.floor(graphic.height));
else
{
trace("Invalid icon ratio for character: " + char);
loadGraphic(Paths.image("icons/icon-face", allowGPU), true, Math.floor(graphic.width / 2), Math.floor(graphic.height));
}

iconOffsets[0] = (width - 150) / 2;
iconOffsets[1] = (width - 150) / 2;
iconOffsets[1] = (height - 150) / 2;
updateHitbox();

animation.add(char, [0, 1], 0, false, isPlayer);
var anims:Array<Int> = (ratio == 3) ? [0, 1, 2] : (ratio == 1) ? [0] : [0, 1];
animation.add(char, anims, 0, false, isPlayer);
animation.play(char);
this.char = char;
if (!isOldIcon)
defChar = char;

if (char.endsWith('-pixel'))
{
antialiasing = false;
}
else
antialiasing = ClientPrefs.data.antialiasing;
}
}

Expand Down
Loading

0 comments on commit f131058

Please sign in to comment.