Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
chipi chipi chapa chapa
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 22, 2023
1 parent e5063bf commit 0834df0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 28 deletions.
8 changes: 4 additions & 4 deletions source/funkin/graphics/FlxRepeatSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ class FlxRepeatSprite extends FlxSpriteExt {
}

inline function matrixOutOfBounds(matrix:FlxMatrix, frame:FlxRect, cam:FlxCamera):Bool {
return ((_matrix.ty + (frame.height * scale.y)) < cam.viewY) ||
((_matrix.ty - (frame.height * scale.y)) > cam.viewHeight) ||
((_matrix.tx + (frame.width * scale.x)) < cam.viewX) ||
((_matrix.tx - (frame.width * scale.x)) > cam.viewWidth);
return ((_matrix.ty + (frame.height * scale.y)) < cam.viewY) ||
((_matrix.ty - (frame.height * scale.y)) > cam.viewHeight) ||
((_matrix.tx + (frame.width * scale.x)) < cam.viewX) ||
((_matrix.tx - (frame.width * scale.x)) > cam.viewWidth);
}

function handleClipRect(tileFrame:FlxFrame, baseFrame:FlxFrame, tilePos:FlxPoint) {
Expand Down
4 changes: 2 additions & 2 deletions source/funkin/graphics/FlxSkewRepeatSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FlxSkewRepeatSprite extends FlxRepeatSprite {

public var wigglePower:Float = 50.0;

var _:Float = 0.0;
/*var _:Float = 0.0;
override function update(elapsed:Float) {
super.update(elapsed);
Expand All @@ -25,7 +25,7 @@ class FlxSkewRepeatSprite extends FlxRepeatSprite {
wigglePower = FlxMath.fastSin(_) * 75;
if (FlxG.keys.justPressed.SPACE) clipRect.y = 0;
}
}*/

public var calcHeight:Int = -1;
public var smoothTiles:Int = 1;
Expand Down
33 changes: 20 additions & 13 deletions source/funkin/objects/note/BasicNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ class BasicNote extends SmartSprite implements INoteData {
return skin;
}

public function changeSkin(?value:String) {
public function changeSkin(?value:String):Void {
if (value != skin)
skin = value;
}

public function updateSprites() {
public function updateSprites():Void {
loadFromSprite(curSkinData.baseSprite);
}

public var approachAngle:Float = 0;
public var spawnMult:Float = 1.0;

public function new(noteData:Int = 0, strumTime:Float = 0.0, skin:String = "default") {
public function new(noteData:Int = 0, strumTime:Float = 0.0, skin:String = "default"):Void {
super();
initVariables();
this.noteData = noteData;
Expand All @@ -49,24 +49,31 @@ class BasicNote extends SmartSprite implements INoteData {
moves = false; // Save on velocity calculation
}

override function update(elapsed:Float) {
override function update(elapsed:Float):Void {
super.update(elapsed);
if (targetStrum != null) {
moveToStrum();
}
}

inline public function moveToStrum() {
final noteMove:Float = getMillPos(Conductor.songPosition - strumTime); // Position with strumtime
y = targetStrum.y - (noteMove * getCos()); // Set Position
x = targetStrum.x - (noteMove * -getSin());
public var xDisplace:Float = 0.0;
public var yDisplace:Float = 0.0;

inline public function moveToStrum():Void {
final noteMove:Float = distanceToStrum(); // Position with strumtime
y = targetStrum.y + xDisplace - (noteMove * getCos()); // Set Position
x = targetStrum.x + yDisplace - (noteMove * -getSin());
}

inline public function distanceToStrum():Float {
return getMillPos(Conductor.songPosition - strumTime);
}

inline public function getCos() {
inline public function getCos():Float {
return FlxMath.fastCos(FlxAngle.asRadians(approachAngle));
}

inline public function getSin() {
inline public function getSin():Float {
return FlxMath.fastSin(FlxAngle.asRadians(approachAngle));
}

Expand All @@ -86,13 +93,13 @@ class BasicNote extends SmartSprite implements INoteData {
public var missHealth:Vector<Float>;
public var hitMult:Float = 1.0;

inline function initVariables() {
inline function initVariables():Void {
hitHealth = new Vector<Float>(2, true, [0.025, 0.0125]);
missHealth = new Vector<Float>(2, true, [0.0475, 0.02375]);
}

public var noteType(default, set):String = "default";
inline function set_noteType(value:String) {
inline function set_noteType(value:String):String {
final typeJson:NoteTypeJson = NoteUtil.getTypeJson(value);
mustHit = typeJson.mustHit;
altAnim = typeJson.altAnim;
Expand All @@ -108,7 +115,7 @@ class BasicNote extends SmartSprite implements INoteData {
return noteType = value;
}

public function changeNoteType(value:String) {
public function changeNoteType(value:String):Void {
if (noteType != value)
noteType = value;
}
Expand Down
30 changes: 21 additions & 9 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,39 @@ class TestNote extends BasicNote {
class Sustain extends BasicNote {
public var susLength:Float = 0.0;

public function new(noteData:Int = 0, strumTime:Float = 0.0, susLength:Float = 0.0, skin:String = "default", ?parentNote:TestNote) {
public function new(noteData:Int = 0, strumTime:Float = 0.0, susLength:Float = 0.0, skin:String = "default", ?parentNote:TestNote):Void {
clipRect = FlxRect.get();
super(noteData, strumTime, skin); // Load skin

this.parentNote = parentNote;
isSustainNote = true;
drawStyle = BOTTOM_TOP;
alpha = 0.6;

yDisplace = NoteUtil.swagHeight * 0.5;
this.susLength = susLength;
setSusLength(susLength);
}

//clipRect = new FlxRect(0,0,0,0);
public inline function inSustain():Bool {
return Conductor.songPosition >= strumTime && Conductor.songPosition <= (susLength + Conductor.stepCrochet);
}

public inline function updateSusLength() {
public inline function updateSusLength():Float {
return setSusLength(susLength);
}

public inline function setSusLength(mills:Float = 0.0) {
return repeatHeight = getMillPos(mills) + NoteUtil.swagHeight * 0.5;
public inline function setSusLength(mills:Float = 0.0):Float {
repeatHeight = getMillPos(mills) + NoteUtil.swagHeight * 0.5;
clipRect.height = repeatHeight;
return repeatHeight;
}

public inline function setSusSecs(secs:Float = 0.0) {
public inline function setSusSecs(secs:Float = 0.0):Float {
return setSusLength(secs * 1000);
}

override function updateSprites() {
override function updateSprites():Void {
super.updateSprites();

playAnim("hold" + CoolUtil.directionArray[noteData]);
Expand All @@ -89,17 +95,23 @@ class Sustain extends BasicNote {
origin.set(width * 0.5 / scale.x, 0);
calcHeight = frameHeight;
repeatHeight = lastHeight;
clipRect.width = repeatWidth;
}

override function setupTile(tileX:Int, tileY:Int, baseFrame:FlxFrame) {
override function setupTile(tileX:Int, tileY:Int, baseFrame:FlxFrame):FlxPoint {
switch (tileY) {
case 0: playAnim("hold" + CoolUtil.directionArray[noteData] + "-end"); // Tail
case 1: playAnim("hold" + CoolUtil.directionArray[noteData]); // Piece
}
return super.setupTile(tileX, tileY, frame);
}

override function applyCurOffset(forced:Bool = false) {
override function handleClipRect(tileFrame:FlxFrame, baseFrame:FlxFrame, tilePos:FlxPoint):Bool {
clipRect.y = Math.min(clipRect.y, 0);
return super.handleClipRect(tileFrame, baseFrame, tilePos);
}

override function applyCurOffset(forced:Bool = false):Void {
// we dont need offsets for these
}
}

0 comments on commit 0834df0

Please sign in to comment.