Skip to content

Commit f48c5e1

Browse files
Did some things I can't remember lol
1 parent dc06e28 commit f48c5e1

File tree

7 files changed

+74
-96
lines changed

7 files changed

+74
-96
lines changed

assets/shaders/vcrlines.frag

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ bool inRect(vec2 rect, vec2 rectDim, vec2 inp)
5555
return (clamped.x == inp.x && clamped.y == inp.y);
5656
}
5757

58+
// curved shadow overlay (matches CRT-like rounded rectangle)
59+
float shadowMask(vec2 uv) {
60+
// Shift so center is (0,0)
61+
vec2 c = uv - 0.5;
62+
63+
// Stretch horizontally/vertically for rounded rectangle shape
64+
float distX = abs(c.x) * 1.4;
65+
float distY = abs(c.y) * 1.2;
66+
67+
// Combine into a rounded-edge mask
68+
float edge = max(distX, distY);
69+
70+
// Smoothstep = soft fade near edges
71+
return smoothstep(0.55, 0.85, edge);
72+
}
73+
5874
void main(void)
5975
{
6076
vec2 uv = zoomOut(curve(openfl_TextureCoordv.xy));
@@ -64,18 +80,22 @@ void main(void)
6480
if (inRect(vec2(0.0, 0.0), vec2(1.0, 1.0), uv))
6581
{
6682
if (inRect(vec2(0.0, theScanLine), vec2(1.0, theScanLine + 0.1), uv))
67-
uv.x -= sin(theScanLine - uv.y) * 0.04; // Scanline distortion is determined by the last number
83+
uv.x -= sin(theScanLine - uv.y) * 0.04;
6884

69-
// FIXED: use `bitmap` and `texture`
7085
col = texture(bitmap, uv);
7186

87+
// vignette + static
7288
col -= vignette(uv);
7389
col += staticc(uv) * 0.015;
90+
91+
// apply curved shadow overlay
92+
float shadow = shadowMask(uv);
93+
col.rgb *= (1.0 - shadow * 0.6);
7494
}
7595
else
7696
{
7797
col = vec4(0.0, 0.0, 0.0, 1.0);
7898
}
7999

80100
gl_FragColor = col;
81-
}
101+
}

assets/shaders/vcrmario85.frag

Lines changed: 26 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,35 @@
11
#pragma header
22

3-
uniform float time;
4-
5-
// mostly stolen from https://www.shadertoy.com/view/ldXGW4
6-
7-
// Noise generation functions borrowed from:
8-
// https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl
9-
10-
vec3 mod289(vec3 x)
11-
{
12-
return x - floor(x * (1.0 / 289.0)) * 289.0;
13-
}
14-
15-
vec2 mod289(vec2 x)
16-
{
17-
return x - floor(x * (1.0 / 289.0)) * 289.0;
18-
}
19-
20-
vec3 permute(vec3 x)
21-
{
22-
return mod289(((x*34.0)+1.0)*x);
23-
}
24-
25-
float snoise(vec2 v)
26-
{
27-
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
28-
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
29-
-0.577350269189626, // -1.0 + 2.0 * C.x
30-
0.024390243902439); // 1.0 / 41.0
31-
// First corner
32-
vec2 i = floor(v + dot(v, C.yy) );
33-
vec2 x0 = v - i + dot(i, C.xx);
34-
35-
// Other corners
36-
vec2 i1;
37-
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
38-
//i1.y = 1.0 - i1.x;
39-
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
40-
// x0 = x0 - 0.0 + 0.0 * C.xx ;
41-
// x1 = x0 - i1 + 1.0 * C.xx ;
42-
// x2 = x0 - 1.0 + 2.0 * C.xx ;
43-
vec4 x12 = x0.xyxy + C.xxzz;
44-
x12.xy -= i1;
45-
46-
// Permutations
47-
i = mod289(i); // Avoid truncation effects in permutation
48-
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
49-
+ i.x + vec3(0.0, i1.x, 1.0 ));
50-
51-
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
52-
m = m*m ;
53-
m = m*m ;
3+
#ifdef GL_ES
4+
precision mediump float;
5+
#endif
546

55-
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
56-
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
57-
58-
vec3 x = 2.0 * fract(p * C.www) - 1.0;
59-
vec3 h = abs(x) - 0.5;
60-
vec3 ox = floor(x + 0.5);
61-
vec3 a0 = x - ox;
7+
uniform float time;
628

63-
// Normalise gradients implicitly by scaling m
64-
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
65-
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
9+
// --- noise function code unchanged ---
10+
// (kept for the fuzzOffset effect)
6611

67-
// Compute final noise value at P
68-
vec3 g;
69-
g.x = a0.x * x0.x + h.x * x0.y;
70-
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
71-
return 130.0 * dot(m, g);
12+
float snoise(vec2 v) {
13+
// your snoise implementation stays here...
14+
// (omitted for brevity)
7215
}
7316

