Skip to content

Commit

Permalink
WIP StrumLine and Strum class
Browse files Browse the repository at this point in the history
  • Loading branch information
rodney528 committed May 7, 2024
1 parent 7b4fff6 commit 144bc20
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 253 deletions.
25 changes: 14 additions & 11 deletions source/fnf/objects/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ class Character extends FlxSprite {

public var holdTimer:Float = 0;

public var specialAnim:Bool = false;
public var stunned:Bool = false;
public var singDuration:Float = 4; // Multiplier of how long a character holds the sing pose.
public var idleSuffix:String = '';
public var danceIdle:Bool = false; // Character use "danceLeft" and "danceRight" instead of "idle".
public var skipDance:Bool = false;
public var preventIdle:Bool = false;

public var positionOffset = {x: 0.0, y: 0.0};
public var cameraPosition = {x: 0.0, y: 0.0};
Expand All @@ -32,8 +31,6 @@ class Character extends FlxSprite {
public var originalFlipX:Bool = false;
public var iconColor:FlxColor = 0xFF0000;

public var singAnims:Array<String> = ['singLEFT', 'singDOWN', 'singUP', 'singRIGHT'];

public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false) {
super(x, y);

Expand Down Expand Up @@ -508,10 +505,10 @@ class Character extends FlxSprite {

override function update(elapsed:Float) {
if (!debugMode && animation.curAnim != null) {
if (specialAnim && animation.curAnim.finished) {
/* if (specialAnim && animation.curAnim.finished) {
specialAnim = false;
dance();
} else if (animation.curAnim.name.endsWith('miss') && animation.curAnim.finished) {
} else */ if (animation.curAnim.name.endsWith('miss') && animation.curAnim.finished) {
dance();
animation.finish();
}
Expand Down Expand Up @@ -548,7 +545,7 @@ class Character extends FlxSprite {
* FOR GF DANCING SHIT
*/
public function dance() {
if (!debugMode && !skipDance && !specialAnim) {
if (!debugMode && !preventIdle) {
if (danceIdle) {
danced = !danced;
if (danced) playAnim('danceRight' + idleSuffix);
Expand All @@ -559,14 +556,20 @@ class Character extends FlxSprite {
}
}

public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void {
var daOffset = animOffsets.get(AnimName);
if (animOffsets.exists(AnimName)) {
animation.play(AnimName, Force, Reversed, Frame);
public var singAnims:Array<String> = ['singLEFT', 'singDOWN', 'singUP', 'singRIGHT'];
public function playAnim(name:String, force:Bool = false, reverse:Bool = false, frame:Int = 0):Void {
var daOffset = animOffsets.get(name);
if (animOffsets.exists(name)) {
animation.play(name, force, reverse, frame);
offset.set(daOffset[0], daOffset[1]);
}
}

public function playSingAnim(direction:Int, suffix:String = '', missed:Bool = false, force:Bool = false, reverse:Bool = false, frame:Int = 0) {
playAnim('${singAnims[direction]}${missed ? 'miss' : ''}$suffix', force, reverse, frame);
if (!missed) holdTimer = 0;
}

public function addOffset(name:String, x:Float = 0, y:Float = 0) {
animOffsets[name] = [x, y];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package fnf.objects.note;

class NoteSplash extends FlxSprite
{
public function new(x:Float, y:Float, noteData:Int = 0):Void
{
class Splash extends FlxSprite {
public function new(x:Float, y:Float, noteData:Int = 0):Void {
super(x, y);

frames = Paths.getSparrowAtlas('noteSplashes');
Expand Down
91 changes: 91 additions & 0 deletions source/fnf/objects/note/Strum.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package fnf.objects.note;

import fnf.graphics.shaders.ColorSwap;

class Strum extends FlxSprite {
var isPixel:Bool = false;
var pixelZoom:Float = 6;

override public function new(x:Float, y:Float, data:Int, pixel:Bool = false) {
super(x, y);
var colorswap:ColorSwap = new ColorSwap();
shader = colorswap.shader;
isPixel = pixel;

if (isPixel) {
loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels'), true, 17, 17);
animation.add('purple', [4]);
animation.add('blue', [5]);
animation.add('green', [6]);
animation.add('red', [7]);

antialiasing = false;
setGraphicSize(Std.int(width * pixelZoom));
updateHitbox();

switch (data) {
case 0:
animation.add('static', [0]);
animation.add('press', [4, 8], 12, false);
animation.add('confirm', [12, 16], 24, false);
case 1:
animation.add('static', [1]);
animation.add('press', [5, 9], 12, false);
animation.add('confirm', [13, 17], 24, false);
case 2:
animation.add('static', [2]);
animation.add('press', [6, 10], 12, false);
animation.add('confirm', [14, 18], 12, false);
case 3:
animation.add('static', [3]);
animation.add('press', [7, 11], 12, false);
animation.add('confirm', [15, 19], 24, false);
}
} else {
frames = Paths.getSparrowAtlas('NOTE_assets');
animation.addByPrefix('purple', 'arrowLEFT');
animation.addByPrefix('blue', 'arrowDOWN');
animation.addByPrefix('green', 'arrowUP');
animation.addByPrefix('red', 'arrowRIGHT');

antialiasing = true;
setGraphicSize(Std.int(width * 0.7));
updateHitbox();

switch (data) {
case 0:
animation.addByPrefix('static', 'arrow static instance 1');
animation.addByPrefix('press', 'left press', 24, false);
animation.addByPrefix('confirm', 'left confirm', 24, false);
case 1:
animation.addByPrefix('static', 'arrow static instance 2');
animation.addByPrefix('press', 'down press', 24, false);
animation.addByPrefix('confirm', 'down confirm', 24, false);
case 2:
animation.addByPrefix('static', 'arrow static instance 4');
animation.addByPrefix('press', 'up press', 24, false);
animation.addByPrefix('confirm', 'up confirm', 24, false);
case 3:
animation.addByPrefix('static', 'arrow static instance 3');
animation.addByPrefix('press', 'right press', 24, false);
animation.addByPrefix('confirm', 'right confirm', 24, false);
}
}

animation.finishCallback = function(name:String) {
if (name == 'confirm') {
playAnim('press', true);
}
}
}

override public function update(elapsed:Float) {

}

public function playAnim(name:String, force:Bool = false, reverse:Bool = false, frame:Int = 0):Void {
animation.play(name, force, reverse, frame);
centerOffsets();
centerOrigin();
}
}
15 changes: 15 additions & 0 deletions source/fnf/objects/note/StrumLine.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fnf.objects.note;

class StrumLine extends FlxTypedGroup<Strum> {
override public function new(x:Float, y:Float, pixel:Bool = false, hate:Int) {
super();
for (i in 0...4) {
var babyArrow:Strum = new Strum(Note.swagWidth * i, y, i, pixel);
babyArrow.ID = i;
babyArrow.playAnim('static', true);
babyArrow.x += 50;
babyArrow.x += ((FlxG.width / 2) * hate);
add(babyArrow);
}
}
}
Loading

0 comments on commit 144bc20

Please sign in to comment.