This commit is contained in:
Renan LE CARO 2025-03-25 08:47:39 +01:00
parent 35ea8e952a
commit 10bae8f47c
8 changed files with 836 additions and 751 deletions

View file

@ -11,8 +11,8 @@ android {
applicationId = "me.lecaro.breakout"
minSdk = 21
targetSdk = 34
versionCode = 29046953
versionName = "29046953"
versionCode = 29048147
versionName = "29048147"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true

File diff suppressed because one or more lines are too long

40
dist/index.html vendored

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
// The version of the cache.
const VERSION = "29046953";
const VERSION = "29048147";
// The name of the cache
const CACHE_NAME = `breakout-71-${VERSION}`;

View file

@ -1 +1 @@
"29046953"
"29048147"

View file

@ -163,10 +163,13 @@ export function normalizeGameState(gameState: GameState) {
putBallsAtPuck(gameState);
}
if (Math.abs(gameState.lastPuckPosition - gameState.puckPosition) > 1 && gameState.running) {
if (
Math.abs(gameState.lastPuckPosition - gameState.puckPosition) > 1 &&
gameState.running
) {
gameState.lastPuckMove = gameState.levelTime;
}
gameState.lastPuckPosition = gameState.puckPosition
gameState.lastPuckPosition = gameState.puckPosition;
}
export function baseCombo(gameState: GameState) {
@ -847,7 +850,6 @@ export function gameStateTick(
gameState.combo,
);
gameState.balls = gameState.balls.filter((ball) => !ball.destroyed);
const remainingBricks = gameState.bricks.filter(

View file

@ -170,10 +170,11 @@ export function render(gameState: GameState) {
coin.size,
coin.x,
coin.y,
(hasCombo && gameState.perks.asceticism && 'red') || level.color || "black",
(hasCombo && gameState.perks.asceticism && "red") ||
level.color ||
"black",
coin.a,
);
});
// Black shadow around balls
@ -277,7 +278,7 @@ export function render(gameState: GameState) {
gameState.puckHeight,
0,
!!gameState.perks.concave_puck,
gameState.perks.streak_shots && hasCombo ? getDashOffset(gameState) : -1
gameState.perks.streak_shots && hasCombo ? getDashOffset(gameState) : -1,
);
if (gameState.combo > 1) {
@ -325,40 +326,96 @@ export function render(gameState: GameState) {
ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1;
if (gameState.offsetXRoundedDown) {
// draw outside of gaming area to avoid capturing borders in recordings
ctx.fillStyle =
hasCombo && gameState.perks.left_is_lava ? "red" : gameState.puckColor;
drawStraightLine(ctx, gameState,
(hasCombo && gameState.perks.left_is_lava && !gameState.perks.unbounded && 'red') || 'white'
, gameState.offsetX - 1, 0, gameState.offsetX - 1, height, gameState.perks.unbounded ? 0.1 : 1)
drawStraightLine(ctx, gameState,
(hasCombo && gameState.perks.right_is_lava && !gameState.perks.unbounded && 'red') || 'white'
, width - gameState.offsetX + 1, 0, width - gameState.offsetX + 1, height, gameState.perks.unbounded ? 0.1 : 1)
drawStraightLine(
ctx,
gameState,
(hasCombo &&
gameState.perks.left_is_lava &&
!gameState.perks.unbounded &&
"red") ||
"white",
gameState.offsetX - 1,
0,
gameState.offsetX - 1,
height,
gameState.perks.unbounded ? 0.1 : 1,
);
drawStraightLine(
ctx,
gameState,
(hasCombo &&
gameState.perks.right_is_lava &&
!gameState.perks.unbounded &&
"red") ||
"white",
width - gameState.offsetX + 1,
0,
width - gameState.offsetX + 1,
height,
gameState.perks.unbounded ? 0.1 : 1,
);
} else {
ctx.fillStyle = "red";
drawStraightLine(ctx, gameState,
(hasCombo && gameState.perks.left_is_lava && !gameState.perks.unbounded && 'red') || ''
, 0, 0, 0, height, 1)
drawStraightLine(
ctx,
gameState,
(hasCombo &&
gameState.perks.left_is_lava &&
!gameState.perks.unbounded &&
"red") ||
"",
0,
0,
0,
height,
1,
);
drawStraightLine(ctx, gameState,
(hasCombo && gameState.perks.right_is_lava && !gameState.perks.unbounded && 'red') || ''
, width - 1, 0, width - 1, height, 1)
drawStraightLine(
ctx,
gameState,
(hasCombo &&
gameState.perks.right_is_lava &&
!gameState.perks.unbounded &&
"red") ||
"",
width - 1,
0,
width - 1,
height,
1,
);
}
drawStraightLine(ctx, gameState,
(hasCombo && gameState.perks.top_is_lava && 'red') || ''
, gameState.offsetXRoundedDown, 1, width - gameState.offsetXRoundedDown, 1, 1)
drawStraightLine(ctx, gameState,
(hasCombo && gameState.perks.compound_interest && 'red') || (isOptionOn("mobile-mode") && 'white') || ''
, gameState.offsetXRoundedDown, gameState.gameZoneHeight, width - gameState.offsetXRoundedDown, gameState.gameZoneHeight, 1)
drawStraightLine(
ctx,
gameState,
(hasCombo && gameState.perks.top_is_lava && "red") || "",
gameState.offsetXRoundedDown,
1,
width - gameState.offsetXRoundedDown,
1,
1,
);
drawStraightLine(
ctx,
gameState,
(hasCombo && gameState.perks.compound_interest && "red") ||
(isOptionOn("mobile-mode") && "white") ||
"",
gameState.offsetXRoundedDown,
gameState.gameZoneHeight,
width - gameState.offsetXRoundedDown,
gameState.gameZoneHeight,
1,
);
if (isOptionOn("mobile-mode") && !gameState.running) {
drawText(
@ -377,27 +434,36 @@ export function render(gameState: GameState) {
}
}
function drawStraightLine(ctx: CanvasRenderingContext2D, gameState: GameState, mode: 'white' | '' | 'red', x1, y1, x2, y2, alpha = 1) {
ctx.globalAlpha = alpha
if (!mode) return
if (mode == 'red') {
ctx.strokeStyle = 'red'
ctx.lineDashOffset = getDashOffset(gameState)
ctx.lineWidth = 2
ctx.setLineDash(redBorderDash)
function drawStraightLine(
ctx: CanvasRenderingContext2D,
gameState: GameState,
mode: "white" | "" | "red",
x1,
y1,
x2,
y2,
alpha = 1,
) {
ctx.globalAlpha = alpha;
if (!mode) return;
if (mode == "red") {
ctx.strokeStyle = "red";
ctx.lineDashOffset = getDashOffset(gameState);
ctx.lineWidth = 2;
ctx.setLineDash(redBorderDash);
} else {
ctx.strokeStyle = 'white'
ctx.lineWidth = 1
ctx.strokeStyle = "white";
ctx.lineWidth = 1;
}
ctx.beginPath()
ctx.moveTo(x1, y1)
ctx.lineTo(x2, y2)
ctx.stroke()
if (mode == 'red') {
ctx.setLineDash([])
ctx.lineWidth = 1
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
if (mode == "red") {
ctx.setLineDash([]);
ctx.lineWidth = 1;
}
ctx.globalAlpha = 1
ctx.globalAlpha = 1;
}
let cachedBricksRender = document.createElement("canvas");
@ -406,24 +472,30 @@ let cachedBricksRenderKey = "";
export function renderAllBricks() {
ctx.globalAlpha = 1;
const hasCombo=gameState.combo > baseCombo(gameState)
const hasCombo = gameState.combo > baseCombo(gameState);
const redBorderOnBricksWithWrongColor =
hasCombo &&
gameState.perks.picky_eater &&
!isOptionOn("basic");
hasCombo && gameState.perks.picky_eater && !isOptionOn("basic");
const redColorOnAllBricks = !!(gameState.lastPuckMove &&
const redColorOnAllBricks = !!(
gameState.lastPuckMove &&
gameState.perks.passive_income &&
hasCombo &&
gameState.lastPuckMove >
gameState.levelTime - 250 * gameState.perks.passive_income)
gameState.levelTime - 250 * gameState.perks.passive_income
);
let offset = getDashOffset(gameState)
if (!(redBorderOnBricksWithWrongColor || redColorOnAllBricks || gameState.perks.reach || gameState.perks.zen)) {
offset = 0
let offset = getDashOffset(gameState);
if (
!(
redBorderOnBricksWithWrongColor ||
redColorOnAllBricks ||
gameState.perks.reach ||
gameState.perks.zen
)
) {
offset = 0;
}
const clairVoyance =
gameState.perks.clairvoyant && gameState.brickHP.reduce((a, b) => a + b, 0);
@ -441,7 +513,9 @@ export function renderAllBricks() {
"_" +
gameState.perks.pierce_color +
"_" +
clairVoyance + '_' + offset;
clairVoyance +
"_" +
offset;
if (newKey !== cachedBricksRenderKey) {
cachedBricksRenderKey = newKey;
@ -469,8 +543,10 @@ export function renderAllBricks() {
let redBorder =
(gameState.ballsColor !== color &&
color !== "black" &&
redBorderOnBricksWithWrongColor) || (hasCombo && gameState.perks.zen && color==='black')||
redBecauseOfReach || redColorOnAllBricks;
redBorderOnBricksWithWrongColor) ||
(hasCombo && gameState.perks.zen && color === "black") ||
redBecauseOfReach ||
redColorOnAllBricks;
canctx.globalCompositeOperation = "source-over";
drawBrick(canctx, color, x, y, redBorder ? offset : -1);
@ -505,11 +581,19 @@ export function drawPuck(
puckHeight: number,
yOffset = 0,
flipped: boolean,
redBorderOffset: number
redBorderOffset: number,
) {
const key =
"puck" + color + "_" + puckWidth + "_" + puckHeight + "_" + flipped + '_' + redBorderOffset;
"puck" +
color +
"_" +
puckWidth +
"_" +
puckHeight +
"_" +
flipped +
"_" +
redBorderOffset;
if (!cachedGraphics[key]) {
const can = document.createElement("canvas");
@ -518,7 +602,6 @@ export function drawPuck(
const canctx = can.getContext("2d") as CanvasRenderingContext2D;
canctx.fillStyle = color;
canctx.beginPath();
canctx.moveTo(0, puckHeight * 2);
@ -549,11 +632,11 @@ export function drawPuck(
canctx.fill();
if (redBorderOffset !== -1) {
canctx.strokeStyle = 'red'
canctx.lineWidth = 4
canctx.setLineDash(redBorderDash)
canctx.lineDashOffset = redBorderOffset
canctx.stroke()
canctx.strokeStyle = "red";
canctx.lineWidth = 4;
canctx.setLineDash(redBorderDash);
canctx.lineDashOffset = redBorderOffset;
canctx.stroke();
}
cachedGraphics[key] = can;
@ -640,11 +723,11 @@ export function drawCoin(
canctx.fillStyle = color;
canctx.fill();
if(color==='gold' || borderColor==='red'){
if (color === "gold" || borderColor === "red") {
canctx.strokeStyle = borderColor;
if(borderColor=='red'){
canctx.lineWidth=2
canctx.setLineDash(redBorderDash)
if (borderColor == "red") {
canctx.lineWidth = 2;
canctx.setLineDash(redBorderDash);
}
canctx.stroke();
}
@ -724,7 +807,7 @@ export function drawBrick(
const width = brx - tlx,
height = bry - tly;
const key = "brick" + color + "_" + "_" + width + "_" + height + '_' + offset;
const key = "brick" + color + "_" + "_" + width + "_" + height + "_" + offset;
if (!cachedGraphics[key]) {
const can = document.createElement("canvas");
@ -736,9 +819,9 @@ export function drawBrick(
canctx.fillStyle = color;
canctx.setLineDash(offset !== -1 ? redBorderDash : [])
canctx.lineDashOffset = offset
canctx.strokeStyle = offset !== -1 ? 'red' : color;
canctx.setLineDash(offset !== -1 ? redBorderDash : []);
canctx.lineDashOffset = offset;
canctx.strokeStyle = offset !== -1 ? "red" : color;
canctx.lineJoin = "round";
canctx.lineWidth = bord;
roundRect(
@ -846,11 +929,11 @@ export const scoreDisplay = document.getElementById(
) as HTMLButtonElement;
const menuLabel = document.getElementById("menuLabel") as HTMLButtonElement;
const redBorderDash = [5, 5]
const redBorderDash = [5, 5];
export function getDashOffset(gameState: GameState) {
if (isOptionOn("basic")) {
return 0
return 0;
}
return Math.floor((gameState.levelTime % 500) / 500 * 10) % 10
return Math.floor(((gameState.levelTime % 500) / 500) * 10) % 10;
}