Skip to content

Commit 4c99117

Browse files
IM HIM
- renamed some conditional flags to be more specific and (as always) more consistent - reformatted some files - added a data util class for manipulating, well, DATA, in specifically variables - added way more mechanics for the text box class (you can now type in it!) - added a (currently very broken) cursor for the text box class - the web version of the game now also has *a* filter rather than looking bland all the time - some other bullshit i cant remember at the top of my head right now because its 5:30 in the morning
1 parent e723316 commit 4c99117

File tree

19 files changed

+416
-105
lines changed

19 files changed

+416
-105
lines changed

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
},
1313
"haxe.enableExtendedIndentation": true,
1414
"cSpell.words": [
15-
"GRAVEACCENT",
15+
"openeditors",
1616
"Haxe",
1717
"IBEAM",
18+
"GRAVEACCENT",
1819
"NUMPADEIGHT",
1920
"NUMPADFIVE",
2021
"NUMPADFOUR",
@@ -29,7 +30,6 @@
2930
"NUMPADTHREE",
3031
"NUMPADTWO",
3132
"NUMPADZERO",
32-
"NUMPADSLASH",
33-
"openeditors"
33+
"NUMPADSLASH"
3434
]
3535
}

assets/shaders/grayscale.frag

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ uniform float _amount;
66
// Converts the input image to grayscale, with `_amount` representing the proportion of the conversion.
77

