diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 00066b90..7c183aa3 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -224,10 +224,16 @@ class PlayState extends MusicBeatState * Interval at which Girlfriend dances. */ public var gfSpeed:Int = 1; + /** * Current health. Goes from 0 to maxHealth (defaults to 2) */ public var health:Float = 1; + + /** + * Maximum health the player can have. Defaults to 2. + */ + @:isVar public var maxHealth(get, set):Float = 2; /** * Current combo. */ @@ -445,6 +451,15 @@ class PlayState extends MusicBeatState curRating = event.rating; } + private inline function get_maxHealth() + return this.maxHealth; + private function set_maxHealth(v:Float) { + if (healthBar != null && healthBar.max == this.maxHealth) { + healthBar.setRange(healthBar.min, v); + } + return this.maxHealth = v; + } + override public function create() { instance = this; @@ -589,11 +604,13 @@ class PlayState extends MusicBeatState add(healthBarBG); healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this, - 'health', 0, 2); + 'health', 0, SONG.maxHealth); healthBar.scrollFactor.set(); healthBar.createFilledBar(0xFFFF0000, 0xFF66FF33); add(healthBar); + health = SONG.maxHealth / 2; + iconP1 = new HealthIcon(boyfriend.getIcon(), true); iconP2 = new HealthIcon(dad.getIcon(), false); @@ -834,6 +851,9 @@ class PlayState extends MusicBeatState { if (songData == null) songData = SONG; + if (songData.maxHealth != null && songData.maxHealth > 0) + maxHealth = songData.maxHealth; + Conductor.changeBPM(songData.bpm); curSong = songData.song.toLowerCase(); diff --git a/source/funkin/system/Song.hx b/source/funkin/system/Song.hx index 725cdfba..6e7ed5ef 100644 --- a/source/funkin/system/Song.hx +++ b/source/funkin/system/Song.hx @@ -21,6 +21,8 @@ typedef SwagSong = var player2:String; var gf:String; var validScore:Bool; + + var maxHealth:Null; } class Song