mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-05-04 18:59:13 -04:00
wip
This commit is contained in:
parent
9e12f62b81
commit
892f800107
14 changed files with 2866 additions and 2840 deletions
|
@ -29,8 +29,8 @@ android {
|
||||||
applicationId = "me.lecaro.breakout"
|
applicationId = "me.lecaro.breakout"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 29104759
|
versionCode = 29104940
|
||||||
versionName = "29104759"
|
versionName = "29104940"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
useSupportLibrary = true
|
useSupportLibrary = true
|
||||||
|
|
File diff suppressed because one or more lines are too long
1385
dist/index.html
vendored
1385
dist/index.html
vendored
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
// The version of the cache.
|
// The version of the cache.
|
||||||
const VERSION = "29104759";
|
const VERSION = "29104940";
|
||||||
|
|
||||||
// The name of the cache
|
// The name of the cache
|
||||||
const CACHE_NAME = `breakout-71-${VERSION}`;
|
const CACHE_NAME = `breakout-71-${VERSION}`;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
"29104759"
|
"29104940"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -642,7 +641,6 @@ h2.histogram-title strong {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
transform: none;
|
transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.gridEdit > div > span,
|
.gridEdit > div > span,
|
||||||
|
@ -733,23 +731,23 @@ h2.histogram-title strong {
|
||||||
}
|
}
|
||||||
|
|
||||||
@palette_B: black;
|
@palette_B: black;
|
||||||
@palette_W:#FFFFFF;
|
@palette_W: #ffffff;
|
||||||
@palette_g: #231f20;
|
@palette_g: #231f20;
|
||||||
@palette_y:#FFD300;
|
@palette_y: #ffd300;
|
||||||
@palette_b:#6262EA;
|
@palette_b: #6262ea;
|
||||||
@palette_t:#5DA3EA;
|
@palette_t: #5da3ea;
|
||||||
@palette_s:#E67070;
|
@palette_s: #e67070;
|
||||||
@palette_r: #e32119;
|
@palette_r: #e32119;
|
||||||
@palette_R: #ab0c0c;
|
@palette_R: #ab0c0c;
|
||||||
@palette_c:#59EEA3;
|
@palette_c: #59eea3;
|
||||||
@palette_G:#A1F051;
|
@palette_G: #a1f051;
|
||||||
@palette_v:#A664E8;
|
@palette_v: #a664e8;
|
||||||
@palette_p:#E869E8;
|
@palette_p: #e869e8;
|
||||||
@palette_a:#5BECEC;
|
@palette_a: #5becec;
|
||||||
@palette_C:#53EE53;
|
@palette_C: #53ee53;
|
||||||
@palette_S:#F44848;
|
@palette_S: #f44848;
|
||||||
@palette_P:#E66BA8;
|
@palette_P: #e66ba8;
|
||||||
@palette_O:#F29E4A;
|
@palette_O: #f29e4a;
|
||||||
@palette_k: #618227;
|
@palette_k: #618227;
|
||||||
@palette_e: #e1c8b4;
|
@palette_e: #e1c8b4;
|
||||||
@palette_l: #9b9fa;
|
@palette_l: #9b9fa;
|
34
src/game.ts
34
src/game.ts
|
@ -254,34 +254,34 @@ let timers = [];
|
||||||
function startPlayCountDown() {
|
function startPlayCountDown() {
|
||||||
stopPlayCountDown();
|
stopPlayCountDown();
|
||||||
|
|
||||||
|
gameState.startCountDown = 3;
|
||||||
|
gameState.needsRender = true;
|
||||||
|
|
||||||
gameState.startCountDown = 3
|
|
||||||
gameState.needsRender = true
|
|
||||||
|
|
||||||
timers.push(setTimeout(() => {
|
|
||||||
gameState.startCountDown = 2
|
|
||||||
gameState.needsRender = true
|
|
||||||
}, 1000));
|
|
||||||
timers.push(setTimeout(() => {
|
|
||||||
gameState.startCountDown = 1
|
|
||||||
gameState.needsRender = true
|
|
||||||
}, 2000));
|
|
||||||
timers.push(
|
timers.push(
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
gameState.startCountDown = 0
|
gameState.startCountDown = 2;
|
||||||
|
gameState.needsRender = true;
|
||||||
|
}, 1000),
|
||||||
|
);
|
||||||
|
timers.push(
|
||||||
|
setTimeout(() => {
|
||||||
|
gameState.startCountDown = 1;
|
||||||
|
gameState.needsRender = true;
|
||||||
|
}, 2000),
|
||||||
|
);
|
||||||
|
timers.push(
|
||||||
|
setTimeout(() => {
|
||||||
|
gameState.startCountDown = 0;
|
||||||
play();
|
play();
|
||||||
}, 3000),
|
}, 3000),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
function stopPlayCountDown() {
|
function stopPlayCountDown() {
|
||||||
if(!timers.length) return
|
if (!timers.length) return;
|
||||||
|
|
||||||
gameState.startCountDown = 0
|
gameState.startCountDown = 0;
|
||||||
timers.forEach((id) => clearTimeout(id));
|
timers.forEach((id) => clearTimeout(id));
|
||||||
timers.length = 0;
|
timers.length = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
gameCanvas.addEventListener("touchstart", (e) => {
|
gameCanvas.addEventListener("touchstart", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -37,10 +37,23 @@ import {t} from "./i18n/i18n";
|
||||||
import { getCurrentMaxCoins, getCurrentMaxParticles } from "./settings";
|
import { getCurrentMaxCoins, getCurrentMaxParticles } from "./settings";
|
||||||
import { background } from "./render";
|
import { background } from "./render";
|
||||||
import { gameOver } from "./gameOver";
|
import { gameOver } from "./gameOver";
|
||||||
import {brickIndex, fitSize, gameState, hasBrick, hitsSomething, pause, startComputerControlledGame,} from "./game";
|
import {
|
||||||
|
brickIndex,
|
||||||
|
fitSize,
|
||||||
|
gameState,
|
||||||
|
hasBrick,
|
||||||
|
hitsSomething,
|
||||||
|
pause,
|
||||||
|
startComputerControlledGame,
|
||||||
|
} from "./game";
|
||||||
import { stopRecording } from "./recording";
|
import { stopRecording } from "./recording";
|
||||||
import { isOptionOn } from "./options";
|
import { isOptionOn } from "./options";
|
||||||
import {ballTransparency, clamp, coinsBoostedCombo, comboKeepingRate,} from "./pure_functions";
|
import {
|
||||||
|
ballTransparency,
|
||||||
|
clamp,
|
||||||
|
coinsBoostedCombo,
|
||||||
|
comboKeepingRate,
|
||||||
|
} from "./pure_functions";
|
||||||
import { addToTotalScore } from "./addToTotalScore";
|
import { addToTotalScore } from "./addToTotalScore";
|
||||||
import { hashCode } from "./getLevelBackground";
|
import { hashCode } from "./getLevelBackground";
|
||||||
import { openUpgradesPicker } from "./openUpgradesPicker";
|
import { openUpgradesPicker } from "./openUpgradesPicker";
|
||||||
|
@ -568,8 +581,7 @@ export function addToScore(gameState: GameState, coin: Coin) {
|
||||||
gameState.highScore = gameState.score;
|
gameState.highScore = gameState.score;
|
||||||
try {
|
try {
|
||||||
localStorage.setItem("breakout-3-hs-short", gameState.score.toString());
|
localStorage.setItem("breakout-3-hs-short", gameState.score.toString());
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!isOptionOn("basic")) {
|
if (!isOptionOn("basic")) {
|
||||||
makeParticle(
|
makeParticle(
|
||||||
|
@ -983,7 +995,7 @@ export function gameStateTick(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// Lost ball while waiting to win, will level up for fairness
|
// Lost ball while waiting to win, will level up for fairness
|
||||||
(gameState.winAt && !gameState.balls.find(b => !b.destroyed)) ||
|
(gameState.winAt && !gameState.balls.find((b) => !b.destroyed)) ||
|
||||||
// Delayed win when coins are still flying
|
// Delayed win when coins are still flying
|
||||||
(gameState.winAt && gameState.levelTime > gameState.winAt) ||
|
(gameState.winAt && gameState.levelTime > gameState.winAt) ||
|
||||||
// instant win condition
|
// instant win condition
|
||||||
|
@ -1387,8 +1399,7 @@ export function gameStateTick(
|
||||||
|
|
||||||
if (gameState.perks.wind) {
|
if (gameState.perks.wind) {
|
||||||
const windD =
|
const windD =
|
||||||
((gameState.puckPosition -
|
((gameState.puckPosition - canvasCenterX(gameState)) /
|
||||||
canvasCenterX(gameState)) /
|
|
||||||
gameState.gameZoneWidth) *
|
gameState.gameZoneWidth) *
|
||||||
2 *
|
2 *
|
||||||
gameState.perks.wind;
|
gameState.perks.wind;
|
||||||
|
@ -1697,9 +1708,18 @@ export function ballTick(gameState: GameState, ball: Ball, frames: number) {
|
||||||
const d = Math.sqrt(ball.vy * ball.vy + ball.vx * ball.vx);
|
const d = Math.sqrt(ball.vy * ball.vy + ball.vx * ball.vx);
|
||||||
ball.vy = Math.sin(angle) * d;
|
ball.vy = Math.sin(angle) * d;
|
||||||
ball.vx = Math.cos(angle) * d;
|
ball.vx = Math.cos(angle) * d;
|
||||||
if (Math.random() < frames && !isOptionOn('basic')) {
|
if (Math.random() < frames && !isOptionOn("basic")) {
|
||||||
makeParticle(gameState, ball.x, ball.y, -ball.vx / 10, -ball.vy / 10,
|
makeParticle(
|
||||||
'#6262EA', true, 8, 500)
|
gameState,
|
||||||
|
ball.x,
|
||||||
|
ball.y,
|
||||||
|
-ball.vx / 10,
|
||||||
|
-ball.vy / 10,
|
||||||
|
"#6262EA",
|
||||||
|
true,
|
||||||
|
8,
|
||||||
|
500,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1885,8 +1905,11 @@ export function ballTick(gameState: GameState, ball: Ball, frames: number) {
|
||||||
}
|
}
|
||||||
// If you loose a ball while waiting to level up, setLevel is called and pauses the game
|
// If you loose a ball while waiting to level up, setLevel is called and pauses the game
|
||||||
// In that case it's ok to not have any ball, don't game over
|
// In that case it's ok to not have any ball, don't game over
|
||||||
if (!gameState.balls.find((b) => !b.destroyed) && gameState.running && !gameState.winAt) {
|
if (
|
||||||
|
!gameState.balls.find((b) => !b.destroyed) &&
|
||||||
|
gameState.running &&
|
||||||
|
!gameState.winAt
|
||||||
|
) {
|
||||||
if (gameState.startParams.computer_controlled) {
|
if (gameState.startParams.computer_controlled) {
|
||||||
startComputerControlledGame(gameState.startParams.stress);
|
startComputerControlledGame(gameState.startParams.stress);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2022,7 +2045,6 @@ export function ballTick(gameState: GameState, ball: Ball, frames: number) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function justLostALife(gameState: GameState, ball: Ball, x: number, y: number) {
|
function justLostALife(gameState: GameState, ball: Ball, x: number, y: number) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import { t } from "./i18n/i18n";
|
||||||
import { clamp } from "./pure_functions";
|
import { clamp } from "./pure_functions";
|
||||||
import { getSettingValue, getTotalScore } from "./settings";
|
import { getSettingValue, getTotalScore } from "./settings";
|
||||||
import { isOptionOn } from "./options";
|
import { isOptionOn } from "./options";
|
||||||
import {gameCanvas} from "./render";
|
|
||||||
|
|
||||||
export function describeLevel(level: Level) {
|
export function describeLevel(level: Level) {
|
||||||
let bricks = 0,
|
let bricks = 0,
|
||||||
|
@ -348,12 +347,11 @@ export function escapeAttribute(str: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canvasCenterX(gameState: GameState) {
|
export function canvasCenterX(gameState: GameState) {
|
||||||
return gameState.canvasWidth/2
|
return gameState.canvasWidth / 2;
|
||||||
}
|
}
|
||||||
export function zoneLeftBorderX(gameState: GameState) {
|
export function zoneLeftBorderX(gameState: GameState) {
|
||||||
|
return gameState.offsetXRoundedDown - 1;
|
||||||
return gameState.offsetXRoundedDown - 1
|
|
||||||
}
|
}
|
||||||
export function zoneRightBorderX(gameState: GameState) {
|
export function zoneRightBorderX(gameState: GameState) {
|
||||||
return gameCanvas.width - gameState.offsetXRoundedDown + 1
|
return gameState.canvasWidth - gameState.offsetXRoundedDown + 1;
|
||||||
}
|
}
|
|
@ -9,8 +9,6 @@ import {
|
||||||
levelTimeGood,
|
levelTimeGood,
|
||||||
missesBest,
|
missesBest,
|
||||||
missesGood,
|
missesGood,
|
||||||
wallBouncedBest,
|
|
||||||
wallBouncedGood,
|
|
||||||
} from "./pure_functions";
|
} from "./pure_functions";
|
||||||
|
|
||||||
export function helpMenuEntry() {
|
export function helpMenuEntry() {
|
||||||
|
|
|
@ -95,9 +95,7 @@ export function firstWhere<Input, Output>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const wallBouncedBest = 2,
|
export const levelTimeBest = 25,
|
||||||
wallBouncedGood = 7,
|
|
||||||
levelTimeBest = 25,
|
|
||||||
levelTimeGood = 45,
|
levelTimeGood = 45,
|
||||||
catchRateBest = 98,
|
catchRateBest = 98,
|
||||||
catchRateGood = 90,
|
catchRateGood = 90,
|
||||||
|
|
|
@ -10,7 +10,9 @@ import {
|
||||||
max_levels,
|
max_levels,
|
||||||
reachRedRowIndex,
|
reachRedRowIndex,
|
||||||
telekinesisEffectRate,
|
telekinesisEffectRate,
|
||||||
yoyoEffectRate, zoneLeftBorderX, zoneRightBorderX,
|
yoyoEffectRate,
|
||||||
|
zoneLeftBorderX,
|
||||||
|
zoneRightBorderX,
|
||||||
} from "./game_utils";
|
} from "./game_utils";
|
||||||
import { colorString, GameState } from "./types";
|
import { colorString, GameState } from "./types";
|
||||||
import { t } from "./i18n/i18n";
|
import { t } from "./i18n/i18n";
|
||||||
|
@ -26,8 +28,6 @@ import {
|
||||||
levelTimeGood,
|
levelTimeGood,
|
||||||
missesBest,
|
missesBest,
|
||||||
missesGood,
|
missesGood,
|
||||||
wallBouncedBest,
|
|
||||||
wallBouncedGood,
|
|
||||||
} from "./pure_functions";
|
} from "./pure_functions";
|
||||||
|
|
||||||
export const gameCanvas = document.getElementById("game") as HTMLCanvasElement;
|
export const gameCanvas = document.getElementById("game") as HTMLCanvasElement;
|
||||||
|
@ -642,21 +642,36 @@ export function render(gameState: GameState) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
startWork("render:timeout");
|
startWork("render:timeout");
|
||||||
if (gameState.winAt || gameState.startCountDown) {
|
if (gameState.winAt || gameState.startCountDown) {
|
||||||
const remaining = gameState.startCountDown || Math.ceil((gameState.winAt-gameState.levelTime)/1000)
|
const remaining =
|
||||||
|
gameState.startCountDown ||
|
||||||
|
Math.ceil((gameState.winAt - gameState.levelTime) / 1000);
|
||||||
if (remaining > 0 && remaining < 5) {
|
if (remaining > 0 && remaining < 5) {
|
||||||
ctx.globalAlpha=1
|
ctx.globalAlpha = 1;
|
||||||
ctx.globalCompositeOperation = "destination-out";
|
ctx.globalCompositeOperation = "destination-out";
|
||||||
drawText(ctx, remaining.toString(), 'white', 65, gameState.canvasWidth/2, gameState.canvasHeight/2)
|
drawText(
|
||||||
|
ctx,
|
||||||
|
remaining.toString(),
|
||||||
|
"white",
|
||||||
|
65,
|
||||||
|
gameState.canvasWidth / 2,
|
||||||
|
gameState.canvasHeight / 2,
|
||||||
|
);
|
||||||
|
|
||||||
ctx.globalCompositeOperation = "screen";
|
ctx.globalCompositeOperation = "screen";
|
||||||
ctx.globalAlpha=1/remaining
|
ctx.globalAlpha = 1 / remaining;
|
||||||
drawText(ctx, remaining.toString(), 'white', 60, gameState.canvasWidth/2, gameState.canvasHeight/2)
|
drawText(
|
||||||
|
ctx,
|
||||||
|
remaining.toString(),
|
||||||
|
"white",
|
||||||
|
60,
|
||||||
|
gameState.canvasWidth / 2,
|
||||||
|
gameState.canvasHeight / 2,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.globalAlpha=1
|
ctx.globalAlpha = 1;
|
||||||
|
|
||||||
startWork("render:askForWakeLock");
|
startWork("render:askForWakeLock");
|
||||||
askForWakeLock(gameState);
|
askForWakeLock(gameState);
|
||||||
|
|
|
@ -3,7 +3,7 @@ div.classList = "hidden toast";
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
let timeout: NodeJS.Timeout | undefined;
|
let timeout: NodeJS.Timeout | undefined;
|
||||||
export function toast(html: string, className = "") {
|
export function toast(html: string, className = "") {
|
||||||
clearToasts()
|
clearToasts();
|
||||||
div.classList = "toast visible " + className;
|
div.classList = "toast visible " + className;
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
timeout = setTimeout(clearToasts, 1500);
|
timeout = setTimeout(clearToasts, 1500);
|
||||||
|
@ -12,7 +12,7 @@ export function toast(html: string, className = "") {
|
||||||
export function clearToasts() {
|
export function clearToasts() {
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
timeout = undefined
|
timeout = undefined;
|
||||||
}
|
}
|
||||||
div.classList = "hidden toast";
|
div.classList = "hidden toast";
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue