Funkin/source/Character.hx

655 lines
19 KiB
Haxe
Raw Normal View History

2020-10-04 18:27:49 -04:00
package;
2021-03-29 13:24:49 -04:00
import Section.SwagSection;
2021-02-24 20:22:37 -05:00
import flixel.FlxG;
2020-10-04 18:27:49 -04:00
import flixel.FlxSprite;
2020-12-09 17:36:31 -05:00
import flixel.animation.FlxBaseAnimation;
2020-10-18 20:59:53 -04:00
import flixel.graphics.frames.FlxAtlasFrames;
2021-03-13 20:53:57 -05:00
import haxe.io.Path;
2020-10-04 18:27:49 -04:00
2020-11-11 05:00:13 -05:00
using StringTools;
2020-10-04 18:27:49 -04:00
class Character extends FlxSprite
{
public var animOffsets:Map<String, Array<Dynamic>>;
public var debugMode:Bool = false;
2020-10-18 20:59:53 -04:00
public var isPlayer:Bool = false;
public var curCharacter:String = 'bf';
2020-11-11 05:00:13 -05:00
public var holdTimer:Float = 0;
2021-03-29 13:24:49 -04:00
public var animationNotes:Array<Dynamic> = [];
2020-10-18 20:59:53 -04:00
public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false)
2020-10-04 18:27:49 -04:00
{
super(x, y);
2020-10-18 20:59:53 -04:00
2021-02-24 20:22:37 -05:00
animOffsets = new Map<String, Array<Dynamic>>();
2020-10-18 20:59:53 -04:00
curCharacter = character;
this.isPlayer = isPlayer;
var tex:FlxAtlasFrames;
antialiasing = true;
switch (curCharacter)
{
case 'gf':
// GIRLFRIEND CODE
2021-03-13 23:02:14 -05:00
tex = Paths.getSparrowAtlas('characters/GF_assets');
2020-10-18 20:59:53 -04:00
frames = tex;
quickAnimAdd('cheer', 'GF Cheer');
quickAnimAdd('singLEFT', 'GF left note');
quickAnimAdd('singRIGHT', 'GF Right Note');
quickAnimAdd('singUP', 'GF Up Note');
quickAnimAdd('singDOWN', 'GF Down Note');
2020-10-18 20:59:53 -04:00
animation.addByIndices('sad', 'gf sad', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "", 24, false);
animation.addByIndices('danceLeft', 'GF Dancing Beat', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
animation.addByIndices('danceRight', 'GF Dancing Beat', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false);
2020-12-11 06:45:00 -05:00
animation.addByIndices('hairBlow', "GF Dancing Beat Hair blowing", [0, 1, 2, 3], "", 24);
animation.addByIndices('hairFall', "GF Dancing Beat Hair Landing", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], "", 24, false);
animation.addByPrefix('scared', 'GF FEAR', 24, true);
2020-11-02 01:46:37 -05:00
2021-03-13 23:02:14 -05:00
loadOffsetFile(curCharacter);
2020-11-02 01:46:37 -05:00
2020-10-18 20:59:53 -04:00
playAnim('danceRight');
2020-11-11 05:00:13 -05:00
2021-01-19 21:09:47 -05:00
case 'gf-christmas':
tex = Paths.getSparrowAtlas('characters/gfChristmas');
2021-01-19 21:09:47 -05:00
frames = tex;
quickAnimAdd('cheer', 'GF Cheer');
quickAnimAdd('singLEFT', 'GF left note');
quickAnimAdd('singRIGHT', 'GF Right Note');
quickAnimAdd('singUP', 'GF Up Note');
quickAnimAdd('singDOWN', 'GF Down Note');
2021-01-19 21:09:47 -05:00
animation.addByIndices('sad', 'gf sad', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "", 24, false);
animation.addByIndices('danceLeft', 'GF Dancing Beat', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
animation.addByIndices('danceRight', 'GF Dancing Beat', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false);
animation.addByIndices('hairBlow', "GF Dancing Beat Hair blowing", [0, 1, 2, 3], "", 24);
animation.addByIndices('hairFall', "GF Dancing Beat Hair Landing", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], "", 24, false);
animation.addByPrefix('scared', 'GF FEAR', 24, true);
2021-01-19 21:09:47 -05:00
loadOffsetFile(curCharacter);
2021-01-19 21:09:47 -05:00
playAnim('danceRight');
2021-03-17 05:20:25 -04:00
case 'bf-holding-gf':
frames = Paths.getSparrowAtlas('characters/bfAndGF');
quickAnimAdd('idle', 'BF idle dance');
quickAnimAdd('singDOWN', 'BF NOTE DOWN0');
quickAnimAdd('singLEFT', 'BF NOTE LEFT0');
quickAnimAdd('singRIGHT', 'BF NOTE RIGHT0');
quickAnimAdd('singUP', 'BF NOTE UP0');
quickAnimAdd('singDOWNmiss', 'BF NOTE DOWN MISS');
quickAnimAdd('singLEFTmiss', 'BF NOTE LEFT MISS');
quickAnimAdd('singRIGHTmiss', 'BF NOTE RIGHT MISS');
quickAnimAdd('singUPmiss', 'BF NOTE UP MISS');
quickAnimAdd('bfCatch', 'BF catches GF');
loadOffsetFile(curCharacter);
playAnim('idle');
2021-03-17 05:29:04 -04:00
flipX = true;
2021-01-14 23:33:12 -05:00
case 'gf-car':
tex = Paths.getSparrowAtlas('characters/gfCar');
2021-01-14 23:33:12 -05:00
frames = tex;
animation.addByIndices('singUP', 'GF Dancing Beat Hair blowing CAR', [0], "", 24, false);
animation.addByIndices('danceLeft', 'GF Dancing Beat Hair blowing CAR', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
animation.addByIndices('danceRight', 'GF Dancing Beat Hair blowing CAR', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24,
false);
2021-03-19 14:02:42 -04:00
animation.addByIndices('idleHair', 'GF Dancing Beat Hair blowing CAR', [10, 11, 12, 25, 26, 27], "", 24, true);
2021-01-14 23:33:12 -05:00
loadOffsetFile(curCharacter);
2021-01-14 23:33:12 -05:00
playAnim('danceRight');
2021-01-25 04:18:44 -05:00
case 'gf-pixel':
tex = Paths.getSparrowAtlas('characters/gfPixel');
2021-01-25 04:18:44 -05:00
frames = tex;
animation.addByIndices('singUP', 'GF IDLE', [2], "", 24, false);
animation.addByIndices('danceLeft', 'GF IDLE', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
animation.addByIndices('danceRight', 'GF IDLE', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false);
loadOffsetFile(curCharacter);
2021-01-25 04:18:44 -05:00
playAnim('danceRight');
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
updateHitbox();
antialiasing = false;
2020-10-18 20:59:53 -04:00
case 'dad':
// DAD ANIMATION LOADING CODE
tex = Paths.getSparrowAtlas('characters/DADDY_DEAREST');
2020-10-18 20:59:53 -04:00
frames = tex;
quickAnimAdd('idle', 'Dad idle dance');
quickAnimAdd('singUP', 'Dad Sing Note UP');
quickAnimAdd('singRIGHT', 'Dad Sing Note RIGHT');
quickAnimAdd('singDOWN', 'Dad Sing Note DOWN');
quickAnimAdd('singLEFT', 'Dad Sing Note LEFT');
2020-10-18 20:59:53 -04:00
loadOffsetFile(curCharacter);
2021-01-14 23:33:12 -05:00
playAnim('idle');
2020-10-23 19:12:38 -04:00
case 'spooky':
tex = Paths.getSparrowAtlas('characters/spooky_kids_assets');
2020-10-23 19:12:38 -04:00
frames = tex;
quickAnimAdd('singUP', 'spooky UP NOTE');
quickAnimAdd('singDOWN', 'spooky DOWN note');
quickAnimAdd('singLEFT', 'note sing left');
quickAnimAdd('singRIGHT', 'spooky sing right');
2020-10-30 19:47:19 -04:00
animation.addByIndices('danceLeft', 'spooky dance idle', [0, 2, 6], "", 12, false);
2020-10-23 19:12:38 -04:00
animation.addByIndices('danceRight', 'spooky dance idle', [8, 10, 12, 14], "", 12, false);
loadOffsetFile(curCharacter);
2020-10-23 19:12:38 -04:00
playAnim('danceRight');
2020-12-22 20:55:03 -05:00
case 'mom':
tex = Paths.getSparrowAtlas('characters/Mom_Assets');
2020-12-22 20:55:03 -05:00
frames = tex;
quickAnimAdd('idle', "Mom Idle");
quickAnimAdd('singUP', "Mom Up Pose");
quickAnimAdd('singDOWN', "MOM DOWN POSE");
quickAnimAdd('singLEFT', 'Mom Left Pose');
2020-12-22 20:55:03 -05:00
// ANIMATION IS CALLED MOM LEFT POSE BUT ITS FOR THE RIGHT
// CUZ DAVE IS DUMB!
quickAnimAdd('singRIGHT', 'Mom Pose Left');
2020-12-22 20:55:03 -05:00
loadOffsetFile(curCharacter);
2021-01-14 23:33:12 -05:00
2020-12-22 20:55:03 -05:00
playAnim('idle');
2021-01-14 23:33:12 -05:00
case 'mom-car':
tex = Paths.getSparrowAtlas('characters/momCar');
2021-01-14 23:33:12 -05:00
frames = tex;
quickAnimAdd('idle', "Mom Idle");
quickAnimAdd('singUP', "Mom Up Pose");
quickAnimAdd('singDOWN', "MOM DOWN POSE");
quickAnimAdd('singLEFT', 'Mom Left Pose');
2021-01-14 23:33:12 -05:00
// ANIMATION IS CALLED MOM LEFT POSE BUT ITS FOR THE RIGHT
// CUZ DAVE IS DUMB!
quickAnimAdd('singRIGHT', 'Mom Pose Left');
2021-03-19 14:02:42 -04:00
animation.addByIndices('idleHair', "Mom Idle", [10, 11, 12, 13], "", 24, true);
2021-01-14 23:33:12 -05:00
loadOffsetFile(curCharacter);
2021-01-14 23:33:12 -05:00
playAnim('idle');
2020-10-30 19:47:19 -04:00
case 'monster':
tex = Paths.getSparrowAtlas('characters/Monster_Assets');
2020-10-30 19:47:19 -04:00
frames = tex;
quickAnimAdd('idle', 'monster idle');
quickAnimAdd('singUP', 'monster up note');
quickAnimAdd('singDOWN', 'monster down');
quickAnimAdd('singLEFT', 'Monster left note');
quickAnimAdd('singRIGHT', 'Monster Right note');
2020-10-30 19:47:19 -04:00
loadOffsetFile(curCharacter);
2020-10-30 19:47:19 -04:00
playAnim('idle');
2021-01-20 01:38:39 -05:00
case 'monster-christmas':
tex = Paths.getSparrowAtlas('characters/monsterChristmas');
2021-01-20 01:38:39 -05:00
frames = tex;
quickAnimAdd('idle', 'monster idle');
quickAnimAdd('singUP', 'monster up note');
quickAnimAdd('singDOWN', 'monster down');
quickAnimAdd('singLEFT', 'Monster left note');
quickAnimAdd('singRIGHT', 'Monster Right note');
2021-01-20 01:38:39 -05:00
loadOffsetFile(curCharacter);
2021-01-20 01:38:39 -05:00
playAnim('idle');
2020-12-09 17:36:31 -05:00
case 'pico':
tex = Paths.getSparrowAtlas('characters/Pico_FNF_assetss');
2020-11-10 12:52:49 -05:00
frames = tex;
quickAnimAdd('idle', "Pico Idle Dance");
quickAnimAdd('singUP', 'pico Up note0');
quickAnimAdd('singDOWN', 'Pico Down Note0');
2020-12-09 17:36:31 -05:00
if (isPlayer)
{
quickAnimAdd('singLEFT', 'Pico NOTE LEFT0');
quickAnimAdd('singRIGHT', 'Pico Note Right0');
quickAnimAdd('singRIGHTmiss', 'Pico Note Right Miss');
quickAnimAdd('singLEFTmiss', 'Pico NOTE LEFT miss');
2020-12-09 17:36:31 -05:00
}
else
{
// Need to be flipped! REDO THIS LATER!
quickAnimAdd('singLEFT', 'Pico Note Right0');
quickAnimAdd('singRIGHT', 'Pico NOTE LEFT0');
quickAnimAdd('singRIGHTmiss', 'Pico NOTE LEFT miss');
quickAnimAdd('singLEFTmiss', 'Pico Note Right Miss');
2020-12-09 17:36:31 -05:00
}
quickAnimAdd('singUPmiss', 'pico Up note miss');
quickAnimAdd('singDOWNmiss', 'Pico Down Note MISS');
2020-12-09 17:36:31 -05:00
loadOffsetFile(curCharacter);
2020-12-09 17:36:31 -05:00
2021-01-14 23:33:12 -05:00
playAnim('idle');
2021-01-13 22:38:31 -05:00
flipX = true;
2020-12-09 17:36:31 -05:00
2021-03-13 20:53:57 -05:00
case 'pico-speaker':
frames = Paths.getSparrowAtlas('characters/picoSpeaker');
quickAnimAdd('shoot1', "Pico shoot 1");
quickAnimAdd('shoot2', "Pico shoot 2");
quickAnimAdd('shoot3', "Pico shoot 3");
quickAnimAdd('shoot4', "Pico shoot 4");
// here for now, will be replaced later for less copypaste
loadOffsetFile(curCharacter);
playAnim('shoot1');
2021-03-29 13:24:49 -04:00
loadMappedAnims();
2020-12-09 17:36:31 -05:00
case 'bf':
2021-03-13 23:02:14 -05:00
var tex = Paths.getSparrowAtlas('characters/BOYFRIEND');
2020-12-09 17:36:31 -05:00
frames = tex;
quickAnimAdd('idle', 'BF idle dance');
quickAnimAdd('singUP', 'BF NOTE UP0');
quickAnimAdd('singLEFT', 'BF NOTE LEFT0');
quickAnimAdd('singRIGHT', 'BF NOTE RIGHT0');
quickAnimAdd('singDOWN', 'BF NOTE DOWN0');
quickAnimAdd('singUPmiss', 'BF NOTE UP MISS');
quickAnimAdd('singLEFTmiss', 'BF NOTE LEFT MISS');
quickAnimAdd('singRIGHTmiss', 'BF NOTE RIGHT MISS');
quickAnimAdd('singDOWNmiss', 'BF NOTE DOWN MISS');
quickAnimAdd('hey', 'BF HEY');
quickAnimAdd('firstDeath', "BF dies");
2020-12-09 17:36:31 -05:00
animation.addByPrefix('deathLoop', "BF Dead Loop", 24, true);
quickAnimAdd('deathConfirm', "BF Dead confirm");
2020-12-09 17:36:31 -05:00
animation.addByPrefix('scared', 'BF idle shaking', 24, true);
2020-12-09 17:36:31 -05:00
2021-03-13 23:02:14 -05:00
loadOffsetFile(curCharacter);
2021-01-13 22:38:31 -05:00
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-01-19 21:44:09 -05:00
flipX = true;
2021-03-13 23:02:14 -05:00
loadOffsetFile(curCharacter);
2021-01-19 21:44:09 -05:00
case 'bf-christmas':
var tex = Paths.getSparrowAtlas('characters/bfChristmas');
2021-01-19 21:44:09 -05:00
frames = tex;
quickAnimAdd('idle', 'BF idle dance');
quickAnimAdd('singUP', 'BF NOTE UP0');
quickAnimAdd('singLEFT', 'BF NOTE LEFT0');
quickAnimAdd('singRIGHT', 'BF NOTE RIGHT0');
quickAnimAdd('singDOWN', 'BF NOTE DOWN0');
quickAnimAdd('singUPmiss', 'BF NOTE UP MISS');
quickAnimAdd('singLEFTmiss', 'BF NOTE LEFT MISS');
quickAnimAdd('singRIGHTmiss', 'BF NOTE RIGHT MISS');
quickAnimAdd('singDOWNmiss', 'BF NOTE DOWN MISS');
quickAnimAdd('hey', 'BF HEY');
2021-01-19 21:44:09 -05:00
loadOffsetFile(curCharacter);
2021-01-19 21:44:09 -05:00
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-01-14 23:33:12 -05:00
flipX = true;
case 'bf-car':
var tex = Paths.getSparrowAtlas('characters/bfCar');
2021-01-14 23:33:12 -05:00
frames = tex;
quickAnimAdd('idle', 'BF idle dance');
quickAnimAdd('singUP', 'BF NOTE UP0');
quickAnimAdd('singLEFT', 'BF NOTE LEFT0');
quickAnimAdd('singRIGHT', 'BF NOTE RIGHT0');
quickAnimAdd('singDOWN', 'BF NOTE DOWN0');
quickAnimAdd('singUPmiss', 'BF NOTE UP MISS');
quickAnimAdd('singLEFTmiss', 'BF NOTE LEFT MISS');
quickAnimAdd('singRIGHTmiss', 'BF NOTE RIGHT MISS');
quickAnimAdd('singDOWNmiss', 'BF NOTE DOWN MISS');
2021-03-19 14:02:42 -04:00
animation.addByIndices('idleHair', 'BF idle dance', [10, 11, 12, 13], "", 24, true);
2021-01-14 23:33:12 -05:00
loadOffsetFile(curCharacter);
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-01-14 23:33:12 -05:00
2021-01-24 22:42:51 -05:00
flipX = true;
case 'bf-pixel':
frames = Paths.getSparrowAtlas('characters/bfPixel');
quickAnimAdd('idle', 'BF IDLE');
quickAnimAdd('singUP', 'BF UP NOTE');
quickAnimAdd('singLEFT', 'BF LEFT NOTE');
quickAnimAdd('singRIGHT', 'BF RIGHT NOTE');
quickAnimAdd('singDOWN', 'BF DOWN NOTE');
quickAnimAdd('singUPmiss', 'BF UP MISS');
quickAnimAdd('singLEFTmiss', 'BF LEFT MISS');
quickAnimAdd('singRIGHTmiss', 'BF RIGHT MISS');
quickAnimAdd('singDOWNmiss', 'BF DOWN MISS');
2021-01-24 22:42:51 -05:00
loadOffsetFile(curCharacter);
2021-01-24 22:42:51 -05:00
setGraphicSize(Std.int(width * 6));
updateHitbox();
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-01-24 22:42:51 -05:00
width -= 100;
height -= 100;
antialiasing = false;
2021-01-13 22:38:31 -05:00
flipX = true;
2021-01-30 07:16:51 -05:00
case 'bf-pixel-dead':
frames = Paths.getSparrowAtlas('characters/bfPixelsDEAD');
quickAnimAdd('singUP', "BF Dies pixel");
quickAnimAdd('firstDeath', "BF Dies pixel");
2021-01-30 07:16:51 -05:00
animation.addByPrefix('deathLoop', "Retry Loop", 24, true);
quickAnimAdd('deathConfirm', "RETRY CONFIRM");
2021-01-30 07:16:51 -05:00
animation.play('firstDeath');
loadOffsetFile(curCharacter);
2021-01-31 09:17:56 -05:00
playAnim('firstDeath');
2021-01-30 07:16:51 -05:00
// pixel bullshit
setGraphicSize(Std.int(width * 6));
updateHitbox();
antialiasing = false;
flipX = true;
2021-01-25 06:07:45 -05:00
case 'senpai':
frames = Paths.getSparrowAtlas('characters/senpai');
quickAnimAdd('idle', 'Senpai Idle');
// at framerate 16.8 animation plays over 2 beats at 144bpm,
// but if the game lags or the bpm is > 144 (mods etc.)
// he may miss his next dance
// animation.getByName('idle').frameRate = 16.8;
quickAnimAdd('singUP', 'SENPAI UP NOTE');
quickAnimAdd('singLEFT', 'SENPAI LEFT NOTE');
quickAnimAdd('singRIGHT', 'SENPAI RIGHT NOTE');
quickAnimAdd('singDOWN', 'SENPAI DOWN NOTE');
2021-01-25 06:07:45 -05:00
loadOffsetFile(curCharacter);
2021-02-02 03:24:34 -05:00
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-02-02 03:24:34 -05:00
setGraphicSize(Std.int(width * 6));
updateHitbox();
antialiasing = false;
case 'senpai-angry':
frames = Paths.getSparrowAtlas('characters/senpai');
quickAnimAdd('idle', 'Angry Senpai Idle');
quickAnimAdd('singUP', 'Angry Senpai UP NOTE');
quickAnimAdd('singLEFT', 'Angry Senpai LEFT NOTE');
quickAnimAdd('singRIGHT', 'Angry Senpai RIGHT NOTE');
quickAnimAdd('singDOWN', 'Angry Senpai DOWN NOTE');
2021-02-02 03:24:34 -05:00
loadOffsetFile(curCharacter);
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-01-25 06:07:45 -05:00
setGraphicSize(Std.int(width * 6));
updateHitbox();
antialiasing = false;
2021-02-02 00:48:22 -05:00
case 'spirit':
frames = Paths.getPackerAtlas('characters/spirit');
quickAnimAdd('idle', "idle spirit_");
quickAnimAdd('singUP', "up_");
quickAnimAdd('singRIGHT', "right_");
quickAnimAdd('singLEFT', "left_");
quickAnimAdd('singDOWN', "spirit down_");
2021-02-02 00:48:22 -05:00
loadOffsetFile(curCharacter);
2021-02-02 00:48:22 -05:00
setGraphicSize(Std.int(width * 6));
updateHitbox();
playAnim('idle');
antialiasing = false;
2021-01-16 15:14:56 -05:00
case 'parents-christmas':
frames = Paths.getSparrowAtlas('characters/mom_dad_christmas_assets');
quickAnimAdd('idle', 'Parent Christmas Idle');
quickAnimAdd('singUP', 'Parent Up Note Dad');
quickAnimAdd('singDOWN', 'Parent Down Note Dad');
quickAnimAdd('singLEFT', 'Parent Left Note Dad');
quickAnimAdd('singRIGHT', 'Parent Right Note Dad');
2021-01-16 15:14:56 -05:00
quickAnimAdd('singUP-alt', 'Parent Up Note Mom');
2021-01-16 15:14:56 -05:00
quickAnimAdd('singDOWN-alt', 'Parent Down Note Mom');
quickAnimAdd('singLEFT-alt', 'Parent Left Note Mom');
quickAnimAdd('singRIGHT-alt', 'Parent Right Note Mom');
2021-01-16 17:21:06 -05:00
loadOffsetFile(curCharacter);
2021-02-02 04:13:28 -05:00
playAnim('idle');
2021-03-04 03:00:48 -05:00
case 'tankman':
frames = Paths.getSparrowAtlas('characters/tankmanCaptain');
2021-03-04 14:30:35 -05:00
quickAnimAdd('idle', "Tankman Idle Dance");
2021-03-04 14:30:35 -05:00
if (isPlayer)
{
quickAnimAdd('singLEFT', 'Tankman Note Left0');
quickAnimAdd('singRIGHT', 'Tankman Right Note0');
quickAnimAdd('singLEFTmiss', 'Tankman Note Left MISS');
quickAnimAdd('singRIGHTmiss', 'Tankman Right Note MISS');
2021-03-04 14:30:35 -05:00
}
else
{
// Need to be flipped! REDO THIS LATER
quickAnimAdd('singLEFT', 'Tankman Right Note0');
quickAnimAdd('singRIGHT', 'Tankman Note Left0');
quickAnimAdd('singLEFTmiss', 'Tankman Right Note MISS');
quickAnimAdd('singRIGHTmiss', 'Tankman Note Left MISS');
2021-03-04 14:30:35 -05:00
}
quickAnimAdd('singUP', 'Tankman UP note0');
quickAnimAdd('singDOWN', 'Tankman DOWN note0');
quickAnimAdd('singUPmiss', 'Tankman UP note MISS');
quickAnimAdd('singDOWNmiss', 'Tankman DOWN note MISS');
2021-03-04 03:00:48 -05:00
2021-03-13 20:53:57 -05:00
loadOffsetFile(curCharacter);
2021-03-04 03:00:48 -05:00
playAnim('idle');
flipX = true;
2021-01-13 22:38:31 -05:00
}
2021-02-02 04:13:28 -05:00
dance();
animation.finish();
2021-01-13 22:38:31 -05:00
if (isPlayer)
{
flipX = !flipX;
2021-01-16 15:20:57 -05:00
// Doesn't flip for BF, since his are already in the right place???
2021-01-24 22:42:51 -05:00
if (!curCharacter.startsWith('bf'))
2021-01-13 22:38:31 -05:00
{
2021-01-16 15:20:57 -05:00
// var animArray
var oldRight = animation.getByName('singRIGHT').frames;
animation.getByName('singRIGHT').frames = animation.getByName('singLEFT').frames;
animation.getByName('singLEFT').frames = oldRight;
// IF THEY HAVE MISS ANIMATIONS??
if (animation.getByName('singRIGHTmiss') != null)
{
var oldMiss = animation.getByName('singRIGHTmiss').frames;
animation.getByName('singRIGHTmiss').frames = animation.getByName('singLEFTmiss').frames;
animation.getByName('singLEFTmiss').frames = oldMiss;
}
2021-01-13 22:38:31 -05:00
}
2020-10-18 20:59:53 -04:00
}
}
2021-03-29 13:24:49 -04:00
public function loadMappedAnims()
{
var swagshit = Song.loadFromJson('picospeaker', 'stress');
var notes = swagshit.notes;
for (section in notes)
{
for (idk in section.sectionNotes)
{
animationNotes.push(idk);
}
}
2021-03-30 16:58:05 -04:00
TankmenBG.animationNotes = animationNotes;
2021-03-29 13:24:49 -04:00
trace(animationNotes);
}
2021-03-13 20:53:57 -05:00
function quickAnimAdd(name:String, prefix:String)
{
animation.addByPrefix(name, prefix, 24, false);
}
2021-03-04 03:00:48 -05:00
private function loadOffsetFile(offsetCharacter:String)
{
2021-03-13 20:53:57 -05:00
var daFile:Array<String> = CoolUtil.coolTextFile(Paths.file("images/characters/" + offsetCharacter + "Offsets.txt"));
for (i in daFile)
{
var splitWords:Array<String> = i.split(" ");
addOffset(splitWords[0], Std.parseInt(splitWords[1]), Std.parseInt(splitWords[2]));
}
2021-03-04 03:00:48 -05:00
}
2020-11-11 05:00:13 -05:00
override function update(elapsed:Float)
{
2021-01-22 01:50:12 -05:00
if (!curCharacter.startsWith('bf'))
2020-11-11 05:00:13 -05:00
{
if (animation.curAnim.name.startsWith('sing'))
{
holdTimer += elapsed;
}
var dadVar:Float = 4;
if (curCharacter == 'dad')
dadVar = 6.1;
if (holdTimer >= Conductor.stepCrochet * dadVar * 0.001)
{
dance();
holdTimer = 0;
}
}
2021-03-19 14:02:42 -04:00
if (curCharacter.endsWith('-car'))
{
// looping hair anims after idle finished
if (!animation.curAnim.name.startsWith('sing') && animation.curAnim.finished)
playAnim('idleHair');
}
2020-12-11 07:55:39 -05:00
switch (curCharacter)
{
case 'gf':
if (animation.curAnim.name == 'hairFall' && animation.curAnim.finished)
playAnim('danceRight');
2021-03-29 13:24:49 -04:00
case "pico-speaker":
// for pico??
if (animationNotes.length > 0)
{
if (Conductor.songPosition > animationNotes[0][0])
{
trace('played shoot anim' + animationNotes[0][1]);
var shootAnim:Int = 1;
if (animationNotes[0][1] >= 2)
shootAnim = 3;
shootAnim += FlxG.random.int(0, 1);
playAnim('shoot' + shootAnim, true);
animationNotes.shift();
}
}
2020-12-11 07:55:39 -05:00
}
2020-11-11 05:00:13 -05:00
super.update(elapsed);
}
2020-10-18 20:59:53 -04:00
private var danced:Bool = false;
/**
* FOR GF DANCING SHIT
*/
public function dance()
{
2021-01-17 04:16:02 -05:00
if (!debugMode)
2020-10-18 20:59:53 -04:00
{
2021-01-17 04:16:02 -05:00
switch (curCharacter)
{
case 'gf' | 'gf-christmas' | 'gf-car' | 'gf-pixel':
2021-01-17 04:16:02 -05:00
if (!animation.curAnim.name.startsWith('hair'))
{
danced = !danced;
if (danced)
playAnim('danceRight');
else
playAnim('danceLeft');
}
2021-03-13 20:53:57 -05:00
case 'pico-speaker':
2021-03-29 13:24:49 -04:00
// lol weed
// playAnim('shoot' + FlxG.random.int(1, 4), true);
2021-01-17 04:16:02 -05:00
case 'spooky':
2021-01-14 23:33:12 -05:00
danced = !danced;
if (danced)
playAnim('danceRight');
else
playAnim('danceLeft');
2021-01-24 22:42:51 -05:00
default:
2021-01-17 04:16:02 -05:00
playAnim('idle');
}
2020-10-18 20:59:53 -04:00
}
2020-10-04 18:27:49 -04:00
}
public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void
{
animation.play(AnimName, Force, Reversed, Frame);
var daOffset = animOffsets.get(AnimName);
if (animOffsets.exists(AnimName))
2020-10-04 18:27:49 -04:00
{
2021-01-16 15:20:57 -05:00
offset.set(daOffset[0], daOffset[1]);
2020-10-04 18:27:49 -04:00
}
2021-02-02 04:13:28 -05:00
else
offset.set(0, 0);
2020-10-30 19:47:19 -04:00
if (curCharacter == 'gf')
{
if (AnimName == 'singLEFT')
{
danced = true;
}
else if (AnimName == 'singRIGHT')
{
danced = false;
}
if (AnimName == 'singUP' || AnimName == 'singDOWN')
{
danced = !danced;
}
}
2020-10-04 18:27:49 -04:00
}
public function addOffset(name:String, x:Float = 0, y:Float = 0)
{
animOffsets[name] = [x, y];
}
}