88
// See https://drafts.fxtf.org/filter-effects/#grayscaleEquivalent
9-
vec4 to_grayscale(vec4 input_rgba) {
9+
vec4 to_grayscale(vec4 input_rgba)
10+
{
1011
float red = (0.2126 + 0.7874 * (1.0 - _amount)) * input_rgba.r + (0.7152 - 0.7152 * (1.0 - _amount)) * input_rgba.g + (0.0722 - 0.0722 * (1.0 - _amount)) * input_rgba.b;
1112
float green = (0.2126 - 0.2126 * (1.0 - _amount)) * input_rgba.r + (0.7152 + 0.2848 * (1.0 - _amount)) * input_rgba.g + (0.0722 - 0.0722 * (1.0 - _amount)) * input_rgba.b;
1213
float blue = (0.2126 - 0.2126 * (1.0 - _amount)) * input_rgba.r + (0.7152 - 0.7152 * (1.0 - _amount)) * input_rgba.g + (0.0722 + 0.9278 * (1.0 - _amount)) * input_rgba.b;
1314

1415
return vec4(red, green, blue, input_rgba.a);
1516
}
1617

17-
void main() {
18+
void main()
19+
{
1820
// Get the texture to apply to.
1921
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
2022

assets/shaders/hueshift.frag

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma header
22
uniform float hue;
33

4-
vec3 rgb2hsv(vec3 c) {
4+
vec3 rgb2hsv(vec3 c)
5+
{
56
vec4 K = vec4(0., -1./3., 2./3., -1.);
67
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
78
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
@@ -11,12 +12,14 @@ vec3 rgb2hsv(vec3 c) {
1112
return vec3(abs(q.z + (q.w - q.y) / (6. * d + e)), d / (q.x + e), q.x);
1213
}
1314

14-
vec3 hsv2rgb(vec3 c) {
15+
vec3 hsv2rgb(vec3 c)
16+
{
1517
vec3 rgb = clamp(abs(mod(c.x * 6. + vec3(0., 4., 2.), 6.) - 3.) - 1., 0., 1.);
1618
return c.z * mix(vec3(1.), rgb, c.y);
1719
}
1820

19-
void main() {
21+
void main()
22+
{
2023
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
2124
vec3 hsv = rgb2hsv(color.rgb);
2225
hsv.x = mod(hsv.x + hue, 1.0);

assets/shaders/scanline.frag

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ const float scale = 1.0;
44
void main()
55
{
66
if (mod(floor(openfl_TextureCoordv.y * openfl_TextureSize.y / scale), 2.0) == 0.0)
7+
{
78
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
9+
}
810
else
11+
{
912
gl_FragColor = texture2D(bitmap, openfl_TextureCoordv);
13+
}
1014
}

assets/shaders/vcrborder.frag

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma header
22

3-
vec2 curve(vec2 uv) {
3+
vec2 curve(vec2 uv)
4+
{
45
uv = (uv - 0.5) * 2.0;
56
uv *= 1.1;
67
uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0); // Increased horizontal distortion

assets/shaders/vcrmario85.frag

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ uniform float time;
77
// Noise generation functions borrowed from:
88
// https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl
99

10-
vec3 mod289(vec3 x) {
10+
vec3 mod289(vec3 x)
11+
{
1112
return x - floor(x * (1.0 / 289.0)) * 289.0;
1213
}
1314

14-
vec2 mod289(vec2 x) {
15+
vec2 mod289(vec2 x)
16+
{
1517
return x - floor(x * (1.0 / 289.0)) * 289.0;
1618
}
1719

18-
vec3 permute(vec3 x) {
20+
vec3 permute(vec3 x)
21+
{
1922
return mod289(((x*34.0)+1.0)*x);
2023
}
2124

@@ -68,7 +71,8 @@ float snoise(vec2 v)
6871
return 130.0 * dot(m, g);
6972
}
7073

71-
void main() {
74+
void main()
75+
{
7276
float fuzzOffset = snoise(vec2(time*15.0,openfl_TextureCoordv.y*80.0))*0.0005;
7377
float largeFuzzOffset = snoise(vec2(time*1.0,openfl_TextureCoordv.y*25.0))*0.001;
7478
float xOffset = (fuzzOffset + largeFuzzOffset);

project.hxp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,26 @@ class Project extends HXProject
9292

9393
//
9494
// FEATURE FLAGS
95-
// Inverse feature flags are automatically populated.
96-
//
95+
// (Inverse feature flags are automatically populated)
96+
// ===========================================================================
9797

9898
/**
9999
* Allows the game to be displayed in the user's Discord "Activity" box
100100
* (it can still be disabled by the user in-game if the option is off).
101101
*/
102-
static final DISCORD_ALLOWED:FeatureFlag = 'DISCORD_ALLOWED';
102+
static final DISCORD_RPC_ALLOWED:FeatureFlag = 'DISCORD_RPC_ALLOWED';
103103

104104
/**
105-
* Enables the game to use filters, giving it a more unsettling and unnerving vibe.
105+
* Enables the game to use advanced shaders, giving it a more unsettling and unnerving vibe.
106106
* Sort of like the analog horror videos you see on YouTube.
107107
*/
108-
static final SHADERS_ALLOWED:FeatureFlag = 'SHADERS_ALLOWED';
108+
static final ADVANCED_SHADERS_ALLOWED:FeatureFlag = 'ADVANCED_SHADERS_ALLOWED';
109109

110110
/**
111111
* Allows the developer(s) to use built-in editors,
112112
* such as creating animations for entities.
113113
*/
114-
static final EDITORS_ALLOWED:FeatureFlag = 'EDITORS_ALLOWED';
114+
static final DEBUG_EDITORS_ALLOWED:FeatureFlag = 'DEBUG_EDITORS_ALLOWED';
115115

116116
/**
117117
* Permits the game to use a built-in logging system, which writes all
@@ -134,9 +134,9 @@ class Project extends HXProject
134134
configureApp();
135135

136136
displayTarget();
137+
configureOutputDir();
137138
configureFeatureFlags();
138139
configureCompileDefines();
139-
configureOutputDir();
140140
configureHaxelibs();
141141
configureAssets();
142142
configureIcons(); // TODO: Implement code when icons are made!
@@ -155,6 +155,7 @@ class Project extends HXProject
155155
info('Git Commit: ' + getGitCommit());
156156
info('Git Modified? ' + getGitModified());
157157
info('Display? ' + isDisplay());
158+
info('-------------------------------------------------------------');
158159
}
159160

160161
/**
@@ -356,15 +357,15 @@ class Project extends HXProject
356357
{
357358
// Enable Discord rich presence
358359
// (works only for Windows)
359-
DISCORD_ALLOWED.apply(this, isWindows());
360+
DISCORD_RPC_ALLOWED.apply(this, isWindows());
360361

361362
// Enable dope ass screen filters
362363
// (if the platform is on desktop)
363-
SHADERS_ALLOWED.apply(this, isDesktop());
364+
ADVANCED_SHADERS_ALLOWED.apply(this, isDesktop());
364365

365366
// Enable the editors if the game is in debug mode,
366367
// otherwise, disable them of course
367-
EDITORS_ALLOWED.apply(this, isDesktop() && isDebug());
368+
DEBUG_EDITORS_ALLOWED.apply(this, isDesktop() && isDebug());
368369

369370
// Enables dope ass logging
370371
// (only works on desktop)
@@ -373,6 +374,8 @@ class Project extends HXProject
373374
// Allows the game to programmatically change sounds
374375
// (only works on desktop)
375376
SOUND_FILTERS_ALLOWED.apply(this, isDesktop());
377+
378+
info('-------------------------------------------------------------');
376379
}
377380

378381
/**
@@ -417,6 +420,7 @@ class Project extends HXProject
417420
buildDir += '/';
418421
info('Output Directory: $buildDir');
419422
app.path = buildDir;
423+
info('-------------------------------------------------------------');
420424
}
421425

422426
function configureHaxelibs()
@@ -450,7 +454,7 @@ class Project extends HXProject
450454
}
451455

452456
// Discord rich presence
453-
if (DISCORD_ALLOWED.isEnabled(this))
457+
if (DISCORD_RPC_ALLOWED.isEnabled(this))
454458
{
455459
addHaxelib('hxdiscord_rpc');
456460
}
@@ -475,10 +479,7 @@ class Project extends HXProject
475479
addAssetPath('assets/shared/images', 'assets/shared/images', 'default', ['*.png'], []);
476480

477481
// Add shader frag assets
478-
if (isDesktop())
479-
{
480-
addAssetPath('assets/shaders', 'assets/shaders', 'default', ['*.frag'], []);
481-
}
482+
addAssetPath('assets/shaders', 'assets/shaders', 'default', ['*.frag'], []);
482483

483484
// Add shared music and sound assets for web (.mp3)
484485
if (isWeb())

source/InitState.hx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package;
22

3+
import starcore.backend.util.SaveUtil;
4+
import openfl.events.KeyboardEvent;
35
import flixel.FlxG;
46
import flixel.FlxState;
57
import flixel.math.FlxMath;
@@ -15,10 +17,8 @@ import starcore.backend.util.FlixelUtil;
1517
import starcore.backend.util.LoggerUtil;
1618
import starcore.backend.util.PathUtil;
1719
import starcore.menus.MainMenuState;
18-
#if DISCORD_ALLOWED
1920
import starcore.backend.api.DiscordClient;
20-
#end
21-
#if SHADERS_ALLOWED
21+
#if ADVANCED_SHADERS_ALLOWED
2222
import starcore.shaders.*;
2323
#end
2424
#if web
@@ -57,9 +57,7 @@ class InitState extends FlxState
5757
registerEntities();
5858

5959
// Start up Discord rich presence
60-
#if DISCORD_ALLOWED
6160
DiscordClient.initialize();
62-
#end
6361

6462
// Switch to the main menu state after everything has loaded
6563
FlxG.switchState(() -> new MainMenuState());
@@ -101,7 +99,7 @@ class InitState extends FlxState
10199
#end
102100

103101
// Assign the shaders AFTER all assets have been loaded!
104-
#if SHADERS_ALLOWED
102+
#if ADVANCED_SHADERS_ALLOWED
105103
CacheUtil.vcrBorderFilter = new VCRBorderShader();
106104
CacheUtil.vcrMario85Filter = new VCRMario85Shader();
107105
#end
@@ -113,7 +111,7 @@ class InitState extends FlxState
113111
LoggerUtil.log('Adding background processes');
114112
// Update the shaders that need to
115113
// constantly be reset
116-
#if SHADERS_ALLOWED
114+
#if ADVANCED_SHADERS_ALLOWED
117115
FlxG.signals.postUpdate.add(() ->
118116
{
119117
CacheUtil.vcrMario85Filter.update(FlxG.elapsed);
@@ -163,6 +161,16 @@ class InitState extends FlxState
163161
});
164162
#end
165163

164+
#if (web && debug)
165+
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, (_) ->
166+
{
167+
if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.BACKSPACE)
168+
{
169+
SaveUtil.deleteAll();
170+
}
171+
});
172+
#end
173+
166174
// Do shit like saving the user's data when the game closes
167175
Application.current.window.onClose.add(() ->
168176
{

source/starcore/backend/api/DiscordClient.hx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package starcore.backend.api;
22

33
import starcore.backend.data.Constants;
4-
#if DISCORD_ALLOWED
54
import starcore.backend.util.LoggerUtil;
65
import starcore.backend.data.ClientPrefs;
6+
#if DISCORD_RPC_ALLOWED
77
import cpp.RawConstPointer;
88
import hxdiscord_rpc.Discord;
99
import hxdiscord_rpc.Types.DiscordRichPresence;
10-
import lime.app.Application;
1110
import sys.thread.Thread;
11+
#end
12+
import lime.app.Application;
1213

1314
/**
14-
* Class that handles Discord rich presence for the client's
15-
* "Activity" box.
15+
* Class that handles Discord rich presence for the client's "Activity" box.
1616
*/
1717
final class DiscordClient
1818
{
@@ -25,6 +25,7 @@ final class DiscordClient
2525
*/
2626
public static function initialize():Void
2727
{
28+
#if DISCORD_RPC_ALLOWED
2829
if (ClientPrefs.getOption('discordRPC'))
2930
{
3031
// Log info
@@ -55,15 +56,17 @@ final class DiscordClient
5556
{
5657
shutdown();
5758
});
59+
#end
5860
}
5961

6062
/**
6163
* Shutdowns Discord rich presence.
6264
*/
6365
public static function shutdown():Void
6466
{
67+
#if DISCORD_RPC_ALLOWED
6568
LoggerUtil.log('Shutting down Discord rich presence');
6669
Discord.Shutdown();
70+
#end
6771
}
6872
}
69-
#end

source/starcore/backend/data/ClientPrefs.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import haxe.Exception;
1515
enum ShaderModeType
1616
{
1717
DEFAULT; // All shaders applied
18-
FAST; // Only the VCRMario85 shader enabled
18+
FAST; // Only the VCRMario85 and Scanline shaders enabled
1919
MINIMAL; // Only scanline shader enabled
2020
NONE; // No shaders at all
2121
}

0 commit comments

Comments
 (0)