mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-02-17 04:11:23 -05:00
still buggy
This commit is contained in:
parent
eb27c679c3
commit
95b03debb3
3 changed files with 77 additions and 5 deletions
|
@ -44,7 +44,7 @@ class RuntimeRainShader extends RuntimePostEffectShader
|
|||
}
|
||||
|
||||
// The intensity of the rain. Zero means no rain and one means the maximum amount of rain.
|
||||
public var intensity(default, set):Float = 1;
|
||||
public var intensity(default, set):Float = 0.5;
|
||||
|
||||
function set_intensity(value:Float):Float
|
||||
{
|
||||
|
@ -52,18 +52,17 @@ class RuntimeRainShader extends RuntimePostEffectShader
|
|||
return intensity = value;
|
||||
}
|
||||
|
||||
public var puddleMap(default, set):BitmapData;
|
||||
|
||||
public var groundMap(default, set):BitmapData;
|
||||
|
||||
function set_groundMap(value:BitmapData):BitmapData
|
||||
{
|
||||
trace('groundmap set');
|
||||
this.setBitmapData('uGroundMap', value);
|
||||
// this.setFloat2('uPuddleTextureSize', value.width, value.height);
|
||||
return groundMap = value;
|
||||
}
|
||||
|
||||
public var puddleMap(default, set):BitmapData;
|
||||
|
||||
function set_puddleMap(value:BitmapData):BitmapData
|
||||
{
|
||||
this.setBitmapData('uPuddleMap', value);
|
||||
|
@ -74,11 +73,18 @@ class RuntimeRainShader extends RuntimePostEffectShader
|
|||
|
||||
function set_lightMap(value:BitmapData):BitmapData
|
||||
{
|
||||
trace('lightmap set');
|
||||
this.setBitmapData('uLightMap', value);
|
||||
return lightMap = value;
|
||||
}
|
||||
|
||||
public var mask(default, set):BitmapData;
|
||||
|
||||
function set_mask(value:BitmapData):BitmapData
|
||||
{
|
||||
this.setBitmapData('uMask', value);
|
||||
return mask = value;
|
||||
}
|
||||
|
||||
public var numLights(default, set):Int = 0;
|
||||
|
||||
function set_numLights(value:Int):Int
|
||||
|
|
|
@ -25,10 +25,14 @@ import flixel.math.FlxRect;
|
|||
import flixel.text.FlxText;
|
||||
import flixel.tweens.FlxEase;
|
||||
import flixel.tweens.FlxTween;
|
||||
import flixel.system.frontEnds.CameraFrontEnd;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.ui.FlxBar;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.api.newgrounds.NGio;
|
||||
import flixel.util.FlxTimer;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.geom.Rectangle;
|
||||
import funkin.audio.VoicesGroup;
|
||||
import funkin.save.Save;
|
||||
import funkin.Highscore.Tallies;
|
||||
|
@ -972,6 +976,21 @@ class PlayState extends MusicBeatSubState
|
|||
processNotes(elapsed);
|
||||
}
|
||||
|
||||
@:access(flixel.FlxCamera)
|
||||
@:access(flixel.system.frontEnds.CameraFrontEnd)
|
||||
override function draw():Void
|
||||
{
|
||||
super.draw();
|
||||
|
||||
bufferCameraFrontEnd.lock();
|
||||
super.draw();
|
||||
camMask.render();
|
||||
bufferCameraFrontEnd.unlock();
|
||||
|
||||
maskTexture.fillRect(new Rectangle(0, 0, FlxG.width, FlxG.height), 0);
|
||||
maskTexture.draw(camMask.canvas); // TODO: this assumes tile render mode??
|
||||
}
|
||||
|
||||
public override function dispatchEvent(event:ScriptEvent):Void
|
||||
{
|
||||
// ORDER: Module, Stage, Character, Song, Conversation, Note
|
||||
|
@ -1245,6 +1264,9 @@ class PlayState extends MusicBeatSubState
|
|||
performCleanup();
|
||||
|
||||
super.destroy();
|
||||
|
||||
FlxG.signals.postUpdate.remove(syncBufferCameras);
|
||||
bufferCameraFrontEnd.remove(camMask);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1279,6 +1301,12 @@ class PlayState extends MusicBeatSubState
|
|||
camCutscene = new FlxCamera();
|
||||
camCutscene.bgColor.alpha = 0; // Show the game scene behind the camera.
|
||||
|
||||
// Init cameras and stuff for buffers.
|
||||
camMask = new FlxCamera();
|
||||
maskTexture = new BitmapData(FlxG.width, FlxG.height, true, FlxColor.TRANSPARENT);
|
||||
bufferCameraFrontEnd.reset(camMask);
|
||||
FlxG.signals.postUpdate.add(syncBufferCameras);
|
||||
|
||||
FlxG.cameras.reset(camGame);
|
||||
FlxG.cameras.add(camHUD, false);
|
||||
FlxG.cameras.add(camCutscene, false);
|
||||
|
@ -1342,6 +1370,24 @@ class PlayState extends MusicBeatSubState
|
|||
add(menuBG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncs cameras for buffers; basically just copies how the main camera is doing
|
||||
*/
|
||||
function syncBufferCameras():Void
|
||||
{
|
||||
final tr = @:privateAccess FlxG.log._standardTraceFunction;
|
||||
// tr("zoom: " + camGame.zoom);
|
||||
for (cam in bufferCameraFrontEnd.list)
|
||||
{
|
||||
cam.x = camGame.x;
|
||||
cam.y = camGame.y;
|
||||
cam.scroll.x = camGame.scroll.x;
|
||||
cam.scroll.y = camGame.scroll.y;
|
||||
cam.zoom = camGame.zoom;
|
||||
cam.update(FlxG.elapsed); // TODO: is this needed?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads stage data from cache, assembles the props,
|
||||
* and adds it to the state.
|
||||
|
@ -1366,6 +1412,14 @@ class PlayState extends MusicBeatSubState
|
|||
#if debug
|
||||
FlxG.console.registerObject('stage', currentStage);
|
||||
#end
|
||||
|
||||
// Add mask sprites to the mask camera.
|
||||
for (sprite in currentStage.maskSprites)
|
||||
{
|
||||
sprite.cameras.push(camMask);
|
||||
}
|
||||
// Set buffer textures.
|
||||
currentStage.maskTexture = maskTexture;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package funkin.play.stage;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.system.FlxAssets.FlxShader;
|
||||
import flixel.util.FlxSort;
|
||||
import openfl.display.BitmapData;
|
||||
import funkin.modding.IScriptedClass;
|
||||
import funkin.modding.events.ScriptEvent;
|
||||
import funkin.modding.events.ScriptEventType;
|
||||
|
@ -32,6 +34,16 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
|
|||
|
||||
public var camZoom:Float = 1.0;
|
||||
|
||||
/**
|
||||
* The list of sprites that should be rendered for mask texture.
|
||||
*/
|
||||
public var maskSprites:Array<FlxSprite> = [];
|
||||
|
||||
/**
|
||||
* The texture that has the mask information. Used for shader effects.
|
||||
*/
|
||||
public var maskTexture:BitmapData;
|
||||
|
||||
var namedProps:Map<String, StageProp> = new Map<String, StageProp>();
|
||||
var characters:Map<String, BaseCharacter> = new Map<String, BaseCharacter>();
|
||||
var boppers:Array<Bopper> = new Array<Bopper>();
|
||||
|
|
Loading…
Reference in a new issue