generated from Joalor64GH/HaxeFlixel-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c348a72
commit 4e6dde3
Showing
17 changed files
with
260 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import('flixel.text.FlxText'); | ||
import('flixel.tweens.FlxTween'); | ||
import('flixel.tweens.FlxEase'); | ||
import('backend.Conductor'); | ||
import('states.PlayState'); | ||
|
||
var txt:FlxText; | ||
|
||
function create() { | ||
var txt:FlxText = new FlxText(0, 0, 0, "Hit the notes to the beat of the song!", 48).screenCenter(); | ||
PlayState.instance.add(txt); | ||
txt = new FlxText(0, 0, 0, "Hit the notes to the beat of the song!", 48).screenCenter(); | ||
PlayState.instance.add(txt); | ||
} | ||
|
||
function beatHit(curBeat:Int) { | ||
if (curBeat >= 0) { | ||
FlxTween.tween(txt, {alpha: 0}, Conductor.crochet / 1000, {ease: FlxEase.quadOut}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
package shaders; | ||
|
||
import flixel.graphics.tile.FlxGraphicsShader; | ||
|
||
class HueDisplacer { | ||
public var shader(default, null):HueDisplacerShader = new HueDisplacerShader(); | ||
public var hasOutline:Bool = false; | ||
public var hueShit:Float = 0; | ||
|
||
public function new():Void { | ||
shader.uTime.value = [0]; | ||
shader.money.value = [0]; | ||
shader.awesomeOutline.value = [hasOutline]; | ||
} | ||
|
||
public function update(elapsed:Float):Void { | ||
shader.uTime.value[0] += elapsed; | ||
hueShit += elapsed; | ||
} | ||
} | ||
|
||
class HueDisplacerShader extends FlxGraphicsShader { | ||
@:glFragmentSource(' | ||
varying float openfl_Alphav; | ||
varying vec4 openfl_ColorMultiplierv; | ||
varying vec4 openfl_ColorOffsetv; | ||
varying vec2 openfl_TextureCoordv; | ||
|
||
uniform bool openfl_HasColorTransform; | ||
uniform vec2 openfl_TextureSize; | ||
uniform sampler2D bitmap; | ||
|
||
uniform bool hasTransform; | ||
uniform bool hasColorTransform; | ||
|
||
vec4 flixel_texture2D(sampler2D bitmap, vec2 coord) | ||
{ | ||
vec4 color = texture2D(bitmap, coord); | ||
if (!hasTransform) | ||
{ | ||
return color; | ||
} | ||
|
||
if (color.a == 0.0) | ||
{ | ||
return vec4(0.0, 0.0, 0.0, 0.0); | ||
} | ||
|
||
if (!hasColorTransform) | ||
{ | ||
return color * openfl_Alphav; | ||
} | ||
|
||
color = vec4(color.rgb / color.a, color.a); | ||
|
||
mat4 colorMultiplier = mat4(0); | ||
colorMultiplier[0][0] = openfl_ColorMultiplierv.x; | ||
colorMultiplier[1][1] = openfl_ColorMultiplierv.y; | ||
colorMultiplier[2][2] = openfl_ColorMultiplierv.z; | ||
colorMultiplier[3][3] = openfl_ColorMultiplierv.w; | ||
|
||
color = clamp(openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0); | ||
|
||
if (color.a > 0.0) | ||
{ | ||
return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); | ||
} | ||
return vec4(0.0, 0.0, 0.0, 0.0); | ||
} | ||
|
||
uniform float uTime; | ||
uniform float money; | ||
uniform bool awesomeOutline; | ||
|
||
const float offset = 1.0 / 128.0; | ||
vec3 normalizeColor(vec3 color) | ||
{ | ||
return vec3( | ||
color[0] / 255.0, | ||
color[1] / 255.0, | ||
color[2] / 255.0 | ||
); | ||
} | ||
|
||
vec3 rgb2hsv(vec3 c) | ||
{ | ||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); | ||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); | ||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); | ||
|
||
float d = q.x - min(q.w, q.y); | ||
float e = 1.0e - 10; | ||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); | ||
} | ||
|
||
vec3 hsv2rgb(vec3 c) | ||
{ | ||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | ||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); | ||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); | ||
} | ||
|
||
void main() | ||
{ | ||
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv); | ||
vec4 swagColor = vec4(rgb2hsv(vec3(color[0], color[1], color[2])), color[3]); | ||
swagColor[0] += uTime; | ||
color = vec4(hsv2rgb(vec3(swagColor[0], swagColor[1], swagColor[2])), swagColor[3]); | ||
|
||
if (awesomeOutline) | ||
{ | ||
vec2 size = vec2(3, 3); | ||
|
||
if (color.a <= 0.5) { | ||
float w = size.x / openfl_TextureSize.x; | ||
float h = size.y / openfl_TextureSize.y; | ||
if (flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x + w, openfl_TextureCoordv.y)).a != 0. | ||
|| flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x - w, openfl_TextureCoordv.y)).a != 0. | ||
|| flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x, openfl_TextureCoordv.y + h)).a != 0. | ||
|| flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x, openfl_TextureCoordv.y - h)).a != 0.) | ||
color = vec4(1.0, 1.0, 1.0, 1.0); | ||
} | ||
} | ||
gl_FragColor = color; | ||
}') | ||
@:glVertexSource(' | ||
attribute float openfl_Alpha; | ||
attribute vec4 openfl_ColorMultiplier; | ||
attribute vec4 openfl_ColorOffset; | ||
attribute vec4 openfl_Position; | ||
attribute vec2 openfl_TextureCoord; | ||
|
||
varying float openfl_Alphav; | ||
varying vec4 openfl_ColorMultiplierv; | ||
varying vec4 openfl_ColorOffsetv; | ||
varying vec2 openfl_TextureCoordv; | ||
|
||
uniform mat4 openfl_Matrix; | ||
uniform bool openfl_HasColorTransform; | ||
uniform vec2 openfl_TextureSize; | ||
|
||
attribute float alpha; | ||
attribute vec4 colorMultiplier; | ||
attribute vec4 colorOffset; | ||
uniform bool hasColorTransform; | ||
void main(void) | ||
{ | ||
openfl_Alphav = openfl_Alpha; | ||
openfl_TextureCoordv = openfl_TextureCoord; | ||
|
||
if (openfl_HasColorTransform) { | ||
openfl_ColorMultiplierv = openfl_ColorMultiplier; | ||
openfl_ColorOffsetv = openfl_ColorOffset / 255.0; | ||
} | ||
|
||
gl_Position = openfl_Matrix * openfl_Position; | ||
openfl_Alphav = openfl_Alpha * alpha; | ||
if (hasColorTransform) | ||
{ | ||
openfl_ColorOffsetv = colorOffset / 255.0; | ||
openfl_ColorMultiplierv = colorMultiplier; | ||
} | ||
}') | ||
public function new() { | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.