Build and deploy of version 29028296

This commit is contained in:
Renan LE CARO 2025-03-11 13:56:42 +01:00
parent a136475f88
commit 8b1278cb55
8 changed files with 325 additions and 3926 deletions

View file

@ -11,8 +11,8 @@ android {
applicationId = "me.lecaro.breakout" applicationId = "me.lecaro.breakout"
minSdk = 21 minSdk = 21
targetSdk = 34 targetSdk = 34
versionCode = 29022953 versionCode = 29028296
versionName = "29022953" versionName = "29028296"
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

3807
dist/index.html vendored

File diff suppressed because one or more lines are too long

View file

@ -17,14 +17,15 @@ import { OptionId, options} from "./options";
const MAX_COINS = 400; const MAX_COINS = 400;
const MAX_PARTICLES = 600; const MAX_PARTICLES = 600;
export const gameCanvas = document.getElementById("game") as HTMLCanvasElement; export const gameCanvas = document.getElementById("game") as HTMLCanvasElement;
const ctx = gameCanvas.getContext("2d", { alpha: false }) as CanvasRenderingContext2D; const ctx = gameCanvas.getContext("2d", {
alpha: false,
}) as CanvasRenderingContext2D;
const puckColor = "#FFF"; const puckColor = "#FFF";
let ballSize = 20; let ballSize = 20;
const coinSize = Math.round(ballSize * 0.8); const coinSize = Math.round(ballSize * 0.8);
const puckHeight = ballSize; const puckHeight = ballSize;
let runLevels: Level[] = []; let runLevels: Level[] = [];
let currentLevel = 0; let currentLevel = 0;
@ -40,10 +41,10 @@ bombSVG.src =
let puckWidth = 200; let puckWidth = 200;
const makeEmptyPerksMap = () => { const makeEmptyPerksMap = () => {
const p = {} as any const p = {} as any;
upgrades.forEach(u=>p[u.id]=0) upgrades.forEach((u) => (p[u.id] = 0));
return p as PerksMap return p as PerksMap;
} };
const perks: PerksMap = makeEmptyPerksMap(); const perks: PerksMap = makeEmptyPerksMap();
@ -166,8 +167,12 @@ background.addEventListener("load", () => {
needsRender = true; needsRender = true;
}); });
let lastWidth = 0,
lastHeight = 0;
export const fitSize = () => { export const fitSize = () => {
const { width, height } = gameCanvas.getBoundingClientRect(); const { width, height } = gameCanvas.getBoundingClientRect();
lastWidth = width;
lastHeight = height;
gameCanvas.width = width; gameCanvas.width = width;
gameCanvas.height = height; gameCanvas.height = height;
ctx.fillStyle = currentLevelInfo()?.color || "black"; ctx.fillStyle = currentLevelInfo()?.color || "black";
@ -177,12 +182,10 @@ export const fitSize = () => {
backgroundCanvas.height = height; backgroundCanvas.height = height;
gameZoneHeight = isSettingOn("mobile-mode") ? (height * 80) / 100 : height; gameZoneHeight = isSettingOn("mobile-mode") ? (height * 80) / 100 : height;
const baseWidth = Math.round( const baseWidth = Math.round(Math.min(lastWidth, gameZoneHeight * 0.73));
Math.min(gameCanvas.width, gameZoneHeight * 0.73),
);
brickWidth = Math.floor(baseWidth / gridSize / 2) * 2; brickWidth = Math.floor(baseWidth / gridSize / 2) * 2;
gameZoneWidth = brickWidth * gridSize; gameZoneWidth = brickWidth * gridSize;
offsetX = Math.floor((gameCanvas.width - gameZoneWidth) / 2); offsetX = Math.floor((lastWidth - gameZoneWidth) / 2);
offsetXRoundedDown = offsetX; offsetXRoundedDown = offsetX;
if (offsetX < ballSize) offsetXRoundedDown = 0; if (offsetX < ballSize) offsetXRoundedDown = 0;
gameZoneWidthRoundedUp = width - 2 * offsetXRoundedDown; gameZoneWidthRoundedUp = width - 2 * offsetXRoundedDown;
@ -202,6 +205,12 @@ export const fitSize = () => {
window.addEventListener("resize", fitSize); window.addEventListener("resize", fitSize);
window.addEventListener("fullscreenchange", fitSize); window.addEventListener("fullscreenchange", fitSize);
setInterval(() => {
// Sometimes, the page changes size without triggering the event (when switching to fullscreen, closing debug panel..)
const { width, height } = gameCanvas.getBoundingClientRect();
if (width !== lastWidth || height !== lastHeight) fitSize();
}, 1000);
function recomputeTargetBaseSpeed() { function recomputeTargetBaseSpeed() {
// We never want the ball to completely stop, it will move at least 3px per frame // We never want the ball to completely stop, it will move at least 3px per frame
baseSpeed = Math.max( baseSpeed = Math.max(
@ -280,7 +289,7 @@ function addToScore(coin: Coin) {
color: coin.color, color: coin.color,
x: coin.previousX, x: coin.previousX,
y: coin.previousY, y: coin.previousY,
vx: (gameCanvas.width - coin.x) / 100, vx: (lastWidth - coin.x) / 100,
vy: -coin.y / 100, vy: -coin.y / 100,
ethereal: true, ethereal: true,
}); });
@ -306,7 +315,7 @@ function resetBalls() {
} }
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const x = puck - puckWidth / 2 + perBall * (i + 1); const x = puck - puckWidth / 2 + perBall * (i + 1);
const vx=Math.random() > 0.5 ? baseSpeed : -baseSpeed const vx = Math.random() > 0.5 ? baseSpeed : -baseSpeed;
balls.push({ balls.push({
x, x,
@ -341,9 +350,9 @@ function putBallsAtPuck() {
ball.y = gameZoneHeight - 1.5 * ballSize; ball.y = gameZoneHeight - 1.5 * ballSize;
ball.previousY = ball.y; ball.previousY = ball.y;
ball.vx = Math.random() > 0.5 ? baseSpeed : -baseSpeed; ball.vx = Math.random() > 0.5 ? baseSpeed : -baseSpeed;
ball.previousVX=ball.vx ball.previousVX = ball.vx;
ball.vy = -baseSpeed; ball.vy = -baseSpeed;
ball.previousVY=ball.vy ball.previousVY = ball.vy;
ball.sx = 0; ball.sx = 0;
ball.sy = 0; ball.sy = 0;
ball.hitItem = []; ball.hitItem = [];
@ -486,6 +495,7 @@ function getPossibleUpgrades() {
function shuffleLevels(nameToAvoid: string | null = null) { function shuffleLevels(nameToAvoid: string | null = null) {
const target = nextRunOverrides?.level; const target = nextRunOverrides?.level;
delete nextRunOverrides.level;
const firstLevel = nextRunOverrides?.level const firstLevel = nextRunOverrides?.level
? allLevels.filter((l) => l.name === target) ? allLevels.filter((l) => l.name === target)
: []; : [];
@ -502,7 +512,7 @@ function shuffleLevels(nameToAvoid :string|null= null) {
} }
function getUpgraderUnlockPoints() { function getUpgraderUnlockPoints() {
let list = [] as {threshold:number,title:string}[]; let list = [] as { threshold: number; title: string }[];
upgrades.forEach((u) => { upgrades.forEach((u) => {
if (u.threshold) { if (u.threshold) {
@ -803,8 +813,8 @@ function bordersHitCheck(coin: Coin | Ball, radius: number, delta: number) {
coin.vy *= -1; coin.vy *= -1;
vhit = 1; vhit = 1;
} }
if (coin.x > gameCanvas.width - offsetXRoundedDown - radius) { if (coin.x > lastWidth - offsetXRoundedDown - radius) {
coin.x = gameCanvas.width - offsetXRoundedDown - radius; coin.x = lastWidth - offsetXRoundedDown - radius;
coin.vx *= -1; coin.vx *= -1;
hhit = 1; hhit = 1;
} }
@ -902,7 +912,7 @@ function tick() {
puckHeight puckHeight
) { ) {
addToScore(coin); addToScore(coin);
} else if (coin.y > gameCanvas.height + coinRadius) { } else if (coin.y > lastHeight + coinRadius) {
coin.destroyed = true; coin.destroyed = true;
if (perks.compound_interest) { if (perks.compound_interest) {
resetCombo(coin.x, coin.y); resetCombo(coin.x, coin.y);
@ -1761,14 +1771,14 @@ function render() {
if (level.svg && background.width && background.complete) { if (level.svg && background.width && background.complete) {
if (backgroundCanvas.title !== level.name) { if (backgroundCanvas.title !== level.name) {
backgroundCanvas.title = level.name; backgroundCanvas.title = level.name;
backgroundCanvas.width = gameCanvas.width; backgroundCanvas.width = lastWidth;
backgroundCanvas.height = gameCanvas.height; backgroundCanvas.height = lastHeight;
const bgctx = backgroundCanvas.getContext( const bgctx = backgroundCanvas.getContext(
"2d", "2d",
) as CanvasRenderingContext2D; ) as CanvasRenderingContext2D;
bgctx.fillStyle = level.color || "#000"; bgctx.fillStyle = level.color || "#000";
bgctx.fillRect(0, 0, gameCanvas.width, gameCanvas.height); bgctx.fillRect(0, 0, lastWidth, lastHeight);
const pattern=ctx.createPattern(background, "repeat") const pattern = ctx.createPattern(background, "repeat");
if (pattern) { if (pattern) {
bgctx.fillStyle = pattern; bgctx.fillStyle = pattern;
bgctx.fillRect(0, 0, width, height); bgctx.fillRect(0, 0, width, height);
@ -1940,8 +1950,8 @@ function render() {
"Press and hold here to play", "Press and hold here to play",
puckColor, puckColor,
puckHeight, puckHeight,
gameCanvas.width / 2, lastWidth / 2,
gameZoneHeight + (gameCanvas.height - gameZoneHeight) / 2, gameZoneHeight + (lastHeight - gameZoneHeight) / 2,
); );
} }
} else if (redBottom) { } else if (redBottom) {
@ -1961,7 +1971,7 @@ function render() {
} }
let cachedBricksRender = document.createElement("canvas"); let cachedBricksRender = document.createElement("canvas");
let cachedBricksRenderKey = ''; let cachedBricksRenderKey = "";
function renderAllBricks() { function renderAllBricks() {
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
@ -2569,7 +2579,8 @@ type AsyncAlertAction<t> = {
disabled?: boolean; disabled?: boolean;
icon?: string; icon?: string;
className?: string; className?: string;
} };
function asyncAlert<t>({ function asyncAlert<t>({
title, title,
text, text,
@ -2684,7 +2695,7 @@ let cachedSettings : Partial<{[key in OptionId]:boolean}>= {};
export function isSettingOn(key: OptionId) { export function isSettingOn(key: OptionId) {
if (typeof cachedSettings[key] == "undefined") { if (typeof cachedSettings[key] == "undefined") {
try { try {
const ls=localStorage.getItem("breakout-settings-enable-" + key) const ls = localStorage.getItem("breakout-settings-enable-" + key);
if (ls) cachedSettings[key] = JSON.parse(ls) as boolean; if (ls) cachedSettings[key] = JSON.parse(ls) as boolean;
} catch (e) { } catch (e) {
console.warn(e); console.warn(e);
@ -2749,7 +2760,8 @@ document.getElementById("menu")?.addEventListener("click", (e) => {
async function openSettingsPanel() { async function openSettingsPanel() {
pause(true); pause(true);
const actions :AsyncAlertAction<()=>void>[]= [{ const actions: AsyncAlertAction<() => void>[] = [
{
text: "Resume", text: "Resume",
help: "Return to your run", help: "Return to your run",
value() {}, value() {},
@ -2760,7 +2772,8 @@ async function openSettingsPanel() {
value() { value() {
openUnlocksList(); openUnlocksList();
}, },
}]; },
];
for (const key of Object.keys(options) as OptionId[]) { for (const key of Object.keys(options) as OptionId[]) {
if (options[key]) if (options[key])
@ -2788,7 +2801,7 @@ async function openSettingsPanel() {
value() { value() {
toggleFullScreen(); toggleFullScreen();
}, },
} ) });
} else { } else {
actions.push({ actions.push({
icon: icons["icon:fullscreen"], icon: icons["icon:fullscreen"],
@ -2796,8 +2809,8 @@ async function openSettingsPanel() {
help: "Might not work on some machines", help: "Might not work on some machines",
value() { value() {
toggleFullScreen(); toggleFullScreen();
} },
}) });
} }
} }
actions.push({ actions.push({
@ -2842,7 +2855,7 @@ async function openSettingsPanel() {
} }
} }
}, },
}) });
actions.push({ actions.push({
text: "Reset Game", text: "Reset Game",
help: "Erase high score and statistics", help: "Erase high score and statistics",
@ -2867,8 +2880,7 @@ async function openSettingsPanel() {
window.location.reload(); window.location.reload();
} }
}, },
}) });
const cb = await asyncAlert<() => void>({ const cb = await asyncAlert<() => void>({
title: "Breakout 71", title: "Breakout 71",
@ -2990,7 +3002,11 @@ function repulse(a: Ball, b: BallLike, power: number, impactsBToo: boolean) {
(((-power * (max - distance)) / (max * 1.2) / 3) * (((-power * (max - distance)) / (max * 1.2) / 3) *
Math.min(500, levelTime)) / Math.min(500, levelTime)) /
500; 500;
if (impactsBToo && typeof b.vx !== 'undefined' && typeof b.vy !== 'undefined') { if (
impactsBToo &&
typeof b.vx !== "undefined" &&
typeof b.vy !== "undefined"
) {
b.vx += dx * fact; b.vx += dx * fact;
b.vy += dy * fact; b.vy += dy * fact;
} }
@ -3011,7 +3027,11 @@ function repulse(a: Ball, b: BallLike, power: number, impactsBToo: boolean) {
vx: -dx * speed + a.vx + (Math.random() - 0.5) * rand, vx: -dx * speed + a.vx + (Math.random() - 0.5) * rand,
vy: -dy * speed + a.vy + (Math.random() - 0.5) * rand, vy: -dy * speed + a.vy + (Math.random() - 0.5) * rand,
}); });
if (impactsBToo&& typeof b.vx !== 'undefined' && typeof b.vy !== 'undefined') { if (
impactsBToo &&
typeof b.vx !== "undefined" &&
typeof b.vy !== "undefined"
) {
flashes.push({ flashes.push({
type: "particle", type: "particle",
duration: 100, duration: 100,

View file

@ -73,7 +73,10 @@ export const icons = {} as {[k:string]:string};
export const allLevels = rawLevelsList export const allLevels = rawLevelsList
.map((level) => { .map((level) => {
const bricks = level.bricks.split("").map((c) => palette[c]); const bricks = level.bricks
.split("")
.map((c) => palette[c])
.slice(0, level.size * level.size);
const icon = levelIconHTML(bricks, level.size, level.name, level.color); const icon = levelIconHTML(bricks, level.size, level.name, level.color);
icons[level.name] = icon; icons[level.name] = icon;
let svg = level.svg; let svg = level.svg;
@ -91,16 +94,15 @@ export const allLevels = rawLevelsList
.filter((l) => !l.name.startsWith("icon:")) .filter((l) => !l.name.startsWith("icon:"))
.map((l, li) => ({ .map((l, li) => ({
...l, ...l,
threshold:li < 8 threshold:
li < 8
? 0 ? 0
: Math.round( : Math.round(
Math.min(Math.pow(10, 1 + (li + l.size) / 30) * 10, 5000) * li, Math.min(Math.pow(10, 1 + (li + l.size) / 30) * 10, 5000) * li,
), ),
sortKey:((Math.random() + 3) / 3.5) * l.bricks.filter((i) => i).length sortKey: ((Math.random() + 3) / 3.5) * l.bricks.filter((i) => i).length,
})) as Level[]; })) as Level[];
export const upgrades = rawUpgrades.map((u) => ({ export const upgrades = rawUpgrades.map((u) => ({
...u, ...u,
icon: icons["icon:" + u.id], icon: icons["icon:" + u.id],

11
src/types.d.ts vendored
View file

@ -111,23 +111,22 @@ interface BaseFlash {
y: number; y: number;
} }
interface ParticleFlash extends BaseFlash { interface ParticleFlash extends BaseFlash {
type: 'particle'; type: "particle";
vx: number; vx: number;
vy: number; vy: number;
ethereal: boolean; ethereal: boolean;
} }
interface TextFlash extends BaseFlash { interface TextFlash extends BaseFlash {
type:'text'; type: "text";
text: string; text: string;
} }
interface BallFlash extends BaseFlash { interface BallFlash extends BaseFlash {
type:'ball'; type: "ball";
} }
export type Flash = ParticleFlash|TextFlash|BallFlash export type Flash = ParticleFlash | TextFlash | BallFlash;
export type RunStats = { export type RunStats = {
started: number; started: number;
@ -148,8 +147,6 @@ export type PerksMap = {
[k in PerkId]: number; [k in PerkId]: number;
}; };
export type RunHistoryItem = RunStats & { export type RunHistoryItem = RunStats & {
perks?: PerksMap; perks?: PerksMap;
appVersion?: string; appVersion?: string;

View file

@ -1 +1 @@
"29022953" "29028296"