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

Commit

Permalink
new notes system part 2 (KINDA PLAYABLE WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 24, 2023
1 parent 6de2696 commit 8a78ad3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
Binary file modified assets/shared/images/skins/pixel/noteAssets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion source/funkin/graphics/SmartSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enum RenderMode {
REPEAT;
}

class SmartSprite extends FlxSkewRepeatSprite {
class SmartSprite extends FlxRepeatSprite {
public var renderMode:RenderMode = QUAD;
public function setRenderMode(value:String) {
renderMode = switch (value.toLowerCase().trim()) {
Expand Down
12 changes: 10 additions & 2 deletions source/funkin/objects/note/BasicNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ class BasicNote extends SmartSprite implements INoteData {
public var strumTime:Float = 0.0;
public var noteData:Int = 0;
public var mustPress:Bool = false;
public var targetStrum:NoteStrum;
public var parent:Note;
public var child:Sustain;

public var targetStrum(default, set):NoteStrum;
function set_targetStrum(value:NoteStrum):NoteStrum {
return targetStrum = value;
}

public var noteSpeed(default, set):Float = 1.0;
function set_noteSpeed(value:Float):Float {
return noteSpeed = value;
Expand Down Expand Up @@ -44,7 +48,11 @@ class BasicNote extends SmartSprite implements INoteData {
loadFromSprite(curSkinData.baseSprite);
}

public var approachAngle:Float = 0;
public var approachAngle(default, set):Float = 0;
function set_approachAngle(value:Float):Float {
return approachAngle = value;
}

public var spawnMult:Float = 1.0;

public function new(noteData:Int = 0, strumTime:Float = 0.0, skin:String = "default"):Void {
Expand Down
5 changes: 5 additions & 0 deletions source/funkin/objects/note/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Note extends BasicNote {
}
}

override function update(elapsed:Float) {
super.update(elapsed);
calcHit();
}

public var canBeHit:Bool = false;
public var wasGoodHit:Bool = false;
public var willMiss:Bool = false;
Expand Down
32 changes: 20 additions & 12 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class Sustain extends BasicNote {
return value;
}

public var autoFlip:Bool = true; // If to flip the sustain at a certain angle
override function set_approachAngle(value:Float):Float {
if (autoFlip) flipX = value % 360 >= 180;
return approachAngle = angle = value;
}

inline public static var MISS_COLOR:Int = 0xffc8c8c8;

public var pressed:Bool = false;
Expand All @@ -44,7 +50,7 @@ class Sustain extends BasicNote {
final susY:Float = getMillPos(strumTime - Conductor.songPosition);
percentLeft = repeatHeight / -susY;
clipRect.y = susY;
offset.y = susY;
offset.y = susY * getCos();
if (susY <= -repeatHeight) {
kill();
}
Expand All @@ -60,7 +66,7 @@ class Sustain extends BasicNote {
}

public inline function setSusLength(mills:Float = 0.0):Float {
repeatHeight = getMillPos(mills) + NoteUtil.swagHeight * 0.5;
repeatHeight = getMillPos(mills) + (NoteUtil.swagHeight * 0.5);
clipRect.height = repeatHeight;
return repeatHeight;
}
Expand All @@ -69,19 +75,26 @@ class Sustain extends BasicNote {
return setSusLength(secs * 1000);
}

override function set_targetStrum(value:NoteStrum):NoteStrum {
if (value != null) {
updateHitbox();
offset.y = 0;
offset.x -= value.width * 0.5 - width * 0.5;
}
return targetStrum = value;
}

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

playAnim("hold" + CoolUtil.directionArray[noteData]);
updateHitbox();
offset.x -= NoteUtil.swagWidth * 0.5;
offset.x += width * 0.5;
offset.y = 0;
playAnim("hold" + CoolUtil.directionArray[noteData] + "-end");
targetStrum = targetStrum;

final lastHeight = repeatHeight;
setTiles(1, 1);
origin.set(width * 0.5 / scale.x, 0);
calcHeight = frameHeight;
//calcHeight = frameHeight;
repeatHeight = lastHeight;
clipRect.width = repeatWidth;
}
Expand All @@ -94,11 +107,6 @@ class Sustain extends BasicNote {
return super.setupTile(tileX, tileY, frame);
}

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
}
Expand Down

0 comments on commit 8a78ad3

Please sign in to comment.