From 06104614ab4a92d49c0510313835dab48d5eec7f Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Wed, 5 Oct 2022 22:17:46 +0200 Subject: [PATCH] more characters + offsets auto fixing --- .../{dadbattle-easy.json => easy.json} | 0 .../{dadbattle-hard.json => hard.json} | 0 .../dadbattle/{dadbattle.json => normal.json} | 0 .../eggnog/{eggnog-easy.json => easy.json} | 0 .../eggnog/{eggnog-hard.json => hard.json} | 0 .../eggnog/{eggnog.json => normal.json} | 0 .../fresh/{fresh-easy.json => easy.json} | 0 .../fresh/{fresh-hard.json => hard.json} | 0 .../charts/fresh/{fresh.json => normal.json} | 0 .../charts/high/{high-easy.json => easy.json} | 0 .../charts/high/{high-hard.json => hard.json} | 0 assets/charts/high/{high.json => normal.json} | 0 .../charts/milf/{milf-easy.json => easy.json} | 0 .../charts/milf/{milf-hard.json => hard.json} | 0 assets/charts/milf/{milf.json => normal.json} | 0 .../monster/{monster-easy.json => easy.json} | 0 .../monster/{monster-hard.json => hard.json} | 0 .../monster/{monster.json => normal.json} | 0 .../philly/{philly-easy.json => easy.json} | 0 .../philly/{philly-hard.json => hard.json} | 0 .../philly/{philly.json => normal.json} | 0 .../charts/pico/{pico-easy.json => easy.json} | 0 .../charts/pico/{pico-hard.json => hard.json} | 0 assets/charts/pico/{pico.json => normal.json} | 0 .../charts/ridge/{ridge.json => normal.json} | 0 .../roses/{roses-easy.json => easy.json} | 0 .../roses/{roses-hard.json => hard.json} | 0 .../charts/roses/{roses.json => normal.json} | 0 .../{satin-panties-easy.json => easy.json} | 0 .../{satin-panties-hard.json => hard.json} | 0 .../{satin-panties.json => normal.json} | 0 .../senpai/{senpai-easy.json => easy.json} | 0 .../senpai/{senpai-hard.json => hard.json} | 0 .../senpai/{senpai.json => normal.json} | 0 .../charts/smash/{smash.json => normal.json} | 0 .../south/{south-easy.json => easy.json} | 0 .../south/{south-hard.json => hard.json} | 0 .../charts/south/{south.json => normal.json} | 0 .../{spookeez-easy.json => easy.json} | 0 .../{spookeez-hard.json => hard.json} | 0 .../spookeez/{spookeez.json => normal.json} | 0 .../thorns/{thorns-easy.json => easy.json} | 0 .../thorns/{thorns-hard.json => hard.json} | 0 .../thorns/{thorns.json => normal.json} | 0 .../{tutorial-easy.json => easy.json} | 0 .../{tutorial-hard.json => hard.json} | 0 .../tutorial/{tutorial.json => normal.json} | 0 ...{winter-horrorland-easy.json => easy.json} | 0 ...{winter-horrorland-hard.json => hard.json} | 0 .../{winter-horrorland.json => normal.json} | 0 assets/data/characters/bf.xml | 2 +- assets/data/characters/gf.xml | 31 ++++ assets/data/characters/mom-car.xml | 10 ++ .../characters/mom-car.png} | Bin .../characters/mom-car.xml} | 0 buildnumber.txt | 2 +- source/CoolUtil.hx | 33 ---- source/funkin/game/Character.hx | 170 +++++++++--------- source/funkin/game/PlayState.hx | 15 +- .../{system => interfaces}/IBeatReceiver.hx | 2 +- source/funkin/interfaces/IOffsetCompatible.hx | 5 + source/funkin/system/CoolUtil.hx | 83 +++++++++ source/funkin/system/MusicBeatState.hx | 1 + source/import.hx | 9 +- 64 files changed, 230 insertions(+), 133 deletions(-) rename assets/charts/dadbattle/{dadbattle-easy.json => easy.json} (100%) rename assets/charts/dadbattle/{dadbattle-hard.json => hard.json} (100%) rename assets/charts/dadbattle/{dadbattle.json => normal.json} (100%) rename assets/charts/eggnog/{eggnog-easy.json => easy.json} (100%) rename assets/charts/eggnog/{eggnog-hard.json => hard.json} (100%) rename assets/charts/eggnog/{eggnog.json => normal.json} (100%) rename assets/charts/fresh/{fresh-easy.json => easy.json} (100%) rename assets/charts/fresh/{fresh-hard.json => hard.json} (100%) rename assets/charts/fresh/{fresh.json => normal.json} (100%) rename assets/charts/high/{high-easy.json => easy.json} (100%) rename assets/charts/high/{high-hard.json => hard.json} (100%) rename assets/charts/high/{high.json => normal.json} (100%) rename assets/charts/milf/{milf-easy.json => easy.json} (100%) rename assets/charts/milf/{milf-hard.json => hard.json} (100%) rename assets/charts/milf/{milf.json => normal.json} (100%) rename assets/charts/monster/{monster-easy.json => easy.json} (100%) rename assets/charts/monster/{monster-hard.json => hard.json} (100%) rename assets/charts/monster/{monster.json => normal.json} (100%) rename assets/charts/philly/{philly-easy.json => easy.json} (100%) rename assets/charts/philly/{philly-hard.json => hard.json} (100%) rename assets/charts/philly/{philly.json => normal.json} (100%) rename assets/charts/pico/{pico-easy.json => easy.json} (100%) rename assets/charts/pico/{pico-hard.json => hard.json} (100%) rename assets/charts/pico/{pico.json => normal.json} (100%) rename assets/charts/ridge/{ridge.json => normal.json} (100%) rename assets/charts/roses/{roses-easy.json => easy.json} (100%) rename assets/charts/roses/{roses-hard.json => hard.json} (100%) rename assets/charts/roses/{roses.json => normal.json} (100%) rename assets/charts/satin-panties/{satin-panties-easy.json => easy.json} (100%) rename assets/charts/satin-panties/{satin-panties-hard.json => hard.json} (100%) rename assets/charts/satin-panties/{satin-panties.json => normal.json} (100%) rename assets/charts/senpai/{senpai-easy.json => easy.json} (100%) rename assets/charts/senpai/{senpai-hard.json => hard.json} (100%) rename assets/charts/senpai/{senpai.json => normal.json} (100%) rename assets/charts/smash/{smash.json => normal.json} (100%) rename assets/charts/south/{south-easy.json => easy.json} (100%) rename assets/charts/south/{south-hard.json => hard.json} (100%) rename assets/charts/south/{south.json => normal.json} (100%) rename assets/charts/spookeez/{spookeez-easy.json => easy.json} (100%) rename assets/charts/spookeez/{spookeez-hard.json => hard.json} (100%) rename assets/charts/spookeez/{spookeez.json => normal.json} (100%) rename assets/charts/thorns/{thorns-easy.json => easy.json} (100%) rename assets/charts/thorns/{thorns-hard.json => hard.json} (100%) rename assets/charts/thorns/{thorns.json => normal.json} (100%) rename assets/charts/tutorial/{tutorial-easy.json => easy.json} (100%) rename assets/charts/tutorial/{tutorial-hard.json => hard.json} (100%) rename assets/charts/tutorial/{tutorial.json => normal.json} (100%) rename assets/charts/winter-horrorland/{winter-horrorland-easy.json => easy.json} (100%) rename assets/charts/winter-horrorland/{winter-horrorland-hard.json => hard.json} (100%) rename assets/charts/winter-horrorland/{winter-horrorland.json => normal.json} (100%) create mode 100644 assets/data/characters/gf.xml create mode 100644 assets/data/characters/mom-car.xml rename assets/{week4/images/momCar.png => images/characters/mom-car.png} (100%) rename assets/{week4/images/momCar.xml => images/characters/mom-car.xml} (100%) delete mode 100644 source/CoolUtil.hx rename source/funkin/{system => interfaces}/IBeatReceiver.hx (81%) create mode 100644 source/funkin/interfaces/IOffsetCompatible.hx create mode 100644 source/funkin/system/CoolUtil.hx diff --git a/assets/charts/dadbattle/dadbattle-easy.json b/assets/charts/dadbattle/easy.json similarity index 100% rename from assets/charts/dadbattle/dadbattle-easy.json rename to assets/charts/dadbattle/easy.json diff --git a/assets/charts/dadbattle/dadbattle-hard.json b/assets/charts/dadbattle/hard.json similarity index 100% rename from assets/charts/dadbattle/dadbattle-hard.json rename to assets/charts/dadbattle/hard.json diff --git a/assets/charts/dadbattle/dadbattle.json b/assets/charts/dadbattle/normal.json similarity index 100% rename from assets/charts/dadbattle/dadbattle.json rename to assets/charts/dadbattle/normal.json diff --git a/assets/charts/eggnog/eggnog-easy.json b/assets/charts/eggnog/easy.json similarity index 100% rename from assets/charts/eggnog/eggnog-easy.json rename to assets/charts/eggnog/easy.json diff --git a/assets/charts/eggnog/eggnog-hard.json b/assets/charts/eggnog/hard.json similarity index 100% rename from assets/charts/eggnog/eggnog-hard.json rename to assets/charts/eggnog/hard.json diff --git a/assets/charts/eggnog/eggnog.json b/assets/charts/eggnog/normal.json similarity index 100% rename from assets/charts/eggnog/eggnog.json rename to assets/charts/eggnog/normal.json diff --git a/assets/charts/fresh/fresh-easy.json b/assets/charts/fresh/easy.json similarity index 100% rename from assets/charts/fresh/fresh-easy.json rename to assets/charts/fresh/easy.json diff --git a/assets/charts/fresh/fresh-hard.json b/assets/charts/fresh/hard.json similarity index 100% rename from assets/charts/fresh/fresh-hard.json rename to assets/charts/fresh/hard.json diff --git a/assets/charts/fresh/fresh.json b/assets/charts/fresh/normal.json similarity index 100% rename from assets/charts/fresh/fresh.json rename to assets/charts/fresh/normal.json diff --git a/assets/charts/high/high-easy.json b/assets/charts/high/easy.json similarity index 100% rename from assets/charts/high/high-easy.json rename to assets/charts/high/easy.json diff --git a/assets/charts/high/high-hard.json b/assets/charts/high/hard.json similarity index 100% rename from assets/charts/high/high-hard.json rename to assets/charts/high/hard.json diff --git a/assets/charts/high/high.json b/assets/charts/high/normal.json similarity index 100% rename from assets/charts/high/high.json rename to assets/charts/high/normal.json diff --git a/assets/charts/milf/milf-easy.json b/assets/charts/milf/easy.json similarity index 100% rename from assets/charts/milf/milf-easy.json rename to assets/charts/milf/easy.json diff --git a/assets/charts/milf/milf-hard.json b/assets/charts/milf/hard.json similarity index 100% rename from assets/charts/milf/milf-hard.json rename to assets/charts/milf/hard.json diff --git a/assets/charts/milf/milf.json b/assets/charts/milf/normal.json similarity index 100% rename from assets/charts/milf/milf.json rename to assets/charts/milf/normal.json diff --git a/assets/charts/monster/monster-easy.json b/assets/charts/monster/easy.json similarity index 100% rename from assets/charts/monster/monster-easy.json rename to assets/charts/monster/easy.json diff --git a/assets/charts/monster/monster-hard.json b/assets/charts/monster/hard.json similarity index 100% rename from assets/charts/monster/monster-hard.json rename to assets/charts/monster/hard.json diff --git a/assets/charts/monster/monster.json b/assets/charts/monster/normal.json similarity index 100% rename from assets/charts/monster/monster.json rename to assets/charts/monster/normal.json diff --git a/assets/charts/philly/philly-easy.json b/assets/charts/philly/easy.json similarity index 100% rename from assets/charts/philly/philly-easy.json rename to assets/charts/philly/easy.json diff --git a/assets/charts/philly/philly-hard.json b/assets/charts/philly/hard.json similarity index 100% rename from assets/charts/philly/philly-hard.json rename to assets/charts/philly/hard.json diff --git a/assets/charts/philly/philly.json b/assets/charts/philly/normal.json similarity index 100% rename from assets/charts/philly/philly.json rename to assets/charts/philly/normal.json diff --git a/assets/charts/pico/pico-easy.json b/assets/charts/pico/easy.json similarity index 100% rename from assets/charts/pico/pico-easy.json rename to assets/charts/pico/easy.json diff --git a/assets/charts/pico/pico-hard.json b/assets/charts/pico/hard.json similarity index 100% rename from assets/charts/pico/pico-hard.json rename to assets/charts/pico/hard.json diff --git a/assets/charts/pico/pico.json b/assets/charts/pico/normal.json similarity index 100% rename from assets/charts/pico/pico.json rename to assets/charts/pico/normal.json diff --git a/assets/charts/ridge/ridge.json b/assets/charts/ridge/normal.json similarity index 100% rename from assets/charts/ridge/ridge.json rename to assets/charts/ridge/normal.json diff --git a/assets/charts/roses/roses-easy.json b/assets/charts/roses/easy.json similarity index 100% rename from assets/charts/roses/roses-easy.json rename to assets/charts/roses/easy.json diff --git a/assets/charts/roses/roses-hard.json b/assets/charts/roses/hard.json similarity index 100% rename from assets/charts/roses/roses-hard.json rename to assets/charts/roses/hard.json diff --git a/assets/charts/roses/roses.json b/assets/charts/roses/normal.json similarity index 100% rename from assets/charts/roses/roses.json rename to assets/charts/roses/normal.json diff --git a/assets/charts/satin-panties/satin-panties-easy.json b/assets/charts/satin-panties/easy.json similarity index 100% rename from assets/charts/satin-panties/satin-panties-easy.json rename to assets/charts/satin-panties/easy.json diff --git a/assets/charts/satin-panties/satin-panties-hard.json b/assets/charts/satin-panties/hard.json similarity index 100% rename from assets/charts/satin-panties/satin-panties-hard.json rename to assets/charts/satin-panties/hard.json diff --git a/assets/charts/satin-panties/satin-panties.json b/assets/charts/satin-panties/normal.json similarity index 100% rename from assets/charts/satin-panties/satin-panties.json rename to assets/charts/satin-panties/normal.json diff --git a/assets/charts/senpai/senpai-easy.json b/assets/charts/senpai/easy.json similarity index 100% rename from assets/charts/senpai/senpai-easy.json rename to assets/charts/senpai/easy.json diff --git a/assets/charts/senpai/senpai-hard.json b/assets/charts/senpai/hard.json similarity index 100% rename from assets/charts/senpai/senpai-hard.json rename to assets/charts/senpai/hard.json diff --git a/assets/charts/senpai/senpai.json b/assets/charts/senpai/normal.json similarity index 100% rename from assets/charts/senpai/senpai.json rename to assets/charts/senpai/normal.json diff --git a/assets/charts/smash/smash.json b/assets/charts/smash/normal.json similarity index 100% rename from assets/charts/smash/smash.json rename to assets/charts/smash/normal.json diff --git a/assets/charts/south/south-easy.json b/assets/charts/south/easy.json similarity index 100% rename from assets/charts/south/south-easy.json rename to assets/charts/south/easy.json diff --git a/assets/charts/south/south-hard.json b/assets/charts/south/hard.json similarity index 100% rename from assets/charts/south/south-hard.json rename to assets/charts/south/hard.json diff --git a/assets/charts/south/south.json b/assets/charts/south/normal.json similarity index 100% rename from assets/charts/south/south.json rename to assets/charts/south/normal.json diff --git a/assets/charts/spookeez/spookeez-easy.json b/assets/charts/spookeez/easy.json similarity index 100% rename from assets/charts/spookeez/spookeez-easy.json rename to assets/charts/spookeez/easy.json diff --git a/assets/charts/spookeez/spookeez-hard.json b/assets/charts/spookeez/hard.json similarity index 100% rename from assets/charts/spookeez/spookeez-hard.json rename to assets/charts/spookeez/hard.json diff --git a/assets/charts/spookeez/spookeez.json b/assets/charts/spookeez/normal.json similarity index 100% rename from assets/charts/spookeez/spookeez.json rename to assets/charts/spookeez/normal.json diff --git a/assets/charts/thorns/thorns-easy.json b/assets/charts/thorns/easy.json similarity index 100% rename from assets/charts/thorns/thorns-easy.json rename to assets/charts/thorns/easy.json diff --git a/assets/charts/thorns/thorns-hard.json b/assets/charts/thorns/hard.json similarity index 100% rename from assets/charts/thorns/thorns-hard.json rename to assets/charts/thorns/hard.json diff --git a/assets/charts/thorns/thorns.json b/assets/charts/thorns/normal.json similarity index 100% rename from assets/charts/thorns/thorns.json rename to assets/charts/thorns/normal.json diff --git a/assets/charts/tutorial/tutorial-easy.json b/assets/charts/tutorial/easy.json similarity index 100% rename from assets/charts/tutorial/tutorial-easy.json rename to assets/charts/tutorial/easy.json diff --git a/assets/charts/tutorial/tutorial-hard.json b/assets/charts/tutorial/hard.json similarity index 100% rename from assets/charts/tutorial/tutorial-hard.json rename to assets/charts/tutorial/hard.json diff --git a/assets/charts/tutorial/tutorial.json b/assets/charts/tutorial/normal.json similarity index 100% rename from assets/charts/tutorial/tutorial.json rename to assets/charts/tutorial/normal.json diff --git a/assets/charts/winter-horrorland/winter-horrorland-easy.json b/assets/charts/winter-horrorland/easy.json similarity index 100% rename from assets/charts/winter-horrorland/winter-horrorland-easy.json rename to assets/charts/winter-horrorland/easy.json diff --git a/assets/charts/winter-horrorland/winter-horrorland-hard.json b/assets/charts/winter-horrorland/hard.json similarity index 100% rename from assets/charts/winter-horrorland/winter-horrorland-hard.json rename to assets/charts/winter-horrorland/hard.json diff --git a/assets/charts/winter-horrorland/winter-horrorland.json b/assets/charts/winter-horrorland/normal.json similarity index 100% rename from assets/charts/winter-horrorland/winter-horrorland.json rename to assets/charts/winter-horrorland/normal.json diff --git a/assets/data/characters/bf.xml b/assets/data/characters/bf.xml index 1f9c5a92..bb7db17e 100644 --- a/assets/data/characters/bf.xml +++ b/assets/data/characters/bf.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/data/characters/gf.xml b/assets/data/characters/gf.xml new file mode 100644 index 00000000..dcb655cf --- /dev/null +++ b/assets/data/characters/gf.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/data/characters/mom-car.xml b/assets/data/characters/mom-car.xml new file mode 100644 index 00000000..71e38b48 --- /dev/null +++ b/assets/data/characters/mom-car.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/assets/week4/images/momCar.png b/assets/images/characters/mom-car.png similarity index 100% rename from assets/week4/images/momCar.png rename to assets/images/characters/mom-car.png diff --git a/assets/week4/images/momCar.xml b/assets/images/characters/mom-car.xml similarity index 100% rename from assets/week4/images/momCar.xml rename to assets/images/characters/mom-car.xml diff --git a/buildnumber.txt b/buildnumber.txt index bd753ccc..50f0bcd3 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -94 \ No newline at end of file +135 \ No newline at end of file diff --git a/source/CoolUtil.hx b/source/CoolUtil.hx deleted file mode 100644 index 2e07f043..00000000 --- a/source/CoolUtil.hx +++ /dev/null @@ -1,33 +0,0 @@ -package; - -import lime.utils.Assets; -import flixel.animation.FlxAnimation; - -using StringTools; - -class CoolUtil -{ - public static var difficultyArray:Array = ['EASY', "NORMAL", "HARD"]; - - public static function difficultyString():String - { - return difficultyArray[PlayState.storyDifficulty]; - } - - public static function coolTextFile(path:String):Array - { - return [for(e in Assets.getText(path).trim().split('\n')) e.trim()]; - } - - public static function numberArray(max:Int, ?min = 0):Array - { - return [for (i in min...max) i]; - } - - public static function switchAnimFrames(anim1:FlxAnimation, anim2:FlxAnimation) { - if (anim1 == null || anim2 == null) return; - var old = anim1.frames; - anim1.frames = anim2.frames; - anim2.frames = old; - } -} diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 112bbbcd..d202a665 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -1,8 +1,12 @@ package funkin.game; -import funkin.system.IBeatReceiver; +import flixel.math.FlxPoint; +import funkin.interfaces.IBeatReceiver; +import funkin.interfaces.IOffsetCompatible; + import flixel.FlxG; import flixel.FlxSprite; +import flixel.FlxCamera; import flixel.animation.FlxBaseAnimation; import flixel.graphics.frames.FlxAtlasFrames; @@ -12,7 +16,7 @@ import haxe.Exception; using StringTools; -class Character extends FlxSprite implements IBeatReceiver +class Character extends FlxSprite implements IBeatReceiver implements IOffsetCompatible { public var stunned:Bool = false; @@ -20,6 +24,7 @@ class Character extends FlxSprite implements IBeatReceiver public var debugMode:Bool = false; public var isPlayer:Bool = false; + public var isGF:Bool = false; public var curCharacter:String = 'bf'; public var lastHit:Float = -5000; @@ -27,6 +32,8 @@ class Character extends FlxSprite implements IBeatReceiver public var playerOffsets:Bool = false; + public var globalOffset:FlxPoint = new FlxPoint(0, 0); + public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false) { super(x, y); @@ -63,32 +70,14 @@ class Character extends FlxSprite implements IBeatReceiver } if (character.has.isPlayer) playerOffsets = (character.att.isPlayer == "true"); + if (character.has.isGF) isGF = (character.att.isGF == "true"); + if (character.has.x) globalOffset.x = Std.parseFloat(character.att.x); + if (character.has.x) globalOffset.y = Std.parseFloat(character.att.y); if (character.has.flipX) flipX = (character.att.flipX == "true"); frames = Paths.getSparrowAtlas('characters/$curCharacter'); for(anim in character.nodes.anim) { - // TODO: Add indices - var animData:AnimData = { - name: null, - anim: null, - fps: 24, - loop: false, - x: 0, - y: 0 - }; - - if (anim.has.name) animData.name = anim.att.name; - if (anim.has.anim) animData.anim = anim.att.anim; - if (anim.has.fps) animData.fps = Std.parseInt(anim.att.fps); - if (anim.has.x) animData.x = Std.parseFloat(anim.att.x); - if (anim.has.y) animData.y = Std.parseFloat(anim.att.y); - - if (animData.name != null && animData.anim != null) { - if (animData.fps <= 0 #if web || animData.fps == null #end) animData.fps = 24; - - animation.addByPrefix(animData.name, animData.anim, animData.fps, animData.loop); - addOffset(animData.name, animData.x, animData.y); - } + CoolUtil.addXMLAnimation(this, anim); } } break; @@ -566,6 +555,9 @@ class Character extends FlxSprite implements IBeatReceiver dance(); + + isDanceLeftDanceRight = (animation.getByName("danceLeft") != null && animation.getByName("danceRight") != null); + // alternative to xor operator // for people who dont believe it, heres the truth table // [ a ][ b ][ a!= b ] @@ -573,7 +565,6 @@ class Character extends FlxSprite implements IBeatReceiver // [ true ][ false ][ true ] // [ false ][ true ][ true ] // [ true ][ true ][ false ] - if (isPlayer != playerOffsets) { // character is flipped @@ -582,10 +573,12 @@ class Character extends FlxSprite implements IBeatReceiver switchOffset('singLEFT', 'singRIGHT'); switchOffset('singLEFTmiss', 'singRIGHTmiss'); - } else - flipX = !flipX; + } + if (isPlayer) flipX = !flipX; } + var isDanceLeftDanceRight:Bool = false; + public function switchOffset(anim1:String, anim2:String) { var old = animOffsets[anim1]; animOffsets[anim1] = animOffsets[anim2]; @@ -594,13 +587,6 @@ class Character extends FlxSprite implements IBeatReceiver override function update(elapsed:Float) { - switch (curCharacter) - { - case 'gf': - if (animation.curAnim.name == 'hairFall' && animation.curAnim.finished) - playAnim('danceRight'); - } - super.update(elapsed); } @@ -615,49 +601,7 @@ class Character extends FlxSprite implements IBeatReceiver { switch (curCharacter) { - case 'gf': - if (!animation.curAnim.name.startsWith('hair')) - { - danced = !danced; - - if (danced) - playAnim('danceRight'); - else - playAnim('danceLeft'); - } - - case 'gf-christmas': - if (!animation.curAnim.name.startsWith('hair')) - { - danced = !danced; - - if (danced) - playAnim('danceRight'); - else - playAnim('danceLeft'); - } - - case 'gf-car': - if (!animation.curAnim.name.startsWith('hair')) - { - danced = !danced; - - if (danced) - playAnim('danceRight'); - else - playAnim('danceLeft'); - } - case 'gf-pixel': - if (!animation.curAnim.name.startsWith('hair')) - { - danced = !danced; - - if (danced) - playAnim('danceRight'); - else - playAnim('danceLeft'); - } - + // hardcode custom dance animations here case 'spooky': danced = !danced; @@ -666,7 +610,10 @@ class Character extends FlxSprite implements IBeatReceiver else playAnim('danceLeft'); default: - playAnim('idle'); + if (isDanceLeftDanceRight) { + playAnim((danced != danced) ? 'danceLeft' : 'danceRight'); + } else + playAnim('idle'); } } } @@ -679,6 +626,56 @@ class Character extends FlxSprite implements IBeatReceiver // nothing } + // /** + // * DO NOT TOUCH!! FOR DRAWING STUFF + // */ + // public override function isOnScreen() { + // if (flipX) { + // return super.isOnScreen(); + // } else { + // return super.isOnScreen(); + // } + // } + // public override function draw() { + // // doing this cause flixel have a bug with frameX not being applied correctly when sprite is flipped + // if (flipX) { + // isOnScreen + // // setting up variables + // flipX = false; + // scale.x = -scale.x; + + // // drawing + // super.draw(); + + // // resetting variables + // scale.x = -scale.x; + // flipX = true; + // } else + // super.draw(); + // } + + public override function isOnScreen(?Camera:FlxCamera):Bool + { + if (Camera == null) + Camera = FlxG.camera; + + getScreenPosition(_point, Camera); + return Camera.containsPoint(_point, width, height); + } + + public override function draw() { + if (flipX) { + dirty = true; + + flipX = false; + scale.x *= -1; + super.draw(); + flipX = true; + scale.x *= -1; + } else + super.draw(); + } + public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void { animation.play(AnimName, Force, Reversed, Frame); @@ -689,15 +686,17 @@ class Character extends FlxSprite implements IBeatReceiver if (isPlayer != playerOffsets) { offset.set(-daOffset[0], daOffset[1]); var anim = animation.getByName(AnimName); - if (anim != null) { - offset.x -= frames.frames[anim.frames[0]].offset.x * 3; - } + // if (anim != null && anim.frames.length > 0) { + // offset.x -= frames.frames[anim.frames[0]].offset.x * 2; + // } } else { offset.set(daOffset[0], daOffset[1]); } } else offset.set(0, 0); + offset.x -= globalOffset.x; + offset.y -= globalOffset.y; if (AnimName.startsWith("sing")) lastHit = Conductor.songPosition; @@ -724,13 +723,4 @@ class Character extends FlxSprite implements IBeatReceiver { animOffsets[name] = [x, y]; } -} - -typedef AnimData = { - var name:String; - var anim:String; - var fps:Int; - var loop:Bool; - var x:Float; - var y:Float; } \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 6a9b87a5..19caba3c 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -173,7 +173,7 @@ class PlayState extends MusicBeatState var camPos:FlxPoint = new FlxPoint(dad.getGraphicMidpoint().x, dad.getGraphicMidpoint().y); - boyfriend = new Character(770, 450, SONG.player1, true); + boyfriend = new Character(770, 100, SONG.player1, true); add(gf); @@ -798,7 +798,7 @@ class PlayState extends MusicBeatState // trace(PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection); } - if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) + if (camFollow.x != dad.getMidpoint().x + 150 + dad.globalOffset.x && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) { camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100); // camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210); @@ -815,6 +815,10 @@ class PlayState extends MusicBeatState camFollow.x = dad.getMidpoint().x - 100; } + + camFollow.x += dad.globalOffset.x; + camFollow.y += dad.globalOffset.y; + if (dad.curCharacter == 'mom') vocals.volume = 1; @@ -824,7 +828,9 @@ class PlayState extends MusicBeatState } } - if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100) + // TODO: redo this god forsaken system + + if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100 + boyfriend.globalOffset.x) { camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100); @@ -842,6 +848,9 @@ class PlayState extends MusicBeatState camFollow.y = boyfriend.getMidpoint().y - 200; } + camFollow.x += boyfriend.globalOffset.x; + camFollow.y += boyfriend.globalOffset.y; + if (SONG.song.toLowerCase() == 'tutorial') { FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut}); diff --git a/source/funkin/system/IBeatReceiver.hx b/source/funkin/interfaces/IBeatReceiver.hx similarity index 81% rename from source/funkin/system/IBeatReceiver.hx rename to source/funkin/interfaces/IBeatReceiver.hx index b6bc405b..ca7dfa35 100644 --- a/source/funkin/system/IBeatReceiver.hx +++ b/source/funkin/interfaces/IBeatReceiver.hx @@ -1,4 +1,4 @@ -package funkin.system; +package funkin.interfaces; interface IBeatReceiver { public function beatHit(curBeat:Int):Void; diff --git a/source/funkin/interfaces/IOffsetCompatible.hx b/source/funkin/interfaces/IOffsetCompatible.hx new file mode 100644 index 00000000..5ec55bcd --- /dev/null +++ b/source/funkin/interfaces/IOffsetCompatible.hx @@ -0,0 +1,5 @@ +package funkin.interfaces; + +interface IOffsetCompatible { + public function addOffset(anim:String, x:Float = 0, y:Float = 0):Void; +} \ No newline at end of file diff --git a/source/funkin/system/CoolUtil.hx b/source/funkin/system/CoolUtil.hx new file mode 100644 index 00000000..52d16eb3 --- /dev/null +++ b/source/funkin/system/CoolUtil.hx @@ -0,0 +1,83 @@ +package funkin.system; + +import funkin.interfaces.IOffsetCompatible; +import lime.utils.Assets; +import flixel.animation.FlxAnimation; +import haxe.xml.Access; +import flixel.FlxSprite; + +using StringTools; + +class CoolUtil +{ + public static function addXMLAnimation(sprite:FlxSprite, anim:Access) { + var animData:AnimData = { + name: null, + anim: null, + fps: 24, + loop: false, + x: 0, + y: 0, + indices: [] + }; + + if (anim.has.name) animData.name = anim.att.name; + if (anim.has.anim) animData.anim = anim.att.anim; + if (anim.has.fps) animData.fps = Std.parseInt(anim.att.fps); + if (anim.has.x) animData.x = Std.parseFloat(anim.att.x); + if (anim.has.y) animData.y = Std.parseFloat(anim.att.y); + if (anim.has.indices) { + var indicesSplit = anim.att.indices.split(","); + for(indice in indicesSplit) { + var i = Std.parseInt(indice.trim()); + if (i != null) + animData.indices.push(i); + } + } + + if (animData.name != null && animData.anim != null) { + if (animData.fps <= 0 #if web || animData.fps == null #end) animData.fps = 24; + + if (animData.indices.length > 0) + sprite.animation.addByIndices(animData.name, animData.anim, animData.indices, "", animData.fps, animData.loop); + else + sprite.animation.addByPrefix(animData.name, animData.anim, animData.fps, animData.loop); + + if (sprite is IOffsetCompatible) + cast(sprite, IOffsetCompatible).addOffset(animData.name, animData.x, animData.y); + } + } + public static var difficultyArray:Array = ['EASY', "NORMAL", "HARD"]; + + public static function difficultyString():String + { + return difficultyArray[PlayState.storyDifficulty]; + } + + public static function coolTextFile(path:String):Array + { + return [for(e in Assets.getText(path).trim().split('\n')) e.trim()]; + } + + public static function numberArray(max:Int, ?min = 0):Array + { + return [for (i in min...max) i]; + } + + public static function switchAnimFrames(anim1:FlxAnimation, anim2:FlxAnimation) { + if (anim1 == null || anim2 == null) return; + var old = anim1.frames; + anim1.frames = anim2.frames; + anim2.frames = old; + } +} + +typedef AnimData = { + var name:String; + var anim:String; + var fps:Int; + var loop:Bool; + var x:Float; + var y:Float; + var indices:Array; +} \ No newline at end of file diff --git a/source/funkin/system/MusicBeatState.hx b/source/funkin/system/MusicBeatState.hx index d03a5f49..1c07989e 100644 --- a/source/funkin/system/MusicBeatState.hx +++ b/source/funkin/system/MusicBeatState.hx @@ -1,5 +1,6 @@ package funkin.system; +import funkin.interfaces.IBeatReceiver; import Conductor.BPMChangeEvent; import flixel.FlxG; import flixel.addons.transition.FlxTransitionableState; diff --git a/source/import.hx b/source/import.hx index f22196e7..15ff41d2 100644 --- a/source/import.hx +++ b/source/import.hx @@ -1,6 +1,7 @@ #if !macro - import Paths; - import funkin.game.PlayState; - import funkin.system.MusicBeatState; - import funkin.system.MusicBeatSubstate; +import Paths; +import funkin.game.PlayState; +import funkin.system.MusicBeatState; +import funkin.system.MusicBeatSubstate; +import funkin.system.CoolUtil; #end \ No newline at end of file