Skip to content

Commit bd79dd2

Browse files
ItsLJcoolTechnikTilNexIsDumb
authored
Week6 pixel fix + more syntax cleanup (#662)
* Fixed some issues with antialiasing not being set like wtf man why isn't it set do false in da code * oops i forgor i was testing smth lol * forcing the note sprites to be non aliased * fine lmao Co-authored-by: Til <[email protected]> * my take * yes i will shut the fuck up now --------- Co-authored-by: Til <[email protected]> Co-authored-by: ⍚~Nex <[email protected]>
1 parent 6d18935 commit bd79dd2

File tree

4 files changed

+66
-93
lines changed

4 files changed

+66
-93
lines changed

assets/data/scripts/pixel.hx

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ static var daPixelZoom = 6;
1818
* UI
1919
*/
2020
function onNoteCreation(event) {
21-
if (event.note.strumLine == playerStrums && !pixelNotesForBF) return;
22-
if (event.note.strumLine == cpuStrums && !pixelNotesForDad) return;
23-
21+
if ((event.note.strumLine == playerStrums && !pixelNotesForBF) || (event.note.strumLine == cpuStrums && !pixelNotesForDad)) return;
2422
event.cancel();
2523

2624
var note = event.note;
@@ -34,18 +32,14 @@ function onNoteCreation(event) {
3432
}
3533
note.scale.set(daPixelZoom, daPixelZoom);
3634
note.updateHitbox();
35+
note.antialiasing = false;
3736
}
3837

39-
function onPostNoteCreation(event) {
40-
var splashes = event.note;
41-
if (pixelSplashes)
42-
splashes.splash = "pixel-default";
43-
}
38+
function onPostNoteCreation(event) if (pixelSplashes)
39+
event.note.splash = "pixel-default";
4440

4541
function onStrumCreation(event) {
46-
if (event.player == 1 && !pixelNotesForBF) return;
47-
if (event.player == 0 && !pixelNotesForDad) return;
48-
42+
if ((event.player == 1 && !pixelNotesForBF) || (event.player == 0 && !pixelNotesForDad)) return;
4943
event.cancel();
5044

5145
var strum = event.strum;
@@ -56,6 +50,7 @@ function onStrumCreation(event) {
5650

5751
strum.scale.set(daPixelZoom, daPixelZoom);
5852
strum.updateHitbox();
53+
strum.antialiasing = false;
5954
}
6055

6156
function onCountdown(event) {
@@ -86,9 +81,9 @@ function onPlayerHit(event:NoteHitEvent) {
8681
* CAMERA HACKS!!
8782
*/
8883
function postCreate() {
89-
if (enablePauseMenu) {
84+
if (enablePauseMenu)
9085
PauseSubState.script = 'data/scripts/week6-pause';
91-
}
86+
9287
if (enableCameraHacks) {
9388
camGame.pixelPerfectRender = true;
9489
camGame.antialiasing = false;
@@ -104,8 +99,8 @@ function postCreate() {
10499
}
105100
}
106101

107-
function onStartCountdown() {
108-
/*var newNoteCamera = new HudCamera();
102+
/*function onStartCountdown() {
103+
var newNoteCamera = new HudCamera();
109104
newNoteCamera.bgColor = 0; // transparent
110105
FlxG.cameras.add(newNoteCamera, false);
111106
@@ -119,8 +114,8 @@ function onStartCountdown() {
119114
i++;
120115
}
121116
}
122-
makeCameraPixely(newNoteCamera);*/
123-
}
117+
makeCameraPixely(newNoteCamera);
118+
}*/
124119

125120
/**
126121
* Use this to make any camera pixelly (you wont be able to zoom with it anymore!)
@@ -145,33 +140,29 @@ function destroy() {
145140
FlxG.game.stage.quality = oldStageQuality;
146141
}
147142

148-
function pixelCam(cam) {
143+
function pixelCam(cam)
149144
makeCameraPixely(cam);
150-
}
151145

152146
var pixellyCameras = [];
153147
var pixellyShaders = [];
154148

155-
function postUpdate(elapsed) {
156-
for(e in pixellyCameras) {
157-
if (Std.isOfType(e, HudCamera))
158-
e.downscroll = camHUD.downscroll;
159-
}
160-
if (enableCameraHacks) {
161-
for(p in strumLines)
162-
p.notes.forEach(function(n) {
163-
if(n.isSustainNote) return; // hacky fix for hold
164-
n.y -= n.y % daPixelZoom;
165-
n.x -= n.x % daPixelZoom;
166-
});
149+
function postUpdate() {
150+
for (e in pixellyCameras) if (Std.isOfType(e, HudCamera))
151+
e.downscroll = camHUD.downscroll;
152+
153+
if (enableCameraHacks) for (p in strumLines) {
154+
p.notes.forEach(function(n) {
155+
if(n.isSustainNote) return; // hacky fix for hold
156+
n.y -= n.y % daPixelZoom;
157+
n.x -= n.x % daPixelZoom;
158+
});
167159
}
168160

169161
var zoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y);
170-
for(e in pixellyCameras) {
162+
for (e in pixellyCameras) {
171163
if (!e.exists) continue;
172164
e.zoom = zoom;
173165
}
174-
for(e in pixellyShaders) {
166+
for (e in pixellyShaders)
175167
e.pixelZoom = zoom;
176-
}
177-
}
168+
}

assets/data/scripts/week6-pause.hx

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import flixel.text.FlxText;
33
import flixel.text.FlxTextBorderStyle;
44
import flixel.util.FlxAxes;
55

6-
var pixelScript:Script;
6+
var pixelScript:Script = game.scripts.getByName("pixel.hx");
77
var pauseCam = new FlxCamera();
88

99
var bg:FlxSprite;
@@ -19,47 +19,40 @@ function create(event) {
1919

2020
event.music = isThorns ? "pixel/LunchboxScary" : "pixel/Lunchbox";
2121

22-
cameras = [];
23-
24-
pixelScript = game.scripts.getByName("pixel.hx");
25-
pixelScript.call("pixelCam", [pauseCam]);
22+
// allowing this pause script even if the pixel script is not loaded - Nex
23+
pixelScript?.call("pixelCam", [pauseCam]);
2624

2725
FlxG.cameras.add(pauseCam, false);
26+
cameras = [pauseCam];
2827

2928
pauseCam.bgColor = isThorns ? 0x88000000 : 0x88FF99CC;
3029
pauseCam.alpha = 0;
3130

32-
bg = new FlxSprite(44 * 6, 14 * 6);
33-
bg.loadGraphic(Paths.image('stages/school/pause/bg'));
34-
if (isThorns)
35-
bg.color = 0xFF000000;
31+
bg = new FlxSprite(44 * 6, 14 * 6, Paths.image('stages/school/pause/bg'));
32+
bg.antialiasing = false;
33+
if (isThorns) bg.color = 0xFF000000;
3634
bg.scale.set(6, 6);
3735
bg.updateHitbox();
3836
bg.scale.y = 4;
39-
bg.cameras = [pauseCam];
4037
add(bg);
4138

4239
songText = new FlxText(0, 22 * 6, 0, "Pause", 8, false);
4340
confText(songText);
4441
add(songText);
4542

46-
var i = 2;
47-
for(e in menuItems) {
48-
text = new FlxText(0, (22 * 6) + (i * 9 * 6), 0, e, 8, false);
43+
for (i=>e in menuItems) {
44+
text = new FlxText(0, (22 * 6) + ((i+2) * 9 * 6), 0, e, 8, false);
4945
confText(text);
50-
add(text);
51-
texts.push(text);
52-
i++;
5346
}
5447

5548
hand = new FlxSprite().loadGraphic(Paths.image('stages/school/ui/hand_textbox'));
49+
hand.antialiasing = false;
5650
hand.scale.set(6, 6);
5751
hand.updateHitbox();
5852
add(hand);
5953

60-
FlxTween.tween(bg, {"scale.y": 6}, 0.75, {ease: FlxEase.elasticOut});
54+
FlxTween.tween(bg.scale, {y: 6}, 0.75, {ease: FlxEase.elasticOut});
6155

62-
cameras = [pauseCam];
6356

6457
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
6558
}
@@ -70,55 +63,50 @@ function confText(text) {
7063
text.screenCenter(FlxAxes.X);
7164
text.borderStyle = FlxTextBorderStyle.OUTLINE;
7265
if (!isThorns) text.borderColor = 0xFF953E3E;
73-
}
7466

75-
function destroy() {
76-
if(FlxG.cameras.list.contains(pauseCam))
77-
FlxG.cameras.remove(pauseCam);
67+
text.antialiasing = false;
68+
texts.push(text);
69+
add(text);
7870
}
7971

72+
function destroy() if (FlxG.cameras.list.contains(pauseCam))
73+
FlxG.cameras.remove(pauseCam);
74+
8075
var canDoShit = true;
8176
var time:Float = 0;
8277
function update(elapsed) {
83-
pixelScript.call("postUpdate", [elapsed]);
78+
pixelScript?.call("postUpdate", [elapsed]);
8479

8580
pauseCam.alpha = lerp(pauseCam.alpha, 1, 0.25);
8681
time += elapsed;
8782

88-
var curText = texts[curSelected];
83+
var curText = texts[curSelected + 1];
8984
hand.setPosition(curText.x - hand.width - 18 + (Math.sin(time * Math.PI * 2) * 12), curText.y + (text.height - hand.height) - 6);
9085
hand.x -= hand.x % 6;
9186
hand.y -= hand.y % 6;
9287

93-
if (!canDoShit) return;
94-
var oldSec = curSelected;
95-
9688
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
9789

98-
if (oldSec != curSelected)
99-
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText'));
90+
if (controls.ACCEPT) enterOption();
91+
}
92+
93+
var scrollSFX = FlxG.sound.load(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText'));
94+
function changeSelection(change) if (canDoShit) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
95+
curSelected = FlxMath.wrap(curSelected + change, 0, menuItems.length - 1);
96+
if (change != 0) scrollSFX.play();
97+
}
10098

101-
if (controls.ACCEPT) {
102-
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
103-
var option = menuItems[curSelected];
104-
if (option == "Resume" || option == "Exit to menu") {
99+
var enterSFX = FlxG.sound.load(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
100+
function enterOption() if (canDoShit) {
101+
var option = menuItems[curSelected];
102+
enterSFX.play();
103+
104+
switch(option) {
105+
case "Resume", "Exit to menu":
105106
canDoShit = false;
106107
for(t in texts) t.visible = false;
107108
hand.visible = songText.visible = false;
108-
FlxTween.tween(bg, {"scale.y": 0}, 0.125, {ease: FlxEase.cubeOut, onComplete: function() {
109-
selectOption();
110-
}});
111-
} else {
112-
selectOption();
113-
}
109+
FlxTween.tween(bg.scale, {y: 0}, 0.125, {ease: FlxEase.cubeOut, onComplete: selectOption});
110+
default: selectOption();
114111
}
115112
}
116-
117-
function changeSelection(change) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
118-
curSelected += change;
119-
120-
if (curSelected < 0)
121-
curSelected = menuItems.length - 1;
122-
if (curSelected >= menuItems.length)
123-
curSelected = 0;
124-
}

assets/data/scripts/week7-balledLines.hx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ var sound:Sound;
33
function create()
44
sound = Paths.sound('jeffGameover/jeffGameover-' + FlxG.random.int(1, 25, !Options.naughtyness ? [1, 3, 8, 13, 17, 21] : null));
55

6-
function beatHit(cur:Int) {
7-
if(cur != 0) return;
8-
6+
function beatHit(cur:Int) if (cur == 0) {
7+
FlxG.sound.play(sound, 1, false, null, true, () -> if (!isEnding) FlxG.sound.music.fadeIn(4, 0.2, 1));
98
FlxG.sound.music.volume = 0.2;
10-
FlxG.sound.play(sound, 1, false, null, true, function()
11-
{
12-
if (!isEnding)
13-
FlxG.sound.music.fadeIn(4, 0.2, 1);
14-
});
159
}

assets/data/stages/tank.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var tankAngle:Float = FlxG.random.int(-90, 45);
22
var tankSpeed:Float = FlxG.random.float(5, 7);
33

4-
function postCreate() if(PlayState.isStoryMode)
4+
function postCreate() if (PlayState.isStoryMode)
55
GameOverSubstate.script = 'data/scripts/week7-balledLines';
66

77
function update(elapsed:Float) {
@@ -12,7 +12,7 @@ function update(elapsed:Float) {
1212
}
1313

1414
function onPostCountdown(event) {
15-
if(!playCutscenes || event.sprite == null) return;
15+
if (!playCutscenes || event.sprite == null) return;
1616
var lastIndex:Int = members.indexOf(event.sprite);
1717
remove(event.sprite);
1818
insert(lastIndex + 4, event.sprite);

0 commit comments

Comments
 (0)