mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-24 22:16:14 -04:00
Build 29073274
This commit is contained in:
parent
a8e9fc6cb6
commit
613b7cce58
13 changed files with 2680 additions and 2648 deletions
|
@ -1,5 +1,5 @@
|
|||
// The version of the cache.
|
||||
const VERSION = "29072514";
|
||||
const VERSION = "29073274";
|
||||
|
||||
// The name of the cache
|
||||
const CACHE_NAME = `breakout-71-${VERSION}`;
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
sumOfValues,
|
||||
} from "./game_utils";
|
||||
import { getHistory } from "./gameOver";
|
||||
import {noCreative} from "./upgrades";
|
||||
import { noCreative } from "./upgrades";
|
||||
|
||||
export function creativeMode(gameState: GameState) {
|
||||
return {
|
||||
|
|
|
@ -1412,4 +1412,4 @@
|
|||
"svg": null,
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -1 +1 @@
|
|||
"29072514"
|
||||
"29073274"
|
||||
|
|
71
src/game.ts
71
src/game.ts
|
@ -134,15 +134,15 @@ export function pause(playerAskedForPause: boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
export const fitSize = (gameState:GameState) => {
|
||||
if(!gameState) throw new Error("Missign game state")
|
||||
export const fitSize = (gameState: GameState) => {
|
||||
if (!gameState) throw new Error("Missign game state");
|
||||
const past_off = gameState.offsetXRoundedDown,
|
||||
past_width = gameState.gameZoneWidthRoundedUp,
|
||||
past_heigh = gameState.gameZoneHeight;
|
||||
|
||||
const width= window.innerWidth, height=window.innerHeight
|
||||
const width = window.innerWidth,
|
||||
height = window.innerHeight;
|
||||
|
||||
console.log('fitSize',width, height)
|
||||
gameState.canvasWidth = width;
|
||||
gameState.canvasHeight = height;
|
||||
gameCanvas.width = width;
|
||||
|
@ -153,21 +153,36 @@ export const fitSize = (gameState:GameState) => {
|
|||
haloCanvas.height = height / haloScale;
|
||||
|
||||
gameState.gameZoneHeight = isOptionOn("mobile-mode")
|
||||
? Math.floor(height * .80) : height;
|
||||
? Math.floor(height * 0.8)
|
||||
: height;
|
||||
|
||||
const baseWidth = Math.round(
|
||||
Math.min(gameState.canvasWidth , gameState.gameZoneHeight * (0.73 )* (gameState.gridSize+gameState.perks.unbounded*2 ) / gameState.gridSize),
|
||||
Math.min(
|
||||
gameState.canvasWidth,
|
||||
(gameState.gameZoneHeight *
|
||||
0.73 *
|
||||
(gameState.gridSize + gameState.perks.unbounded * 2)) /
|
||||
gameState.gridSize,
|
||||
),
|
||||
);
|
||||
|
||||
gameState.brickWidth = Math.floor(baseWidth / (gameState.gridSize+gameState.perks.unbounded*2) / 2) * 2;
|
||||
gameState.brickWidth =
|
||||
Math.floor(
|
||||
baseWidth / (gameState.gridSize + gameState.perks.unbounded * 2) / 2,
|
||||
) * 2;
|
||||
|
||||
gameState.gameZoneWidth = gameState.brickWidth * gameState.gridSize;
|
||||
gameState.offsetX = Math.floor(
|
||||
(gameState.canvasWidth - gameState.gameZoneWidth) / 2,
|
||||
);
|
||||
// Space between left side and border
|
||||
gameState.offsetXRoundedDown = gameState.offsetX - gameState.perks.unbounded*gameState.brickWidth;
|
||||
if (gameState.offsetX < gameState.ballSize+gameState.perks.unbounded*2*gameState.brickWidth) gameState.offsetXRoundedDown = 0;
|
||||
gameState.offsetXRoundedDown =
|
||||
gameState.offsetX - gameState.perks.unbounded * gameState.brickWidth;
|
||||
if (
|
||||
gameState.offsetX <
|
||||
gameState.ballSize + gameState.perks.unbounded * 2 * gameState.brickWidth
|
||||
)
|
||||
gameState.offsetXRoundedDown = 0;
|
||||
gameState.gameZoneWidthRoundedUp = width - 2 * gameState.offsetXRoundedDown;
|
||||
backgroundCanvas.title = "resized";
|
||||
// Ensure puck stays within bounds
|
||||
|
@ -201,8 +216,8 @@ export const fitSize = (gameState:GameState) => {
|
|||
`${window.innerHeight * 0.01}px`,
|
||||
);
|
||||
};
|
||||
window.addEventListener("resize", ()=>fitSize(gameState));
|
||||
window.addEventListener("fullscreenchange", ()=>fitSize(gameState));
|
||||
window.addEventListener("resize", () => fitSize(gameState));
|
||||
window.addEventListener("fullscreenchange", () => fitSize(gameState));
|
||||
|
||||
setInterval(() => {
|
||||
// Sometimes, the page changes size without triggering the event (when switching to fullscreen, closing debug panel...)
|
||||
|
@ -417,8 +432,8 @@ export function tick() {
|
|||
normalizeGameState(gameState);
|
||||
|
||||
if (gameState.running) {
|
||||
gameState.levelTime += timeDeltaMs*frames;
|
||||
gameState.runStatistics.runTime += timeDeltaMs*frames;
|
||||
gameState.levelTime += timeDeltaMs * frames;
|
||||
gameState.runStatistics.runTime += timeDeltaMs * frames;
|
||||
gameStateTick(gameState, frames);
|
||||
}
|
||||
if (gameState.running || gameState.needsRender) {
|
||||
|
@ -717,10 +732,7 @@ async function openSettingsMenu() {
|
|||
} catch (e: any) {
|
||||
await asyncAlert({
|
||||
title: t("settings.save_file_error"),
|
||||
content: [
|
||||
e.message,
|
||||
{ text: t("settings.save_file_loaded_ok") },
|
||||
],
|
||||
content: [e.message, { text: t("settings.save_file_loaded_ok") }],
|
||||
});
|
||||
}
|
||||
input.value = "";
|
||||
|
@ -986,17 +998,20 @@ export function restart(params: RunParams) {
|
|||
setLevel(gameState, 0);
|
||||
}
|
||||
|
||||
restart(window.location.search.includes('stress')?{
|
||||
|
||||
perks:{
|
||||
bricks_attract_ball:2,
|
||||
superhot:1,
|
||||
bricks_attract_coins:3,
|
||||
hot_start:3,
|
||||
pierce:3,
|
||||
rainbow:3
|
||||
}
|
||||
}:{});
|
||||
restart(
|
||||
window.location.search.includes("stress")
|
||||
? {
|
||||
perks: {
|
||||
bricks_attract_ball: 2,
|
||||
superhot: 1,
|
||||
bricks_attract_coins: 3,
|
||||
hot_start: 3,
|
||||
pierce: 3,
|
||||
rainbow: 3,
|
||||
},
|
||||
}
|
||||
: {},
|
||||
);
|
||||
|
||||
tick();
|
||||
setupTooltips();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -69,7 +69,7 @@ export function getNearestUnlockHTML(gameState: GameState) {
|
|||
});
|
||||
|
||||
if (!firstUnlockable) return "";
|
||||
let missingPoints = Math.max(0,firstUnlockable.minScore - gameState.score);
|
||||
let missingPoints = Math.max(0, firstUnlockable.minScore - gameState.score);
|
||||
let missingUpgrades = firstUnlockable.missing.map((u) => u.name).join(", ");
|
||||
|
||||
const title =
|
||||
|
|
|
@ -329,9 +329,9 @@ export function render(gameState: GameState) {
|
|||
ctx.fillStyle = gameState.puckColor;
|
||||
for (let i = 0; i < gameState.perks.extra_life; i++) {
|
||||
ctx.fillRect(
|
||||
gameState.offsetXRoundedDown,
|
||||
gameState.offsetXRoundedDown,
|
||||
gameState.gameZoneHeight - gameState.puckHeight / 2 + 2 * i,
|
||||
gameState.gameZoneWidthRoundedUp,
|
||||
gameState.gameZoneWidthRoundedUp,
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
@ -444,18 +444,14 @@ export function render(gameState: GameState) {
|
|||
// Borders
|
||||
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
let redLeftSide =
|
||||
hasCombo &&
|
||||
(gameState.perks.left_is_lava || gameState.perks.trampoline);
|
||||
hasCombo && (gameState.perks.left_is_lava || gameState.perks.trampoline);
|
||||
let redRightSide =
|
||||
hasCombo &&
|
||||
(gameState.perks.right_is_lava || gameState.perks.trampoline);
|
||||
hasCombo && (gameState.perks.right_is_lava || gameState.perks.trampoline);
|
||||
let redTop =
|
||||
hasCombo &&
|
||||
(gameState.perks.top_is_lava || gameState.perks.trampoline);
|
||||
|
||||
hasCombo && (gameState.perks.top_is_lava || gameState.perks.trampoline);
|
||||
|
||||
if (gameState.offsetXRoundedDown) {
|
||||
// draw outside of gaming area to avoid capturing borders in recordings
|
||||
|
@ -466,7 +462,8 @@ export function render(gameState: GameState) {
|
|||
gameState.offsetXRoundedDown - 1,
|
||||
0,
|
||||
gameState.offsetXRoundedDown - 1,
|
||||
height, 1,
|
||||
height,
|
||||
1,
|
||||
);
|
||||
|
||||
drawStraightLine(
|
||||
|
@ -477,7 +474,7 @@ export function render(gameState: GameState) {
|
|||
0,
|
||||
width - gameState.offsetXRoundedDown + 1,
|
||||
height,
|
||||
1,
|
||||
1,
|
||||
);
|
||||
} else {
|
||||
drawStraightLine(
|
||||
|
@ -507,9 +504,9 @@ export function render(gameState: GameState) {
|
|||
ctx,
|
||||
gameState,
|
||||
"#FF0000",
|
||||
gameState.offsetXRoundedDown,
|
||||
gameState.offsetXRoundedDown,
|
||||
1,
|
||||
width - gameState.offsetXRoundedDown,
|
||||
width - gameState.offsetXRoundedDown,
|
||||
1,
|
||||
1,
|
||||
);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { t } from "./i18n/i18n";
|
|||
import { icons, upgrades } from "./loadGameData";
|
||||
import { getSettingValue, getTotalScore, setSettingValue } from "./settings";
|
||||
import { isOptionOn } from "./options";
|
||||
import {notStartingPerk} from "./upgrades";
|
||||
import { notStartingPerk } from "./upgrades";
|
||||
|
||||
export function startingPerkMenuButton() {
|
||||
return {
|
||||
|
@ -20,15 +20,14 @@ export function startingPerkMenuButton() {
|
|||
|
||||
export function isBlackListedForStart(u: Upgrade) {
|
||||
return !!(
|
||||
notStartingPerk.includes(u.id) ||
|
||||
notStartingPerk.includes(u.id) ||
|
||||
u.requires ||
|
||||
u.threshold > getTotalScore()
|
||||
);
|
||||
}
|
||||
export function isStartingPerk(u: Upgrade): boolean {
|
||||
return (
|
||||
!isBlackListedForStart(u) &&
|
||||
getSettingValue("start_with_" + u.id, u.gift)
|
||||
!isBlackListedForStart(u) && getSettingValue("start_with_" + u.id, u.gift)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
1638
src/upgrades.ts
1638
src/upgrades.ts
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue