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

Commit

Permalink
good ol heapass
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 22, 2023
1 parent ae5b492 commit e5063bf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
19 changes: 8 additions & 11 deletions source/funkin/graphics/FlxRepeatSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class FlxRepeatSprite extends FlxSpriteExt {

public var tilesX(get, null):Int;
inline function get_tilesX() {
return Math.ceil(repeatWidth / (frameWidth * scale.x));
return Math.ceil(repeatWidth / (frameWidth * Math.abs(scale.x)));
}

public var tilesY(get, null):Int;
inline function get_tilesY() {
return Math.ceil(repeatHeight / (frameHeight * scale.y));
return Math.ceil(repeatHeight / (frameHeight * Math.abs(scale.y)));
}

public function setRepeat(repeatWidth:Float, repeatHeight:Float) {
Expand Down Expand Up @@ -91,6 +91,7 @@ class FlxRepeatSprite extends FlxSpriteExt {

static final __tilePoint:FlxPoint = FlxPoint.get();
static final __tempPoint:FlxPoint = FlxPoint.get();
static final __lastMatrix = FlxPoint.get(); // Nasty hack
static var __drawCam:FlxCamera;

override function drawComplex(camera:FlxCamera) {
Expand All @@ -113,11 +114,9 @@ class FlxRepeatSprite extends FlxSpriteExt {
**/

__tilePoint.set(_matrix.tx, _matrix.ty);
final fw:Float = frameWidth * scale.x;
__lastMatrix.set(-1, -1);

_frame.frame.width = frameWidth;
_frame.frame.height = frameHeight;
lastMatrix.set(-1,-1);
final fw:Float = frameWidth * scale.x; // TODO: replace this shit same way as Height

switch (drawStyle) {
// Draw from left top to right bottom style
Expand Down Expand Up @@ -177,7 +176,7 @@ class FlxRepeatSprite extends FlxSpriteExt {

}

function translateWithTrig(tx:Float, ty:Float) {
private inline function translateWithTrig(tx:Float, ty:Float) {
_matrix.tx += (tx * _cosAngle) + (ty * -_sinAngle);
_matrix.ty += (tx * _sinAngle) + (ty * _cosAngle);
}
Expand All @@ -189,14 +188,12 @@ class FlxRepeatSprite extends FlxSpriteExt {
return __tempPoint;
}

static var lastMatrix = FlxPoint.get(); // Nasty hack

function drawTile(tileX:Int, tileY:Int, tileFrame:FlxFrame, baseFrame:FlxFrame, bitmap:BitmapData, tilePos:FlxPoint) {
final __doDraw:Bool = clipRect != null ? handleClipRect(tileFrame, baseFrame, tilePos) : true;
if (tileRect != null) tileFrame = tileFrame.clipTo(tileRect);

if (__doDraw && (lastMatrix.x != _matrix.tx || lastMatrix.y != _matrix.ty)) {
lastMatrix.set(_matrix.tx, _matrix.ty);
if (__doDraw && (__lastMatrix.x != _matrix.tx || __lastMatrix.y != _matrix.ty)) {
__lastMatrix.set(_matrix.tx, _matrix.ty);
if (!matrixOutOfBounds(_matrix, tileFrame.frame, __drawCam)) // dont draw stuff out of bounds
__drawCam.drawPixels(tileFrame, bitmap, _matrix, colorTransform, blend, antialiasing, shader);
}
Expand Down
17 changes: 14 additions & 3 deletions source/funkin/graphics/FlxSkewRepeatSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import flixel.graphics.frames.FlxFrame;
import openfl.display.BitmapData;

/*
TODO: add skew y support (_matrix.b) and fix problems with dynamically sized tiles
TODO:
add skew y support (_matrix.b) and fix problems with dynamically sized tiles
implement smoothTiles u dumb fuck
*/

class FlxSkewRepeatSprite extends FlxRepeatSprite {
Expand All @@ -14,11 +16,20 @@ class FlxSkewRepeatSprite extends FlxRepeatSprite {

public var wigglePower:Float = 50.0;

var _:Float = 0.0;

override function update(elapsed:Float) {
super.update(elapsed);
clipRect.y -= elapsed * 25;
clipRect.y -= elapsed * 50;
_ += elapsed * 10;
wigglePower = FlxMath.fastSin(_) * 75;

if (FlxG.keys.justPressed.SPACE) clipRect.y = 0;
}

public var calcHeight:Int = -1;
public var smoothTiles:Int = 1;

override function drawTile(tileX:Int, tileY:Int, tileFrame:FlxFrame, baseFrame:FlxFrame, bitmap:BitmapData, tilePos:FlxPoint) {
if (wigglePower == 0) {
super.drawTile(tileX, tileY, tileFrame, baseFrame, bitmap, tilePos);
Expand All @@ -29,7 +40,7 @@ class FlxSkewRepeatSprite extends FlxRepeatSprite {

tempMatrix.copyFrom(_matrix);

final wiggleX = wigglePower * ((baseFrame.frame.height * scale.y) * 0.01); // Value outta my ass but trust me bro
final wiggleX = wigglePower * (calcHeight != -1 ? calcHeight : baseFrame.frame.height) * scale.y * 0.01; // Value outta my ass but trust me bro
final skewX = wiggleX * (idY % 2 == 0 ? -1 : 1);
_matrix.c = Math.tan(skewX * FlxAngle.TO_RAD);

Expand Down
13 changes: 9 additions & 4 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ class Sustain extends BasicNote {
//clipRect = new FlxRect(0,0,0,0);
}

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

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

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

override function updateSprites() {
Expand All @@ -83,6 +87,7 @@ class Sustain extends BasicNote {
final lastHeight = repeatHeight;
setTiles(1, 1);
origin.set(width * 0.5 / scale.x, 0);
calcHeight = frameHeight;
repeatHeight = lastHeight;
}

Expand Down

0 comments on commit e5063bf

Please sign in to comment.