Skip to content

Commit 576dcfa

Browse files
committed
Pre pixi-canvas integration
1 parent b5e1f7d commit 576dcfa

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed
File renamed without changes.

quintacolor.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// TODO: Bad performance on crappy machines... test using pixi canvas, or sprites instead of drawRect?
2+
// TODO: Show highscore on title screen.
3+
// TODO: If the player would lose, has quake, and quake would save them, auto-use quake
4+
15
// TODO: Improve the vanishes for the new 3D look. Cube shape? Delaunay triangulation? (https://github.com/mapbox/delaunator)
2-
// TODO: Still sometimes lagging HARD the first time the meter becomes full. Why?! We're continuously making blur calls. Seems more consistent the longer the game has been running
3-
// Just switched the meter text to be when the appearance is full vs the actual value. It was happening on the actual value becoming full before... is it now when the meter appears full?
4-
// And go fix that inline TODO
56
// TODO: Music not working on mobile?
67
// TODO: Fix bad mouse events vs page interaction on mobile.
78

@@ -128,8 +129,8 @@ var TEXT_KEYS = ["P: pause",
128129
if (ALLOW_INCREASE_LEVEL) {
129130
TEXT_KEYS.unshift("Z: increase level")
130131
}
131-
const TEXT_CREDITS = ["Quintacolor v 1.0",
132-
"a game by Tom Quinn (thquinn.github.io)",
132+
const TEXT_CREDITS = ["Quintacolor v 1.0.1",
133+
"by Tom Quinn (thquinn.github.io)",
133134
"sound by Jacob Ruttenberg (jruttenberg.io)",
134135
"fonts Gilgongo and Source Sans Pro by Apostrophic Labs and Paul D. Hunt, respectively",
135136
"thanks to Arthee, Chet, Jay, Jonny, Maggie, San, and Tanoy",
@@ -176,6 +177,7 @@ const SFX_QUAKE_VOLUME = .4;
176177
// 2D HTML5 context setup.
177178
const ctx = canvas.getContext('2d');
178179
ctx.lineCap = "square";
180+
ctx.shadowColor = UI_QUAKE_METER_FULL_COLOR;
179181
const boardCtx = boardCanvas.getContext('2d');
180182
const boardDesaturationCtx = boardDesaturationCanvas.getContext('2d');
181183
// Asset setup.
@@ -708,6 +710,9 @@ function loop() {
708710
if (state == StateEnum.TITLE && !ASSET_BGM_TITLE.playing()) {
709711
ASSET_BGM_TITLE.play();
710712
}
713+
if (state != StateEnum.TITLE && ASSET_BGM_TITLE.playing()) {
714+
ASSET_BGM_TITLE.stop();
715+
}
711716

712717
window.requestAnimationFrame(loop);
713718
if (quakeSpawnDelay == 0) {
@@ -745,6 +750,10 @@ function loop() {
745750
ctx.stroke();
746751
}
747752

753+
// Mute check.
754+
if (keysPressed.has(KeyBindings.MUTE)) {
755+
localStorage.mute = localStorage.mute == 'true' ? 'false' : 'true';
756+
}
748757
// Pause check.
749758
if (keysPressed.has(KeyBindings.PAUSE) && (state == StateEnum.RUNNING || state == StateEnum.PAUSED)) {
750759
state = state == StateEnum.RUNNING ? StateEnum.PAUSED : StateEnum.RUNNING;
@@ -759,11 +768,6 @@ function loop() {
759768
}
760769

761770
if (state != StateEnum.PAUSED) {
762-
// Mute check.
763-
if (keysPressed.has(KeyBindings.MUTE)) {
764-
localStorage.mute = localStorage.mute == 'true' ? 'false' : 'true';
765-
}
766-
767771
// Game over check.
768772
if (state == StateEnum.RUNNING) {
769773
spawnBlocked = true;
@@ -776,6 +780,7 @@ function loop() {
776780
gameOver = false;
777781
}
778782
}
783+
// Game over.
779784
if (gameOver) {
780785
selected = [];
781786
quakeMeter = 0;
@@ -1011,11 +1016,11 @@ function loop() {
10111016
ctx.fillStyle = UI_QUAKE_METER_FULL_COLOR;
10121017
ctx.fillRect(screenShakeX + UI_QUAKE_METER_X, screenShakeY + UI_QUAKE_METER_Y, UI_QUAKE_METER_WIDTH * fillPercent, UI_QUAKE_METER_HEIGHT);
10131018
let glow = PIECE_SIZE * (quakeMeter == quakeMeterSize ? Math.sin(clock / 25) * .05 + .1 : .04);
1014-
ctx.filter = 'blur(' + glow + 'px)';
1019+
ctx.shadowBlur = glow;
10151020
ctx.fillRect(screenShakeX + UI_QUAKE_METER_X, screenShakeY + UI_QUAKE_METER_Y, UI_QUAKE_METER_WIDTH * (quakeMeterAppearance / quakeMeterSize), UI_QUAKE_METER_HEIGHT);
1016-
ctx.filter = 'none';
1021+
ctx.shadowBlur = 0;
10171022
}
1018-
if (Math.abs(quakeMeterAppearance - quakeMeterSize) < .001) { // TODO: Change this back to quakeMeter == quakeMeterSize
1023+
if (quakeMeter == quakeMeterSize) {
10191024
ctx.textAlign = 'center';
10201025
ctx.textBaseline = 'middle';
10211026
ctx.fillStyle = '#DFDFFF';

0 commit comments

Comments
 (0)