more characters + offsets auto fixing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE codename-engine-character>
|
||||
<character isPlayer="true" flipX="true">
|
||||
<character isPlayer="true" flipX="true" x="0" y="350">
|
||||
<anim name="idle" anim="BF idle dance" fps="24" loop="false" x="-5" y="0"/>
|
||||
<anim name="singUP" anim="BF NOTE UP0" fps="24" loop="false" x="-29" y="27"/>
|
||||
<anim name="singLEFT" anim="BF NOTE LEFT0" fps="24" loop="false" x="12" y="-6"/>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE codename-engine-character>
|
||||
<character isPlayer="false" flipX="false" isGF="true">
|
||||
<anim name="cheer" anim="GF Cheer" fps="24" loop="false" />
|
||||
<anim name="singUP" anim="GF Up Note" fps="24" loop="false" x="0" y="4" />
|
||||
<anim name="singLEFT" anim="GF left note" fps="24" loop="false" x="0" y="-20" />
|
||||
<anim name="singRIGHT" anim="GF Right Note" fps="24" loop="false" x="0" y="-20" />
|
||||
<anim name="singDOWN" anim="GF Down Note" fps="24" loop="false" x="0" y="-20" />
|
||||
<anim name="danceLeft" anim="GF Dancing Beat" fps="24" loop="false" x="0" y="-9" indices="30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14" />
|
||||
<anim name="danceRight" anim="GF Dancing Beat" fps="24" loop="false" x="0" y="-9" indices="15,16,17,18,19,20,21,22,23,24,25,26,27,28,29" />
|
||||
<anim name="hairBlow" anim="GF Dancing Beat Hair blowing" fps="24" loop="false" x="45" y="-8" indices="0,1,2,3" />
|
||||
<anim name="hairFall" anim="GF Dancing Beat Hair Landing" fps="24" loop="false" x="0" y="-9" indices="0,1,2,3,4,5,6,7,8,9,10,11" />
|
||||
<anim name="scared" anim="GF FEAR" fps="24" loop="true" x="-2" y="-17" />
|
||||
</character>
|
||||
|
||||
<!-- if (!animation.curAnim.name.startsWith('hair'))
|
||||
{
|
||||
danced = !danced;
|
||||
|
||||
if (danced)
|
||||
playAnim('danceRight');
|
||||
else
|
||||
playAnim('danceLeft');
|
||||
} -->
|
||||
|
||||
<!--
|
||||
switch (curCharacter)
|
||||
{
|
||||
case 'gf':
|
||||
if (animation.curAnim.name == 'hairFall' && animation.curAnim.finished)
|
||||
playAnim('danceRight');
|
||||
} -->
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE codename-engine-character>
|
||||
<character isPlayer="false" flipX="false">
|
||||
<anim name="idle" anim="Mom Idle" fps="24" loop="false" />
|
||||
<anim name="singUP" anim="Mom Up Pose" fps="24" loop="false" x="14" y="71"/>
|
||||
<anim name="singDOWN" anim="MOM DOWN POSE" fps="24" loop="false" x="20" y="-160"/>
|
||||
<anim name="singLEFT" anim="Mom Left Pose" fps="24" loop="false" x="250" y="-23"/>
|
||||
<!-- ANIMATION IS CALLED MOM LEFT POSE BUT ITS FOR THE RIGHT -->
|
||||
<!-- CUZ DAVE IS DUMB! -->
|
||||
<anim name="singRIGHT" anim="Mom Pose Left" fps="24" loop="false" x="10" y="-60"/>
|
||||
</character>
|
||||
|
Before Width: | Height: | Size: 3.3 MiB After Width: | Height: | Size: 3.3 MiB |
+1
-1
@@ -1 +1 @@
|
||||
94
|
||||
135
|
||||
@@ -1,33 +0,0 @@
|
||||
package;
|
||||
|
||||
import lime.utils.Assets;
|
||||
import flixel.animation.FlxAnimation;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class CoolUtil
|
||||
{
|
||||
public static var difficultyArray:Array<String> = ['EASY', "NORMAL", "HARD"];
|
||||
|
||||
public static function difficultyString():String
|
||||
{
|
||||
return difficultyArray[PlayState.storyDifficulty];
|
||||
}
|
||||
|
||||
public static function coolTextFile(path:String):Array<String>
|
||||
{
|
||||
return [for(e in Assets.getText(path).trim().split('\n')) e.trim()];
|
||||
}
|
||||
|
||||
public static function numberArray(max:Int, ?min = 0):Array<Int>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package funkin.system;
|
||||
package funkin.interfaces;
|
||||
|
||||
interface IBeatReceiver {
|
||||
public function beatHit(curBeat:Int):Void;
|
||||
@@ -0,0 +1,5 @@
|
||||
package funkin.interfaces;
|
||||
|
||||
interface IOffsetCompatible {
|
||||
public function addOffset(anim:String, x:Float = 0, y:Float = 0):Void;
|
||||
}
|
||||
@@ -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<String> = ['EASY', "NORMAL", "HARD"];
|
||||
|
||||
public static function difficultyString():String
|
||||
{
|
||||
return difficultyArray[PlayState.storyDifficulty];
|
||||
}
|
||||
|
||||
public static function coolTextFile(path:String):Array<String>
|
||||
{
|
||||
return [for(e in Assets.getText(path).trim().split('\n')) e.trim()];
|
||||
}
|
||||
|
||||
public static function numberArray(max:Int, ?min = 0):Array<Int>
|
||||
{
|
||||
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<Int>;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.system;
|
||||
|
||||
import funkin.interfaces.IBeatReceiver;
|
||||
import Conductor.BPMChangeEvent;
|
||||
import flixel.FlxG;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
|
||||
+5
-4
@@ -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
|
||||
Reference in New Issue
Block a user