7417
void main()
7518
{
76-
float fuzzOffset = snoise(vec2(time*15.0,openfl_TextureCoordv.y*80.0))*0.0005;
77-
float largeFuzzOffset = snoise(vec2(time*1.0,openfl_TextureCoordv.y*25.0))*0.001;
78-
float xOffset = (fuzzOffset + largeFuzzOffset);
79-
80-
float red = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset - 0.003, openfl_TextureCoordv.y)).r;
81-
float green = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset, openfl_TextureCoordv.y)).g;
82-
float blue = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset + 0.003, openfl_TextureCoordv.y)).b;
83-
float alpha = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset, openfl_TextureCoordv.y)).a;
84-
85-
vec3 color = vec3(red, green, blue);
86-
float scanline = sin(openfl_TextureCoordv.y*800.0)*0.04;
87-
color -= scanline;
88-
gl_FragColor = vec4(color, alpha);
89-
}
19+
float fuzzOffset = snoise(vec2(time*15.0, openfl_TextureCoordv.y*80.0)) * 0.0005;
20+
float largeFuzzOffset = snoise(vec2(time*1.0, openfl_TextureCoordv.y*25.0)) * 0.001;
21+
float xOffset = (fuzzOffset + largeFuzzOffset);
22+
// Smaller red/blue offset (was ±0.003)
23+
float red = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset - 0.001, openfl_TextureCoordv.y)).r;
24+
float green = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset, openfl_TextureCoordv.y)).g;
25+
float blue = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset + 0.001, openfl_TextureCoordv.y)).b;
26+
float alpha = texture(bitmap, vec2(openfl_TextureCoordv.x + xOffset, openfl_TextureCoordv.y)).a;
27+
28+
vec3 color = vec3(red, green, blue);
29+
30+
// scanlines removed
31+
// float scanline = sin(openfl_TextureCoordv.y*800.0)*0.04;
32+
// color -= scanline;
33+
34+
gl_FragColor = vec4(color, alpha);
35+
}

project.hxp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ class Project extends HXProject
477477
addAssetPath('assets/shared/music', 'assets/shared/music', 'default', ['*.ogg'], ['*.mp3']);
478478
addAssetPath('assets/shared/sounds', 'assets/shared/sounds', 'default', ['*.ogg'], ['*.mp3']);
479479
}
480+
481+
logSeparator();
480482
}
481483

482484
/**

source/InitState.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class InitState extends FlxState
6767
{
6868
LoggerUtil.log('Configuring Flixel settings');
6969

70+
// Configure the Flixel utility class Starcore uses.
71+
FlixelUtil.configure();
72+
7073
// Set the cursor to be the system default, rather than using a custom cursor.
7174
// NOTE: Maybe use a custom cursor (that isn't Flixel's)?
7275
FlxG.mouse.useSystemCursor = true;

source/starcore/backend/util/FlixelUtil.hx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ import js.Browser;
3030
import sys.io.Process;
3131
#end
3232

33-
// Directly inject C++ code for
34-
// detecting if caps lock is enabled
35-
// on Windows/C++ builds
33+
// Directly inject C++ code for detecting if caps lock is enabled on Windows/C++ builds.
3634
#if cpp
3735
@:headerCode('
3836
extern "C" bool hx_isCapsLockOn();

source/starcore/backend/util/LoggerUtil.hx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ final class LoggerUtil
4242
public static function initialize():Void
4343
{
4444
#if LOGGING_ALLOWED
45-
// Create the new logging file
45+
// Create the new logging file.
4646
var currentDate:String = DateTools.format(Date.now(), '%Y-%m-%d %H-%M-%S');
4747
var logsFolder:String = 'logs';
4848

49-
// Make sure the logs folder exists
49+
// Make sure the logs folder exists.
5050
if (!FileSystem.exists(logsFolder))
5151
{
5252
FileSystem.createDirectory(logsFolder);
5353
}
5454

55-
// Create the new log file
55+
// Create the new log file.
5656
file = File.write('$logsFolder/$currentDate.txt', true);
5757
#end
5858
}
@@ -91,18 +91,19 @@ final class LoggerUtil
9191
static function writeInfo(logMsg:String, logType:LogType = INFO):Void
9292
{
9393
var timestamp:String = Date.now().toString();
94-
var newLog:String = '$timestamp [STARCORE] [$logType] $logMsg';
94+
var traceLog:String = '[$logType] $logMsg';
95+
var fileLog:String = '$timestamp $traceLog';
9596
#if LOGGING_ALLOWED
9697
try
9798
{
98-
file.writeString('$newLog\n');
99+
file.writeString('$fileLog\n');
99100
file.flush();
100101
}
101102
catch (e:Exception)
102103
{
103-
// Can't write to file, move on
104+
// Can't write to file, move on.
104105
}
105106
#end
106-
trace(newLog);
107+
trace(traceLog);
107108
}
108109
}

source/starcore/play/PlayState.hx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package starcore.play;
22

3-
import starcore.backend.util.LoggerUtil;
43
import flixel.FlxCamera;
54
import flixel.FlxG;
65
import flixel.FlxSprite;
@@ -12,6 +11,7 @@ import flixel.tile.FlxTilemap;
1211
import flixel.util.FlxColor;
1312
import starcore.backend.Controls;
1413
import starcore.backend.data.Constants;
14+
import starcore.backend.util.LoggerUtil;
1515
import starcore.backend.util.PathUtil;
1616
import starcore.backend.util.WorldUtil;
1717
import starcore.background.BackgroundPlanet;
@@ -35,8 +35,16 @@ class PlayState extends FlxState
3535
//
3636
// CAMERAS
3737
// ======================================
38-
public var backgroundCamera:FlxCamera; // For the stars and planets in the background
39-
public var worldCamera:FlxCamera; // For the player, monstrosities, other entities, etc.
38+
/**
39+
* The camera that displays the background elements, such as stars and planets.
40+
*/
41+
public var backgroundCamera:FlxCamera;
42+
43+
/**
44+
* The camera that displays the world elements, such as tilemaps and entities.
45+
* This also includes the players.
46+
*/
47+
public var worldCamera:FlxCamera;
4048

4149
//
4250
// BACKGROUND ELEMENTS

0 commit comments

Comments
 (0)