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

Commit

Permalink
better to cum in the sink than to skin in the cum
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 19, 2023
1 parent 4cc08a1 commit 8693767
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 13 deletions.
2 changes: 2 additions & 0 deletions source/funkin/ScriptConsole.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Print extends Sprite {
frame.copyPixels(bmp, new Rectangle(i*frameSize,0,frameSize,frameSize), new Point(0,0));
iconFrames.push(frame);
}
bmp.dispose();
bmp.disposeImage();
}

static var typeMap:Map<PrintType, {frame:Int, color:FlxColor}> = [
Expand Down
7 changes: 4 additions & 3 deletions source/funkin/graphics/FlxRepeatSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import flixel.graphics.frames.FlxFrame;
enum RepeatDrawStyle {
TOP_BOTTOM;
BOTTOM_TOP;
//FAST_BOTTOM_TOP; maybe later
}

/**
Expand Down Expand Up @@ -133,8 +134,8 @@ class FlxRepeatSprite extends FlxSpriteExt {
_frame.frame.height = (__tempPoint.y + (repeatHeight - heightPos)) / scale.y;

// Position and draw
var addX = addW - fw;
var addY = heightPos - __tempPoint.y;
final addX = addW - fw;
final addY = heightPos - __tempPoint.y;

_matrix.tx = __tilePoint.x + (addX * _cosAngle) + (addY * -_sinAngle);
_matrix.ty = __tilePoint.y + (addX * _sinAngle) + (addY * _cosAngle);
Expand Down Expand Up @@ -162,7 +163,7 @@ class FlxRepeatSprite extends FlxSpriteExt {
}

// Position and draw
var addX = addW - fw;
final addX = addW - fw;
_matrix.tx = __tilePoint.x + (addX * _cosAngle) + (heightPos * -_sinAngle);
_matrix.ty = __tilePoint.y + (addX * _sinAngle) + (heightPos * _cosAngle);

Expand Down
32 changes: 31 additions & 1 deletion source/funkin/graphics/SmartSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,37 @@ class SmartSprite extends FlxRepeatSprite {
public function new(?X:Float, ?Y:Float, ?SimpleGraphic:FlxGraphicAsset) {
super(X, Y, SimpleGraphic, 0, 0);
}

override function draw() {
switch (renderMode) {
case REPEAT: super.draw();
case QUAD:
inline checkEmptyFrame();
if (alpha == 0 || _frame.type == EMPTY) return;
if (dirty) calcFrame(useFramePixels); // rarely

for (i in 0...cameras.length) {
final camera = cameras[i];
if (!camera.visible || !camera.exists || !isOnScreen(camera)) continue;
drawComplex(camera);
}
}
}

override function getScreenBounds(?newRect:FlxRect, ?camera:FlxCamera):FlxRect {
switch (renderMode) {
case REPEAT: return super.getScreenBounds(newRect, camera);
case QUAD:
if (newRect == null) newRect = FlxRect.get();
if (camera == null) camera = FlxG.camera;
newRect.setPosition(x, y);
_scaledOrigin.set(origin.x * scale.x, origin.y * scale.y);
newRect.x += -Std.int(camera.scroll.x * scrollFactor.x) - offset.x + origin.x - _scaledOrigin.x;
newRect.y += -Std.int(camera.scroll.y * scrollFactor.y) - offset.y + origin.y - _scaledOrigin.y;
newRect.setSize(frameWidth * Math.abs(scale.x), frameHeight * Math.abs(scale.y));
return newRect.getRotatedBounds(angle, _scaledOrigin, newRect);
}
}

override function drawComplex(camera:FlxCamera) {
switch (renderMode) {
Expand All @@ -42,6 +73,5 @@ class SmartSprite extends FlxRepeatSprite {
_matrix.translate(_point.x, _point.y);
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader);
}

}
}
40 changes: 38 additions & 2 deletions source/funkin/objects/note/BasicNote.hx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package funkin.objects.note;

import openfl.Vector;
import funkin.objects.note.Sustain.TestNote;
import funkin.graphics.SmartSprite;

class BasicNote extends SmartSprite {
class BasicNote extends SmartSprite implements INoteData {
public var strumTime:Float = 0.0;
public var noteData:Int = 0;
public var noteSpeed:Float = 1.0;
public var targetStrum:NoteStrum;
public var parentNote:Note;
public var parentNote:TestNote;
public var childNote:Sustain;

public var isSustainNote(default, set):Bool = false;
Expand Down Expand Up @@ -39,6 +41,7 @@ class BasicNote extends SmartSprite {

public function new(noteData:Int = 0, strumTime:Float = 0.0, skin:String = "default") {
super();
initVariables();
this.noteData = noteData;
this.strumTime = strumTime;
this.skin = skin;
Expand Down Expand Up @@ -75,4 +78,37 @@ class BasicNote extends SmartSprite {
inline public function getPosMill(pos:Float):Float {
return pos / (0.45 * noteSpeed);
}

public var mustHit:Bool = true;
public var altAnim:String = "";
public var hitHealth:Vector<Float>;
public var missHealth:Vector<Float>;
public var hitMult:Float = 1.0;

inline function initVariables() {
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) {
final typeJson:NoteTypeJson = NoteUtil.getTypeJson(value);
mustHit = typeJson.mustHit;
altAnim = typeJson.altAnim;

for (i in 0...2) {
hitHealth[i] = typeJson.hitHealth[i];
missHealth[i] = typeJson.missHealth[i];
}

hitMult = FlxMath.bound(typeJson.hitMult, 0.01, 1);
changeSkin(typeJson.skin);

return noteType = value;
}

public function changeNoteType(value:String) {
if (noteType != value)
noteType = value;
}
}
60 changes: 53 additions & 7 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,55 @@ package funkin.objects.note;

import flixel.graphics.frames.FlxFrame;

class TestNote extends BasicNote {
public function new(noteData:Int, strumTime:Float = 0.0, skin:String = "default", ?childNote:Sustain) {
super(noteData, strumTime, skin); // Load skin
this.childNote = childNote;
isSustainNote = false;
}

override function updateSprites() {
super.updateSprites();
playAnim('scroll' + CoolUtil.directionArray[noteData]);
}

override function applyCurOffset(forced:Bool = false) {
if (animation.curAnim != null) {
if(existsOffsets(animation.curAnim.name)) {
final animOffset:FlxPoint = new FlxPoint().copyFrom(animOffsets.get(animation.curAnim.name));
if (!animOffset.isZero() || forced) {
animOffset.x *= (flippedOffsets ? -1 : 1);
updateHitbox();
offset.add(animOffset.x, animOffset.y);
}
}
}
}

public var canBeHit:Bool = false;
public var wasGoodHit:Bool = false;
public var willMiss:Bool = false;

inline public function calcHit():Void {
if (willMiss && !wasGoodHit) {
canBeHit = false;
}
else {
if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset * hitMult) {
if (strumTime < Conductor.songPosition + 0.5 * Conductor.safeZoneOffset * hitMult)
canBeHit = true;
}
else {
willMiss = canBeHit = true;
}
}
}
}

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:Note) {
public function new(noteData:Int = 0, strumTime:Float = 0.0, susLength:Float = 0.0, skin:String = "default", ?parentNote:TestNote) {
super(noteData, strumTime, skin); // Load skin

this.parentNote = parentNote;
Expand All @@ -19,24 +64,25 @@ class Sustain extends BasicNote {
//clipRect = new FlxRect(0,0,0,0);
}

function updateSusLength() {
public function updateSusLength() {
setSusLength(susLength);
}

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

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

playAnim("hold" + CoolUtil.directionArray[noteData] + "-end");
updateHitbox();

final holdFrame = animation.getByName("hold" + CoolUtil.directionArray[noteData]).frames[0];
final holdWidth = frames.getByIndex(holdFrame).frame.width * scale.x;
offset.x -= (NoteUtil.swagWidth * 0.5) - (holdWidth * scale.x * 0.5);
offset.x -= NoteUtil.swagWidth * 0.5;
offset.x += width * 0.5;

final lastHeight = repeatHeight;
setTiles(1, 1);
origin.set(width * 0.5 / scale.x, 0);
repeatHeight = lastHeight;
}

Expand Down

0 comments on commit 8693767

Please sign in to comment.