1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-05-21 14:41:10 +00:00

camera bullshit for menus a lil cooler

This commit is contained in:
Cameron Taylor 2021-04-04 10:17:46 -07:00
parent 6cd6f9b0f7
commit 08074f56a5
6 changed files with 117 additions and 79 deletions

View file

@ -122,7 +122,7 @@
<!--In case you want to use the ui package-->
<haxelib name="flixel-ui" />
<haxelib name="newgrounds" unless="switch"/>
<!--haxelib name="newgrounds" unless="switch"/> -->
<haxelib name="faxe" if='switch'/>
<haxelib name="polymod"/>
<haxelib name="hxcpp-debug-server" if="desktop debug"/>

View file

@ -43,6 +43,18 @@ class CoolUtil
return dumbArray;
}
/**
Lerps camera, but accountsfor framerate shit?
Right now it's simply for use to change the followLerp variable of a camera during update
TODO LATER MAYBE:
Actually make and modify the scroll and lerp shit in it's own function
instead of solely relying on changing the lerp on the fly
*/
public static function camLerpShit(lerp:Float):Float
{
return lerp * (FlxG.elapsed / (1 / 60));
}
public static function fromAnimate(Source:FlxGraphicAsset, Description:String):FlxAtlasFrames
{
var graphic:FlxGraphic = FlxG.bitmap.add(Source);

View file

@ -237,6 +237,8 @@ class MainMenuState extends MusicBeatState
override function update(elapsed:Float)
{
FlxG.camera.followLerp = CoolUtil.camLerpShit(0.06);
if (FlxG.sound.music.volume < 0.8)
{
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;

View file

@ -1453,7 +1453,7 @@ class PlayState extends MusicBeatState
override public function update(elapsed:Float)
{
// makes the lerp non-dependant on the framerate
FlxG.camera.followLerp = 0.04 * (elapsed / (1 / 60));
FlxG.camera.followLerp = CoolUtil.camLerpShit(0.04);
#if !debug
perfectMode = false;

View file

@ -1,15 +1,14 @@
package ui;
import flixel.input.actions.FlxActionInput;
import flixel.input.gamepad.FlxGamepadInputID;
import flixel.FlxG;
import Controls;
import flixel.FlxCamera;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.input.actions.FlxActionInput;
import flixel.input.gamepad.FlxGamepadInputID;
import flixel.input.keyboard.FlxKey;
import Controls;
import ui.AtlasText;
import ui.MenuList;
import ui.TextMenuList;
@ -23,9 +22,9 @@ class ControlsMenu extends ui.OptionsState.Page
* if the player sets Back to Z it also set ACCEPT to X. This prevents the player from setting the controls in
* a way the prevents them from changing more controls or exiting the menu.
*/
static var controlGroups:Array<Array<Control>> =
[ [ NOTE_UP, NOTE_DOWN, NOTE_LEFT, NOTE_RIGHT ]
, [ UI_UP, UI_DOWN, UI_LEFT, UI_RIGHT, ACCEPT, BACK ]
static var controlGroups:Array<Array<Control>> = [
[NOTE_UP, NOTE_DOWN, NOTE_LEFT, NOTE_RIGHT],
[UI_UP, UI_DOWN, UI_LEFT, UI_RIGHT, ACCEPT, BACK]
];
var itemGroups:Array<Array<InputItem>> = [for (i in 0...controlGroups.length) []];
@ -124,11 +123,11 @@ class ControlsMenu extends ui.OptionsState.Page
var margin = 100;
menuCamera.deadzone.set(0, margin, menuCamera.width, menuCamera.height - margin * 2);
menuCamera.minScrollY = 0;
controlGrid.onChange.add(function (selected)
controlGrid.onChange.add(function(selected)
{
camFollow.y = selected.y;
labels.forEach((label)->label.alpha = 0.6);
labels.forEach((label) -> label.alpha = 0.6);
labels.members[Std.int(controlGrid.selectedIndex / COLUMNS)].alpha = 1.0;
});
@ -179,13 +178,12 @@ class ControlsMenu extends ui.OptionsState.Page
var inputName = device == Keys ? "key" : "button";
var cancel = device == Keys ? "Escape" : "Back";
//todo: alignment
// todo: alignment
if (device == Keys)
prompt.setText('\nPress any key to rebind\n\n\n\n $cancel to cancel');
else
prompt.setText('\nPress any button\n to rebind\n\n\n $cancel to cancel');
controlGrid.selectedItem.select();
labels.members[Std.int(controlGrid.selectedIndex / COLUMNS)].alpha = 1.0;
controlGrid.enabled = true;
@ -313,7 +311,7 @@ class InputItem extends TextMenuItem
public var input:Int = -1;
public var index:Int = -1;
public function new (x = 0.0, y = 0.0, device, control, index, ?callback)
public function new(x = 0.0, y = 0.0, device, control, index, ?callback)
{
this.device = device;
this.control = control;

View file

@ -1,6 +1,8 @@
package ui;
import flixel.FlxCamera;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.util.FlxColor;
@ -14,10 +16,18 @@ class PreferencesMenu extends ui.OptionsState.Page
var items:TextMenuList;
var checkboxes:Array<CheckboxThingie> = [];
var menuCamera:FlxCamera;
var camFollow:FlxObject;
public function new()
{
super();
menuCamera = new FlxCamera();
FlxG.cameras.add(menuCamera, false);
menuCamera.bgColor = 0x0;
camera = menuCamera;
add(items = new TextMenuList());
createPrefItem('naughtyness', 'censor-naughty', false);
@ -25,6 +35,20 @@ class PreferencesMenu extends ui.OptionsState.Page
createPrefItem('flashing menu', 'flashing-menu', true);
createPrefItem('Camera Zooming on Beat', 'camera-zoom', true);
createPrefItem('FPS Counter', 'fps-counter', true);
camFollow = new FlxObject(FlxG.width / 2, 0, 140, 70);
if (items != null)
camFollow.y = items.selectedItem.y;
menuCamera.follow(camFollow, null, 0.06);
var margin = 160;
menuCamera.deadzone.set(0, margin, menuCamera.width, 40);
menuCamera.minScrollY = 0;
items.onChange.add(function(selected)
{
camFollow.y = selected.y;
});
}
public static function getPref(pref:String):Dynamic
@ -103,6 +127,8 @@ class PreferencesMenu extends ui.OptionsState.Page
{
super.update(elapsed);
menuCamera.followLerp = CoolUtil.camLerpShit(0.05);
items.forEach(function(daItem:TextMenuItem)
{
if (items.selectedItem == daItem)