This commit is contained in:
Yoshman29
2022-10-30 19:53:04 +01:00
parent 9a72f0893a
commit 9c07bb26b7
5 changed files with 73 additions and 11 deletions
+1 -1
View File
@@ -1 +1 @@
822
845
+50
View File
@@ -0,0 +1,50 @@
package funkin.game;
import flixel.FlxCamera;
import lime.app.Application;
import flixel.graphics.tile.FlxGraphicsShader;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flixel.graphics.FlxGraphic;
import flixel.graphics.frames.FlxFrame;
import flixel.graphics.tile.FlxDrawBaseItem;
import flixel.graphics.tile.FlxDrawTrianglesItem;
import flixel.math.FlxMath;
import flixel.math.FlxMatrix;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxShader;
import flixel.util.FlxAxes;
import flixel.util.FlxColor;
import flixel.util.FlxDestroyUtil;
import flixel.util.FlxSpriteUtil;
import openfl.display.BlendMode;
import openfl.filters.BitmapFilter;
import openfl.filters.ShaderFilter;
import openfl.Vector;
class HudCamera extends FlxCamera {
public var downscroll:Bool = false;
public override function update(elapsed:Float) {
super.update(elapsed);
flipY = downscroll;
}
public override function drawPixels(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false,
?shader:FlxShader):Void
{
if (downscroll) {
matrix.scale(1, -1);
matrix.translate(0, height);
}
super.drawPixels(frame, pixels, matrix, transform, blend, smoothing, shader);
}
}
+4
View File
@@ -37,6 +37,10 @@ class Note extends FlxSprite
public var noteTypeID:Int = 0;
// TO APPLY THOSE ON A SINGLE NOTE
public var scrollSpeed:Null<Float> = null;
public var noteAngle:Null<Float> = null;
public var noteType(get, null):String;
private function get_noteType() {
return PlayState.instance.getNoteType(noteTypeID);
+8 -4
View File
@@ -75,6 +75,10 @@ class PlayState extends MusicBeatState
public var stage:Stage;
public var scrollSpeed:Float = 0;
public var downscroll(get, set):Bool;
@:dox(hide) private function set_downscroll(v:Bool) {return camHUD.downscroll = v;}
@:dox(hide) private function get_downscroll():Bool {return camHUD.downscroll;}
public var vocals:FlxSound;
@@ -115,12 +119,11 @@ class PlayState extends MusicBeatState
public var iconP1:HealthIcon;
public var iconP2:HealthIcon;
public var camHUD:FlxCamera;
public var camHUD:HudCamera;
public var camGame:FlxCamera;
public var songScore:Int = 0;
public var downscroll:Bool = Options.downscroll;
public var misses:Int = 0;
public var scoreTxt:FlxText;
public var missesTxt:FlxText;
@@ -154,11 +157,12 @@ class PlayState extends MusicBeatState
scripts.setParent(this);
camGame = camera;
camHUD = new FlxCamera();
camHUD = new HudCamera();
camHUD.bgColor.alpha = 0;
FlxG.cameras.add(camHUD, false);
downscroll = Options.downscroll;
// camGame.widescreen = true;
persistentUpdate = true;
@@ -988,7 +992,7 @@ class PlayState extends MusicBeatState
if (event.strum == null) return;
if (event.__reposNote) event.strum.updateNotePosition(daNote);
event.strum.updateClipRect(daNote);
event.strum.updateSustain(daNote);
PlayState.instance.scripts.event("onNoteUpdatePost", event);
}
+10 -6
View File
@@ -14,13 +14,15 @@ class Strum extends FlxSprite {
public var noteAngle:Null<Float> = null; // custom scroll speed per strum
public var downscroll:Null<Bool> = false; // custom downscroll per strum
public function getScrollSpeed() {
public function getScrollSpeed(?note:Note) {
if (note != null && note.scrollSpeed != null) return note.scrollSpeed;
if (scrollSpeed != null) return scrollSpeed;
if (PlayState.instance != null) return PlayState.instance.scrollSpeed;
return 1;
}
public function getNotesAngle() {
public function getNotesAngle(?note:Note) {
if (note != null && note.noteAngle != null) return note.noteAngle;
if (noteAngle != null) return noteAngle;
return angle;
}
@@ -44,11 +46,11 @@ class Strum extends FlxSprite {
public function updateNotePosition(daNote:Note) {
if (!daNote.exists) return;
var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(), 2)));
var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(daNote), 2)));
var realOffset = FlxPoint.get(0, 0);
if (daNote.isSustainNote) offset.y -= Note.swagWidth / 2;
var noteAngle = getNotesAngle();
var noteAngle = getNotesAngle(daNote);
daNote.angle = daNote.isSustainNote ? noteAngle : angle;
if (Std.int(noteAngle % 360) != 0) {
var noteAngleCos = Math.cos(noteAngle / 180 * Math.PI);
@@ -67,8 +69,10 @@ class Strum extends FlxSprite {
realOffset.put();
}
public function updateClipRect(daNote:Note) {
if (!daNote.isSustainNote || !daNote.wasGoodHit) return;
public function updateSustain(daNote:Note) {
if (!daNote.isSustainNote) return;
daNote.flipY = PlayState.instance.downscroll != (getScrollSpeed(daNote) < 0);
if (!daNote.wasGoodHit) return;
daNote.updateClipRect(this);
}