mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-26 15:07:14 +00:00
character repositioning proof of concept stuf
This commit is contained in:
parent
231f76c893
commit
282e93e1ff
|
@ -10,13 +10,13 @@ import flixel.math.FlxRect;
|
||||||
import flixel.system.FlxAssets.FlxGraphicAsset;
|
import flixel.system.FlxAssets.FlxGraphicAsset;
|
||||||
import flixel.tweens.FlxEase;
|
import flixel.tweens.FlxEase;
|
||||||
import flixel.tweens.FlxTween;
|
import flixel.tweens.FlxTween;
|
||||||
|
import funkin.play.PlayState;
|
||||||
|
import funkin.shaderslmfao.ScreenWipeShader;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
import haxe.format.JsonParser;
|
import haxe.format.JsonParser;
|
||||||
import lime.math.Rectangle;
|
import lime.math.Rectangle;
|
||||||
import lime.utils.Assets;
|
import lime.utils.Assets;
|
||||||
import openfl.filters.ShaderFilter;
|
import openfl.filters.ShaderFilter;
|
||||||
import funkin.play.PlayState;
|
|
||||||
import funkin.shaderslmfao.ScreenWipeShader;
|
|
||||||
|
|
||||||
using StringTools;
|
using StringTools;
|
||||||
|
|
||||||
|
@ -68,18 +68,34 @@ class CoolUtil
|
||||||
static var oldCamPos:FlxPoint = new FlxPoint();
|
static var oldCamPos:FlxPoint = new FlxPoint();
|
||||||
static var oldMousePos:FlxPoint = new FlxPoint();
|
static var oldMousePos:FlxPoint = new FlxPoint();
|
||||||
|
|
||||||
public static function mouseCamDrag():Void
|
/**
|
||||||
|
* Used to be for general camera middle click dragging, now generalized for any click and drag type shit!
|
||||||
|
* Listen I don't make the rules here
|
||||||
|
* @param target what you want to be dragged, defaults to CAMERA SCROLL
|
||||||
|
* @param jusPres the "justPressed", should be a button of some sort
|
||||||
|
* @param pressed the "pressed", which should be the same button as `jusPres`
|
||||||
|
*/
|
||||||
|
public static function mouseCamDrag(?target:FlxPoint, ?jusPres:Bool, ?pressed:Bool):Void
|
||||||
{
|
{
|
||||||
if (FlxG.mouse.justPressedMiddle)
|
if (target == null)
|
||||||
|
target = FlxG.camera.scroll;
|
||||||
|
|
||||||
|
if (jusPres == null)
|
||||||
|
jusPres = FlxG.mouse.justPressedMiddle;
|
||||||
|
|
||||||
|
if (pressed == null)
|
||||||
|
pressed = FlxG.mouse.pressedMiddle;
|
||||||
|
|
||||||
|
if (jusPres)
|
||||||
{
|
{
|
||||||
oldCamPos.set(FlxG.camera.scroll.x, FlxG.camera.scroll.y);
|
oldCamPos.set(target.x, target.y);
|
||||||
oldMousePos.set(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
oldMousePos.set(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FlxG.mouse.pressedMiddle)
|
if (pressed)
|
||||||
{
|
{
|
||||||
FlxG.camera.scroll.x = oldCamPos.x - (FlxG.mouse.screenX - oldMousePos.x);
|
target.x = oldCamPos.x - (FlxG.mouse.screenX - oldMousePos.x);
|
||||||
FlxG.camera.scroll.y = oldCamPos.y - (FlxG.mouse.screenY - oldMousePos.y);
|
target.y = oldCamPos.y - (FlxG.mouse.screenY - oldMousePos.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import funkin.play.stage.Stage;
|
||||||
import funkin.play.stage.StageData;
|
import funkin.play.stage.StageData;
|
||||||
import funkin.ui.PopUpStuff;
|
import funkin.ui.PopUpStuff;
|
||||||
import funkin.ui.PreferencesMenu;
|
import funkin.ui.PreferencesMenu;
|
||||||
|
import funkin.ui.stageBuildShit.StageOffsetSubstate;
|
||||||
import funkin.util.Constants;
|
import funkin.util.Constants;
|
||||||
import funkin.util.SortUtil;
|
import funkin.util.SortUtil;
|
||||||
import lime.ui.Haptic;
|
import lime.ui.Haptic;
|
||||||
|
@ -624,6 +625,15 @@ class PlayState extends MusicBeatState implements IHook
|
||||||
super.debug_refreshModules();
|
super.debug_refreshModules();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses music and vocals easily.
|
||||||
|
*/
|
||||||
|
public function pauseMusic()
|
||||||
|
{
|
||||||
|
FlxG.sound.music.pause();
|
||||||
|
vocals.pause();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads stage data from cache, assembles the props,
|
* Loads stage data from cache, assembles the props,
|
||||||
* and adds it to the state.
|
* and adds it to the state.
|
||||||
|
@ -939,6 +949,11 @@ class PlayState extends MusicBeatState implements IHook
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.U)
|
||||||
|
{
|
||||||
|
openSubState(new StageOffsetSubstate());
|
||||||
|
}
|
||||||
|
|
||||||
updateHealthBar();
|
updateHealthBar();
|
||||||
updateScoreText();
|
updateScoreText();
|
||||||
|
|
||||||
|
@ -1071,7 +1086,7 @@ class PlayState extends MusicBeatState implements IHook
|
||||||
changeSection(-1);
|
changeSection(-1);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
if (camZooming)
|
if (camZooming && subState == null)
|
||||||
{
|
{
|
||||||
FlxG.camera.zoom = FlxMath.lerp(defaultCameraZoom, FlxG.camera.zoom, 0.95);
|
FlxG.camera.zoom = FlxMath.lerp(defaultCameraZoom, FlxG.camera.zoom, 0.95);
|
||||||
camHUD.zoom = FlxMath.lerp(1 * FlxCamera.defaultZoom, camHUD.zoom, 0.95);
|
camHUD.zoom = FlxMath.lerp(1 * FlxCamera.defaultZoom, camHUD.zoom, 0.95);
|
||||||
|
@ -1776,6 +1791,8 @@ class PlayState extends MusicBeatState implements IHook
|
||||||
// That combo counter that got spoiled that one time.
|
// That combo counter that got spoiled that one time.
|
||||||
// Comes with NEAT visual and audio effects.
|
// Comes with NEAT visual and audio effects.
|
||||||
|
|
||||||
|
// bruh this var is bonkers i thot it was a function lmfaooo
|
||||||
|
|
||||||
var shouldShowComboText:Bool = (curBeat % 8 == 7) // End of measure. TODO: Is this always the correct time?
|
var shouldShowComboText:Bool = (curBeat % 8 == 7) // End of measure. TODO: Is this always the correct time?
|
||||||
&& (SongLoad.getSong()[Std.int(curStep / 16)].mustHitSection) // Current section is BF's.
|
&& (SongLoad.getSong()[Std.int(curStep / 16)].mustHitSection) // Current section is BF's.
|
||||||
&& (combo > 5) // Don't want to show on small combos.
|
&& (combo > 5) // Don't want to show on small combos.
|
||||||
|
@ -1991,9 +2008,10 @@ class PlayState extends MusicBeatState implements IHook
|
||||||
/**
|
/**
|
||||||
* Resets the camera's zoom level and focus point.
|
* Resets the camera's zoom level and focus point.
|
||||||
*/
|
*/
|
||||||
function resetCamera():Void
|
public function resetCamera():Void
|
||||||
{
|
{
|
||||||
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
|
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
|
||||||
|
FlxG.camera.targetOffset.set();
|
||||||
FlxG.camera.zoom = defaultCameraZoom;
|
FlxG.camera.zoom = defaultCameraZoom;
|
||||||
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
||||||
}
|
}
|
||||||
|
|
73
source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
Normal file
73
source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
package funkin.ui.stageBuildShit;
|
||||||
|
|
||||||
|
import flixel.math.FlxPoint;
|
||||||
|
import flixel.ui.FlxButton;
|
||||||
|
import funkin.play.PlayState;
|
||||||
|
|
||||||
|
class StageOffsetSubstate extends MusicBeatSubstate
|
||||||
|
{
|
||||||
|
public function new()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
FlxG.mouse.visible = true;
|
||||||
|
PlayState.instance.pauseMusic();
|
||||||
|
FlxG.camera.target = null;
|
||||||
|
|
||||||
|
var btn:FlxButton = new FlxButton(10, 10, "SAVE COMPILE", function()
|
||||||
|
{
|
||||||
|
// put character position data to a file of some sort
|
||||||
|
});
|
||||||
|
btn.scrollFactor.set();
|
||||||
|
add(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
var mosPosOld:FlxPoint = new FlxPoint();
|
||||||
|
var sprOld:FlxPoint = new FlxPoint();
|
||||||
|
|
||||||
|
override function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
|
||||||
|
CoolUtil.mouseCamDrag();
|
||||||
|
|
||||||
|
if (FlxG.keys.pressed.CONTROL)
|
||||||
|
CoolUtil.mouseWheelZoom();
|
||||||
|
|
||||||
|
if (FlxG.mouse.pressed)
|
||||||
|
{
|
||||||
|
if (FlxG.mouse.justPressed)
|
||||||
|
{
|
||||||
|
sprOld.x = PlayState.instance.currentStage.getBoyfriend().x;
|
||||||
|
sprOld.y = PlayState.instance.currentStage.getBoyfriend().y;
|
||||||
|
|
||||||
|
mosPosOld.x = FlxG.mouse.x;
|
||||||
|
mosPosOld.y = FlxG.mouse.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayState.instance.currentStage.getBoyfriend().x = sprOld.x - (mosPosOld.x - FlxG.mouse.x);
|
||||||
|
PlayState.instance.currentStage.getBoyfriend().y = sprOld.y - (mosPosOld.y - FlxG.mouse.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.mouse.pressedRight)
|
||||||
|
{
|
||||||
|
if (FlxG.mouse.justPressedRight)
|
||||||
|
{
|
||||||
|
sprOld.x = PlayState.instance.currentStage.getDad().x;
|
||||||
|
sprOld.y = PlayState.instance.currentStage.getDad().y;
|
||||||
|
|
||||||
|
mosPosOld.x = FlxG.mouse.x;
|
||||||
|
mosPosOld.y = FlxG.mouse.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayState.instance.currentStage.getDad().x = sprOld.x - (mosPosOld.x - FlxG.mouse.x);
|
||||||
|
PlayState.instance.currentStage.getDad().y = sprOld.y - (mosPosOld.y - FlxG.mouse.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.Y)
|
||||||
|
{
|
||||||
|
PlayState.instance.resetCamera();
|
||||||
|
FlxG.mouse.visible = false;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue