Skip to content

Commit dfb7c6e

Browse files
committed
vobf
1 parent 576dcfa commit dfb7c6e

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

quintacolor.js

+38-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
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-
51
// TODO: Improve the vanishes for the new 3D look. Cube shape? Delaunay triangulation? (https://github.com/mapbox/delaunator)
62
// TODO: Music not working on mobile?
73
// TODO: Fix bad mouse events vs page interaction on mobile.
@@ -793,18 +789,6 @@ function loop() {
793789
}
794790
}
795791

796-
// Quake?
797-
if (quakeMeter < quakeMeterAppearance) {
798-
quakeMeterAppearance = quakeMeter * .067 + quakeMeterAppearance * .933;
799-
}
800-
if (state == StateEnum.RUNNING && QUAKE_METER && keysPressed.has(KeyBindings.QUAKE)) {
801-
if (quakeMeter >= quakeMeterSize) {
802-
quake();
803-
} else if (DEBUG_MODE) {
804-
quakeMeter = quakeMeterSize;
805-
quakeMeterAppearance = quakeMeterSize;
806-
}
807-
}
808792
// Update pieces.
809793
if (state == StateEnum.SETUP || state == StateEnum.RUNNING) {
810794
for (let x = 0; x < BOARD_WIDTH; x++) {
@@ -861,7 +845,20 @@ function loop() {
861845
}
862846
// Spawn pieces.
863847
if (spawnTimer <= 0) {
864-
if (!spawnBlocked) {
848+
let headSpace = 0;
849+
for (let x = 0; x < BOARD_WIDTH; x++) {
850+
for (let y = 0; y < BOARD_HEIGHT; y++) {
851+
if (board[x][y] == null) {
852+
headSpace++;
853+
} else {
854+
break;
855+
}
856+
}
857+
}
858+
if (headSpace == 1 && quakeMeter == quakeMeterSize) {
859+
keysPressed.add(KeyBindings.QUAKE);
860+
spawnTimer = .001;
861+
} else if (!spawnBlocked) {
865862
new Piece();
866863
let rate = SPAWN_RATE_INITIAL + Math.pow((level - 1) * SPAWN_RATE_INCREMENT, SPAWN_RATE_INCREMENT_EXPONENT);
867864
if (SPAWN_RATE_SCALE_WITH_VACANCY) {
@@ -889,6 +886,19 @@ function loop() {
889886
spawnTimer--;
890887
}
891888
}
889+
890+
// Quake?
891+
if (quakeMeter < quakeMeterAppearance) {
892+
quakeMeterAppearance = quakeMeter * .067 + quakeMeterAppearance * .933;
893+
}
894+
if (state == StateEnum.RUNNING && QUAKE_METER && keysPressed.has(KeyBindings.QUAKE)) {
895+
if (quakeMeter >= quakeMeterSize) {
896+
quake();
897+
} else if (DEBUG_MODE) {
898+
quakeMeter = quakeMeterSize;
899+
quakeMeterAppearance = quakeMeterSize;
900+
}
901+
}
892902

893903
// Draw pieces.
894904
boardCtx.clearRect(0, 0, boardCanvas.width, boardCanvas.height);
@@ -1014,10 +1024,9 @@ function loop() {
10141024
let fillPercent = quakeMeterAppearance / quakeMeterSize;
10151025
if (fillPercent > 0) {
10161026
ctx.fillStyle = UI_QUAKE_METER_FULL_COLOR;
1017-
ctx.fillRect(screenShakeX + UI_QUAKE_METER_X, screenShakeY + UI_QUAKE_METER_Y, UI_QUAKE_METER_WIDTH * fillPercent, UI_QUAKE_METER_HEIGHT);
10181027
let glow = PIECE_SIZE * (quakeMeter == quakeMeterSize ? Math.sin(clock / 25) * .05 + .1 : .04);
10191028
ctx.shadowBlur = glow;
1020-
ctx.fillRect(screenShakeX + UI_QUAKE_METER_X, screenShakeY + UI_QUAKE_METER_Y, UI_QUAKE_METER_WIDTH * (quakeMeterAppearance / quakeMeterSize), UI_QUAKE_METER_HEIGHT);
1029+
ctx.fillRect(screenShakeX + UI_QUAKE_METER_X, screenShakeY + UI_QUAKE_METER_Y, UI_QUAKE_METER_WIDTH * fillPercent, UI_QUAKE_METER_HEIGHT);
10211030
ctx.shadowBlur = 0;
10221031
}
10231032
if (quakeMeter == quakeMeterSize) {
@@ -1118,9 +1127,16 @@ function loop() {
11181127
ctx.fillText(TEXT_KEYS[i], BOARD_PADDING / 2, y);
11191128
}
11201129
ctx.textAlign ='right';
1121-
for (let i = 0; i < TEXT_CREDITS.length; i++) {
1122-
let y = canvas.height - BOARD_PADDING / 2 - (UI_SCORE_FONT_SIZE / 6) * (TEXT_CREDITS.length - i - 1);
1123-
ctx.fillText(TEXT_CREDITS[i], canvas.width - BOARD_PADDING / 2, y);
1130+
let textCreditsLength = localStorage.highScore == null ? TEXT_CREDITS.length : TEXT_CREDITS.length + 1;
1131+
for (let i = 0; i < textCreditsLength; i++) {
1132+
let text;
1133+
if (i == TEXT_CREDITS.length) {
1134+
text = "your high score: " + parseInt(localStorage.highScore).toLocaleString();
1135+
} else {
1136+
text = TEXT_CREDITS[i];
1137+
}
1138+
let y = canvas.height - BOARD_PADDING / 2 - (UI_SCORE_FONT_SIZE / 6) * (textCreditsLength - i - 1);
1139+
ctx.fillText(text, canvas.width - BOARD_PADDING / 2, y);
11241140
}
11251141
}
11261142

0 commit comments

Comments
 (0)