week 6 pause!!
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
import flixel.FlxCamera.FlxCameraFollowStyle;
|
||||
|
||||
public var pixelNotesForBF = true;
|
||||
public var pixelNotesForDad = true;
|
||||
public var enablePixelUI = true;
|
||||
public var enableCameraHacks = true;
|
||||
public var enablePauseMenu = true;
|
||||
|
||||
var daPixelZoom = 6;
|
||||
|
||||
/**
|
||||
* UI
|
||||
*/
|
||||
function onNoteCreation(event) {
|
||||
if (event.note.mustPress && !pixelNotesForBF) return;
|
||||
if (!event.note.mustPress && !pixelNotesForDad) return;
|
||||
@@ -51,4 +58,79 @@ function onCountdown(event) {
|
||||
case 2: 'stages/school/ui/set';
|
||||
case 3: 'stages/school/ui/go';
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* CAMERA HACKS!!
|
||||
*/
|
||||
function createPost() {
|
||||
if (enablePauseMenu) {
|
||||
PauseSubState.script = 'data/scripts/week6-pause';
|
||||
}
|
||||
if (enableCameraHacks) {
|
||||
FlxG.camera.antialiasing = false;
|
||||
FlxG.camera.pixelPerfectRender = true;
|
||||
FlxG.game.stage.quality = 2;
|
||||
|
||||
var newNoteCamera = new FlxCamera();
|
||||
newNoteCamera.bgColor = 0; // transparent
|
||||
FlxG.cameras.add(newNoteCamera, false);
|
||||
|
||||
var pixelSwagWidth = Note.swagWidth + (6 - (Note.swagWidth % 6));
|
||||
// TODO: multikey support??
|
||||
for(s in 0...4) {
|
||||
var i = 0;
|
||||
for(str in [cpuStrums.members[s], playerStrums.members[s]]) {
|
||||
// TODO: middlescroll???
|
||||
str.x = (FlxG.width * (0.25 + (0.5 * i))) + (pixelSwagWidth * (s - 2));
|
||||
str.x -= str.x % 6;
|
||||
str.cameras = [newNoteCamera];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
iconP1.antialiasing = false;
|
||||
iconP2.antialiasing = false;
|
||||
|
||||
makeCameraPixely(camGame);
|
||||
makeCameraPixely(newNoteCamera);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to make any camera pixelly (you wont be able to zoom with it anymore!)
|
||||
*/
|
||||
public function makeCameraPixely(cam) {
|
||||
cam.pixelPerfectRender = true;
|
||||
cam.zoom /= Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y) * 6;
|
||||
defaultCamZoom /= 6;
|
||||
|
||||
var shad = new CustomShader('pixelZoomShader');
|
||||
cam.addShader(shad);
|
||||
|
||||
pixellyCameras.push(cam);
|
||||
pixellyShaders.push(shad);
|
||||
}
|
||||
|
||||
function pixelCam(cam) {
|
||||
makeCameraPixely(cam);
|
||||
}
|
||||
|
||||
var pixellyCameras = [];
|
||||
var pixellyShaders = [];
|
||||
|
||||
function updatePost(elapsed) {
|
||||
for(e in pixellyCameras) {
|
||||
if (!e.exists) continue;
|
||||
e.zoom = 1 / 6 / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y);
|
||||
}
|
||||
for(e in pixellyShaders) {
|
||||
e.pixelZoom = 1 / 6 / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y);
|
||||
}
|
||||
|
||||
if (enableCameraHacks) {
|
||||
notes.forEach(function(n) {
|
||||
n.y -= n.y % 6;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import funkin.ui.FunkinText;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.text.FlxTextBorderStyle;
|
||||
import flixel.util.FlxAxes;
|
||||
|
||||
var pixelScript:Script;
|
||||
var pauseCam = new FlxCamera();
|
||||
|
||||
var bg:FlxSprite;
|
||||
var hand:FlxSprite;
|
||||
|
||||
var texts:Array<FlxText> = [];
|
||||
|
||||
function create(event) {
|
||||
// cancel default pause menu!!
|
||||
event.cancel();
|
||||
event.music = "pixel/Lunchbox";
|
||||
|
||||
cameras = [];
|
||||
|
||||
pixelScript = game.scripts.getByName("pixel.hx");
|
||||
pixelScript.call("pixelCam", [pauseCam]);
|
||||
|
||||
FlxG.cameras.add(pauseCam, false);
|
||||
|
||||
pauseCam.bgColor = 0x88FF99CC;
|
||||
pauseCam.alpha = 0;
|
||||
|
||||
bg = new FlxSprite(44 * 6, 14 * 6).loadGraphic(Paths.image('stages/school/pause/bg'));
|
||||
bg.scale.set(6, 6);
|
||||
bg.updateHitbox();
|
||||
bg.scale.y = 5;
|
||||
bg.cameras = [pauseCam];
|
||||
add(bg);
|
||||
|
||||
text = new FlxText(0, 22 * 6, 0, "Pause", 8, false);
|
||||
confText(text);
|
||||
add(text);
|
||||
|
||||
var i = 2;
|
||||
for(e in menuItems) {
|
||||
text = new FlxText(0, (22 * 6) + (i * 9 * 6), 0, e, 8, false);
|
||||
confText(text);
|
||||
add(text);
|
||||
texts.push(text);
|
||||
i++;
|
||||
}
|
||||
|
||||
hand = new FlxSprite().loadGraphic(Paths.image('stages/school/ui/hand_textbox'));
|
||||
hand.scale.set(6, 6);
|
||||
hand.updateHitbox();
|
||||
add(hand);
|
||||
|
||||
FlxTween.tween(bg, {"scale.y": 6}, 0.75, {ease: FlxEase.elasticOut});
|
||||
|
||||
cameras = [pauseCam];
|
||||
|
||||
FlxG.sound.play(Paths.sound('pixel/clickText'));
|
||||
}
|
||||
|
||||
function confText(text) {
|
||||
text.scale.set(6, 6);
|
||||
text.updateHitbox();
|
||||
text.screenCenter(FlxAxes.X);
|
||||
text.borderStyle = FlxTextBorderStyle.OUTLINE;
|
||||
text.borderColor = 0xFF953E3E;
|
||||
}
|
||||
|
||||
function createPost() {
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
FlxG.cameras.remove(pauseCam);
|
||||
}
|
||||
|
||||
function update(elapsed) {
|
||||
pixelScript.call("updatePost", [elapsed]);
|
||||
|
||||
pauseCam.alpha = lerp(pauseCam.alpha, 1, 0.25);
|
||||
|
||||
var oldSec = curSelected;
|
||||
if (controls.DOWN_P)
|
||||
changeSelection(1, false);
|
||||
if (controls.UP_P)
|
||||
changeSelection(-1);
|
||||
|
||||
if (oldSec != curSelected) {
|
||||
FlxG.sound.play(Paths.sound('pixel/pixelText'));
|
||||
}
|
||||
|
||||
var curText = texts[curSelected];
|
||||
hand.setPosition(curText.x - hand.width - 12, curText.y + (text.height - hand.height) - 6);
|
||||
hand.x -= hand.x % 6;
|
||||
hand.y -= hand.y % 6;
|
||||
|
||||
if (controls.ACCEPT) {
|
||||
FlxG.sound.play(Paths.sound('pixel/clickText'));
|
||||
selectOption();
|
||||
}
|
||||
}
|
||||
|
||||
function changeSelection(change) {
|
||||
curSelected += change;
|
||||
|
||||
if (curSelected < 0)
|
||||
curSelected = menuItems.length - 1;
|
||||
if (curSelected >= menuItems.length)
|
||||
curSelected = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user