mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 20:16:16 -04:00
Build 29040298
This commit is contained in:
parent
dce41a43ec
commit
d2266de792
13 changed files with 2155 additions and 2103 deletions
|
@ -11,8 +11,8 @@ android {
|
|||
applicationId = "me.lecaro.breakout"
|
||||
minSdk = 21
|
||||
targetSdk = 34
|
||||
versionCode = 29040074
|
||||
versionName = "29040074"
|
||||
versionCode = 29040298
|
||||
versionName = "29040298"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
|
|
File diff suppressed because one or more lines are too long
6
dist/index.html
vendored
6
dist/index.html
vendored
|
@ -1270,7 +1270,7 @@ const upgrades = (0, _upgrades.rawUpgrades).map((u)=>({
|
|||
}));
|
||||
|
||||
},{"./data/palette.json":"ktRBU","./data/levels.json":"8JSUc","./data/version.json":"iyP6E","./getLevelBackground":"7OIPf","./levelIcon":"6rQoT","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3","./upgrades":"1u3Dx"}],"iyP6E":[function(require,module,exports,__globalThis) {
|
||||
module.exports = JSON.parse("\"29040074\"");
|
||||
module.exports = JSON.parse("\"29040298\"");
|
||||
|
||||
},{}],"6rQoT":[function(require,module,exports,__globalThis) {
|
||||
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||||
|
@ -2402,7 +2402,7 @@ function spawnExplosion(gameState, count, x, y, color) {
|
|||
for(let i = 0; i < count; i++)makeParticle(gameState, x + (Math.random() - 0.5) * gameState.brickWidth / 2, y + (Math.random() - 0.5) * gameState.brickWidth / 2, (Math.random() - 0.5) * 30, (Math.random() - 0.5) * 30, color, false);
|
||||
}
|
||||
function explosionAt(gameState, index, x, y, ball) {
|
||||
if (gameState.bricks[index] == 'black') delete gameState.bricks[index];
|
||||
if (gameState.bricks[index] == "black") delete gameState.bricks[index];
|
||||
schedulGameSound(gameState, "explode", ball.x, 1);
|
||||
const col = index % gameState.gridSize;
|
||||
const row = Math.floor(index / gameState.gridSize);
|
||||
|
@ -2710,7 +2710,7 @@ frames = 1) {
|
|||
if (!gameState.perks.etherealcoins) {
|
||||
const flip = gameState.perks.helium > 0 && Math.abs(coin.x - gameState.puckPosition) * 2 > gameState.puckWidth + coin.size;
|
||||
coin.vy += frames * coin.weight * 0.8 * (flip ? -1 : 1);
|
||||
if (flip && !(0, _options.isOptionOn)('basic') && Math.random() < 0.1) makeParticle(gameState, coin.x, coin.y, 0, gameState.baseSpeed, rainbowColor(), true, 5, 250);
|
||||
if (flip && !(0, _options.isOptionOn)("basic") && Math.random() < 0.1) makeParticle(gameState, coin.x, coin.y, 0, gameState.baseSpeed, rainbowColor(), true, 5, 250);
|
||||
}
|
||||
const speed = Math.abs(coin.sx) + Math.abs(coin.sx);
|
||||
const hitBorder = bordersHitCheck(gameState, coin, coin.size / 2, frames);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// The version of the cache.
|
||||
const VERSION = "29040074";
|
||||
const VERSION = "29040298";
|
||||
|
||||
// The name of the cache
|
||||
const CACHE_NAME = `breakout-71-${VERSION}`;
|
||||
|
|
|
@ -1 +1 @@
|
|||
"29040074"
|
||||
"29040298"
|
||||
|
|
55
src/game.ts
55
src/game.ts
|
@ -1,4 +1,4 @@
|
|||
import {allLevels, appVersion, icons, upgrades} from "./loadGameData";
|
||||
import { allLevels, appVersion, icons, upgrades } from "./loadGameData";
|
||||
import {
|
||||
Ball,
|
||||
Coin,
|
||||
|
@ -11,12 +11,17 @@ import {
|
|||
TextFlash,
|
||||
Upgrade,
|
||||
} from "./types";
|
||||
import {getAudioContext, playPendingSounds} from "./sounds";
|
||||
import {currentLevelInfo, getRowColIndex, max_levels, pickedUpgradesHTMl,} from "./game_utils";
|
||||
import { getAudioContext, playPendingSounds } from "./sounds";
|
||||
import {
|
||||
currentLevelInfo,
|
||||
getRowColIndex,
|
||||
max_levels,
|
||||
pickedUpgradesHTMl,
|
||||
} from "./game_utils";
|
||||
|
||||
import "./PWA/sw_loader";
|
||||
import {getCurrentLang, t} from "./i18n/i18n";
|
||||
import {getSettingValue, getTotalScore, setSettingValue} from "./settings";
|
||||
import { getCurrentLang, t } from "./i18n/i18n";
|
||||
import { getSettingValue, getTotalScore, setSettingValue } from "./settings";
|
||||
import {
|
||||
forEachLiveOne,
|
||||
gameStateTick,
|
||||
|
@ -25,12 +30,28 @@ import {
|
|||
setLevel,
|
||||
setMousePos,
|
||||
} from "./gameStateMutators";
|
||||
import {backgroundCanvas, ctx, gameCanvas, render, scoreDisplay,} from "./render";
|
||||
import {pauseRecording, recordOneFrame, resumeRecording, startRecordingGame,} from "./recording";
|
||||
import {newGameState} from "./newGameState";
|
||||
import {alertsOpen, asyncAlert, AsyncAlertAction, closeModal,} from "./asyncAlert";
|
||||
import {isOptionOn, options, toggleOption} from "./options";
|
||||
import {hashCode} from "./getLevelBackground";
|
||||
import {
|
||||
backgroundCanvas,
|
||||
ctx,
|
||||
gameCanvas,
|
||||
render,
|
||||
scoreDisplay,
|
||||
} from "./render";
|
||||
import {
|
||||
pauseRecording,
|
||||
recordOneFrame,
|
||||
resumeRecording,
|
||||
startRecordingGame,
|
||||
} from "./recording";
|
||||
import { newGameState } from "./newGameState";
|
||||
import {
|
||||
alertsOpen,
|
||||
asyncAlert,
|
||||
AsyncAlertAction,
|
||||
closeModal,
|
||||
} from "./asyncAlert";
|
||||
import { isOptionOn, options, toggleOption } from "./options";
|
||||
import { hashCode } from "./getLevelBackground";
|
||||
|
||||
export function play() {
|
||||
if (gameState.running) return;
|
||||
|
@ -406,8 +427,7 @@ async function openScorePanel() {
|
|||
async function openSettingsPanel() {
|
||||
pause(true);
|
||||
|
||||
const actions: AsyncAlertAction<() => void>[] = [
|
||||
];
|
||||
const actions: AsyncAlertAction<() => void>[] = [];
|
||||
|
||||
for (const key of Object.keys(options) as OptionId[]) {
|
||||
if (options[key])
|
||||
|
@ -449,21 +469,18 @@ async function openSettingsPanel() {
|
|||
});
|
||||
}
|
||||
}
|
||||
actions.push(
|
||||
{
|
||||
actions.push({
|
||||
text: t("main_menu.resume"),
|
||||
help: t("main_menu.resume_help"),
|
||||
value() {},
|
||||
})
|
||||
});
|
||||
actions.push({
|
||||
text: t("main_menu.unlocks"),
|
||||
help: t("main_menu.unlocks_help"),
|
||||
value() {
|
||||
openUnlocksList();
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
|
||||
actions.push({
|
||||
text: t("sandbox.title"),
|
||||
|
|
|
@ -23,18 +23,27 @@ import {
|
|||
getRowColIndex,
|
||||
isTelekinesisActive,
|
||||
isYoyoActive,
|
||||
max_levels, sample,
|
||||
max_levels,
|
||||
sample,
|
||||
shouldPierceByColor,
|
||||
} from "./game_utils";
|
||||
import {t} from "./i18n/i18n";
|
||||
import {icons} from "./loadGameData";
|
||||
import { t } from "./i18n/i18n";
|
||||
import { icons } from "./loadGameData";
|
||||
|
||||
import {addToTotalScore} from "./settings";
|
||||
import {background} from "./render";
|
||||
import {gameOver} from "./gameOver";
|
||||
import {brickIndex, fitSize, gameState, hasBrick, hitsSomething, openUpgradesPicker, pause,} from "./game";
|
||||
import {stopRecording} from "./recording";
|
||||
import {isOptionOn} from "./options";
|
||||
import { addToTotalScore } from "./settings";
|
||||
import { background } from "./render";
|
||||
import { gameOver } from "./gameOver";
|
||||
import {
|
||||
brickIndex,
|
||||
fitSize,
|
||||
gameState,
|
||||
hasBrick,
|
||||
hitsSomething,
|
||||
openUpgradesPicker,
|
||||
pause,
|
||||
} from "./game";
|
||||
import { stopRecording } from "./recording";
|
||||
import { isOptionOn } from "./options";
|
||||
|
||||
export function setMousePos(gameState: GameState, x: number) {
|
||||
// Sets the puck position, and updates the ball position if they are supposed to follow it
|
||||
|
@ -227,12 +236,11 @@ export function spawnExplosion(
|
|||
export function explosionAt(
|
||||
gameState: GameState,
|
||||
index: number,
|
||||
x: number, y: number,
|
||||
ball: Ball) {
|
||||
|
||||
if(gameState.bricks[index]=='black')
|
||||
delete gameState.bricks[index];
|
||||
|
||||
x: number,
|
||||
y: number,
|
||||
ball: Ball,
|
||||
) {
|
||||
if (gameState.bricks[index] == "black") delete gameState.bricks[index];
|
||||
|
||||
schedulGameSound(gameState, "explode", ball.x, 1);
|
||||
|
||||
|
@ -276,8 +284,8 @@ export function explosionAt(
|
|||
);
|
||||
gameState.runStatistics.bricks_broken++;
|
||||
|
||||
if(gameState.perks.zen){
|
||||
resetCombo(gameState, x,y)
|
||||
if (gameState.perks.zen) {
|
||||
resetCombo(gameState, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,10 +301,7 @@ export function explodeBrick(
|
|||
if (color === "black") {
|
||||
const x = brickCenterX(gameState, index),
|
||||
y = brickCenterY(gameState, index);
|
||||
explosionAt(gameState,
|
||||
index, x, y,
|
||||
ball)
|
||||
|
||||
explosionAt(gameState, index, x, y, ball);
|
||||
} else if (color) {
|
||||
// Even if it bounces we don't want to count that as a miss
|
||||
|
||||
|
@ -328,7 +333,7 @@ export function explodeBrick(
|
|||
while (coinsToSpawn > 0) {
|
||||
const points = Math.min(pointsPerCoin, coinsToSpawn);
|
||||
if (points < 0 || isNaN(points)) {
|
||||
console.error({points});
|
||||
console.error({ points });
|
||||
debugger;
|
||||
}
|
||||
|
||||
|
@ -351,7 +356,8 @@ export function explodeBrick(
|
|||
);
|
||||
}
|
||||
|
||||
gameState.combo += gameState.perks.streak_shots +
|
||||
gameState.combo +=
|
||||
gameState.perks.streak_shots +
|
||||
gameState.perks.compound_interest +
|
||||
gameState.perks.left_is_lava +
|
||||
gameState.perks.right_is_lava +
|
||||
|
@ -359,9 +365,7 @@ export function explodeBrick(
|
|||
gameState.perks.picky_eater +
|
||||
gameState.perks.asceticism +
|
||||
gameState.perks.zen +
|
||||
gameState.perks.unbounded
|
||||
|
||||
;
|
||||
gameState.perks.unbounded;
|
||||
|
||||
if (!isExplosion) {
|
||||
// color change
|
||||
|
@ -475,7 +479,7 @@ export function addToScore(gameState: GameState, coin: Coin) {
|
|||
}
|
||||
gameState.runStatistics.score += coin.points;
|
||||
if (gameState.perks.asceticism) {
|
||||
resetCombo(gameState, coin.x, coin.y)
|
||||
resetCombo(gameState, coin.x, coin.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,7 +502,7 @@ export async function setLevel(gameState: GameState, l: number) {
|
|||
|
||||
// Reset combo silently
|
||||
if (!gameState.perks.shunt) {
|
||||
gameState.combo = baseCombo(gameState)
|
||||
gameState.combo = baseCombo(gameState);
|
||||
}
|
||||
gameState.combo += gameState.perks.hot_start * 15;
|
||||
|
||||
|
@ -630,10 +634,10 @@ export function attract(gameState: GameState, a: Ball, b: Ball, power: number) {
|
|||
}
|
||||
|
||||
export function coinBrickHitCheck(gameState: GameState, coin: Coin) {
|
||||
if(gameState.perks.ghost_coins)return undefined
|
||||
if (gameState.perks.ghost_coins) return undefined;
|
||||
// Make ball/coin bonce, and return bricks that were hit
|
||||
const radius = coin.size / 2;
|
||||
const {x, y, previousX, previousY} = coin;
|
||||
const { x, y, previousX, previousY } = coin;
|
||||
|
||||
const vhit = hitsSomething(previousX, y, radius);
|
||||
const hhit = hitsSomething(x, previousY, radius);
|
||||
|
@ -697,7 +701,10 @@ export function bordersHitCheck(
|
|||
let vhit = 0,
|
||||
hhit = 0;
|
||||
|
||||
if (coin.x < gameState.offsetXRoundedDown + radius && !gameState.perks.unbounded) {
|
||||
if (
|
||||
coin.x < gameState.offsetXRoundedDown + radius &&
|
||||
!gameState.perks.unbounded
|
||||
) {
|
||||
coin.x =
|
||||
gameState.offsetXRoundedDown +
|
||||
radius +
|
||||
|
@ -710,7 +717,10 @@ export function bordersHitCheck(
|
|||
coin.vy *= -1;
|
||||
vhit = 1;
|
||||
}
|
||||
if (coin.x > gameState.canvasWidth - gameState.offsetXRoundedDown - radius && !gameState.perks.unbounded) {
|
||||
if (
|
||||
coin.x > gameState.canvasWidth - gameState.offsetXRoundedDown - radius &&
|
||||
!gameState.perks.unbounded
|
||||
) {
|
||||
coin.x =
|
||||
gameState.canvasWidth -
|
||||
gameState.offsetXRoundedDown -
|
||||
|
@ -765,15 +775,19 @@ export function gameStateTick(
|
|||
gameState.autoCleanUses++;
|
||||
}
|
||||
if (!remainingBricks && gameState.noBricksSince == 0) {
|
||||
gameState.noBricksSince ||= gameState.levelTime
|
||||
gameState.noBricksSince ||= gameState.levelTime;
|
||||
}
|
||||
if (!remainingBricks && (!liveCount(gameState.coins) || (gameState.levelTime > gameState.noBricksSince + 5000))) {
|
||||
if (
|
||||
!remainingBricks &&
|
||||
(!liveCount(gameState.coins) ||
|
||||
gameState.levelTime > gameState.noBricksSince + 5000)
|
||||
) {
|
||||
if (gameState.currentLevel + 1 < max_levels(gameState)) {
|
||||
setLevel(gameState, gameState.currentLevel + 1);
|
||||
} else {
|
||||
gameOver(
|
||||
t("gameOver.win.title"),
|
||||
t("gameOver.win.summary", {score: gameState.score}),
|
||||
t("gameOver.win.summary", { score: gameState.score }),
|
||||
);
|
||||
}
|
||||
} else if (gameState.running || gameState.levelTime) {
|
||||
|
@ -781,25 +795,30 @@ export function gameStateTick(
|
|||
|
||||
forEachLiveOne(gameState.coins, (coin, coinIndex) => {
|
||||
if (gameState.perks.coin_magnet) {
|
||||
const strength = 100 / (100 +
|
||||
const strength =
|
||||
(100 /
|
||||
(100 +
|
||||
Math.pow(coin.y - gameState.gameZoneHeight, 2) +
|
||||
Math.pow(coin.x - gameState.puckPosition, 2)) *
|
||||
Math.pow(coin.x - gameState.puckPosition, 2))) *
|
||||
gameState.perks.coin_magnet;
|
||||
|
||||
const attractionX = frames * (gameState.puckPosition - coin.x) * strength
|
||||
const attractionX =
|
||||
frames * (gameState.puckPosition - coin.x) * strength;
|
||||
|
||||
coin.vx += attractionX;
|
||||
coin.vy += frames * (gameState.gameZoneHeight - coin.y) * strength / 2
|
||||
coin.vy +=
|
||||
(frames * (gameState.gameZoneHeight - coin.y) * strength) / 2;
|
||||
coin.sa -= attractionX / 10;
|
||||
|
||||
}
|
||||
|
||||
if(gameState.perks.ball_attracts_coins){
|
||||
gameState.balls.forEach(ball=>{
|
||||
const d2= distance2(ball, coin)
|
||||
coin.vx+=(ball.x-coin.x)/d2*30*gameState.perks.ball_attracts_coins
|
||||
coin.vy+=(ball.y-coin.y)/d2*30*gameState.perks.ball_attracts_coins
|
||||
})
|
||||
if (gameState.perks.ball_attracts_coins) {
|
||||
gameState.balls.forEach((ball) => {
|
||||
const d2 = distance2(ball, coin);
|
||||
coin.vx +=
|
||||
((ball.x - coin.x) / d2) * 30 * gameState.perks.ball_attracts_coins;
|
||||
coin.vy +=
|
||||
((ball.y - coin.y) / d2) * 30 * gameState.perks.ball_attracts_coins;
|
||||
});
|
||||
}
|
||||
|
||||
const ratio = 1 - (gameState.perks.viscosity * 0.03 + 0.005) * frames;
|
||||
|
@ -816,10 +835,14 @@ export function gameStateTick(
|
|||
|
||||
// Gravity
|
||||
if (!gameState.perks.etherealcoins) {
|
||||
const flip = gameState.perks.helium > 0 && Math.abs(coin.x - gameState.puckPosition) * 2 > gameState.puckWidth + coin.size
|
||||
const flip =
|
||||
gameState.perks.helium > 0 &&
|
||||
Math.abs(coin.x - gameState.puckPosition) * 2 >
|
||||
gameState.puckWidth + coin.size;
|
||||
coin.vy += frames * coin.weight * 0.8 * (flip ? -1 : 1);
|
||||
if (flip && !isOptionOn('basic') && Math.random() < 0.1) {
|
||||
makeParticle(gameState,
|
||||
if (flip && !isOptionOn("basic") && Math.random() < 0.1) {
|
||||
makeParticle(
|
||||
gameState,
|
||||
coin.x,
|
||||
coin.y,
|
||||
0,
|
||||
|
@ -827,10 +850,9 @@ export function gameStateTick(
|
|||
rainbowColor(),
|
||||
true,
|
||||
5,
|
||||
250
|
||||
)
|
||||
250,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const speed = Math.abs(coin.sx) + Math.abs(coin.sx);
|
||||
|
@ -851,12 +873,14 @@ export function gameStateTick(
|
|||
if (gameState.perks.compound_interest) {
|
||||
resetCombo(gameState, coin.x, coin.y);
|
||||
}
|
||||
} else if (gameState.perks.unbounded && (coin.x < -50 || coin.x > gameState.canvasWidth + 50)) {
|
||||
} else if (
|
||||
gameState.perks.unbounded &&
|
||||
(coin.x < -50 || coin.x > gameState.canvasWidth + 50)
|
||||
) {
|
||||
// Out of bound on sides
|
||||
destroy(gameState.coins, coinIndex);
|
||||
}
|
||||
|
||||
|
||||
const hitBrick = coinBrickHitCheck(gameState, coin);
|
||||
|
||||
if (gameState.perks.metamorphosis && typeof hitBrick !== "undefined") {
|
||||
|
@ -891,29 +915,41 @@ export function gameStateTick(
|
|||
if (gameState.perks.shocks) {
|
||||
gameState.balls.forEach((a, ai) =>
|
||||
gameState.balls.forEach((b, bi) => {
|
||||
if (ai < bi && !a.destroyed && !b.destroyed && distance2(a, b) < gameState.ballSize * gameState.ballSize) {
|
||||
let tempVx = a.vx
|
||||
let tempVy = a.vy
|
||||
a.vx = b.vx
|
||||
a.vy = b.vy
|
||||
b.vx = tempVx
|
||||
b.vy = tempVy
|
||||
if (
|
||||
ai < bi &&
|
||||
!a.destroyed &&
|
||||
!b.destroyed &&
|
||||
distance2(a, b) < gameState.ballSize * gameState.ballSize
|
||||
) {
|
||||
let tempVx = a.vx;
|
||||
let tempVy = a.vy;
|
||||
a.vx = b.vx;
|
||||
a.vy = b.vy;
|
||||
b.vx = tempVx;
|
||||
b.vy = tempVy;
|
||||
|
||||
let x = (a.x + b.x) / 2
|
||||
let y = (a.y + b.y) / 2
|
||||
const limit = gameState.baseSpeed
|
||||
a.vx += clamp(a.x - x, -limit, limit)+(Math.random()-0.5) * limit/3
|
||||
a.vy += clamp(a.y - y, -limit, limit)+(Math.random()-0.5) * limit/3
|
||||
b.vx += clamp(b.x - x, -limit, limit)+(Math.random()-0.5) * limit/3
|
||||
b.vy += clamp(b.y - y, -limit, limit)+(Math.random()-0.5) * limit/3
|
||||
let x = (a.x + b.x) / 2;
|
||||
let y = (a.y + b.y) / 2;
|
||||
const limit = gameState.baseSpeed;
|
||||
a.vx +=
|
||||
clamp(a.x - x, -limit, limit) +
|
||||
((Math.random() - 0.5) * limit) / 3;
|
||||
a.vy +=
|
||||
clamp(a.y - y, -limit, limit) +
|
||||
((Math.random() - 0.5) * limit) / 3;
|
||||
b.vx +=
|
||||
clamp(b.x - x, -limit, limit) +
|
||||
((Math.random() - 0.5) * limit) / 3;
|
||||
b.vy +=
|
||||
clamp(b.y - y, -limit, limit) +
|
||||
((Math.random() - 0.5) * limit) / 3;
|
||||
|
||||
let index = brickIndex(x, y)
|
||||
let index = brickIndex(x, y);
|
||||
|
||||
explosionAt(gameState, index, x, y, a)
|
||||
explosionAt(gameState, index, x, y, a);
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (gameState.perks.wind) {
|
||||
|
@ -1081,9 +1117,7 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
if (isYoyoActive(gameState, ball)) {
|
||||
speedLimitDampener += 3;
|
||||
ball.vx +=
|
||||
((gameState.puckPosition - ball.x) / 1000) *
|
||||
delta *
|
||||
gameState.perks.yoyo;
|
||||
((gameState.puckPosition - ball.x) / 1000) * delta * gameState.perks.yoyo;
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -1143,7 +1177,7 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
i < ball.hitItem?.length - 1 && i < gameState.perks.respawn;
|
||||
i++
|
||||
) {
|
||||
const {index, color} = ball.hitItem[i];
|
||||
const { index, color } = ball.hitItem[i];
|
||||
if (gameState.bricks[index] || color === "black") continue;
|
||||
const vertical = Math.random() > 0.5;
|
||||
const dx = Math.random() > 0.5 ? 1 : -1;
|
||||
|
@ -1163,7 +1197,12 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
}
|
||||
}
|
||||
|
||||
const borderHitCode = bordersHitCheck(gameState, ball, gameState.ballSize / 2, delta);
|
||||
const borderHitCode = bordersHitCheck(
|
||||
gameState,
|
||||
ball,
|
||||
gameState.ballSize / 2,
|
||||
delta,
|
||||
);
|
||||
if (borderHitCode) {
|
||||
if (
|
||||
gameState.perks.left_is_lava &&
|
||||
|
@ -1216,46 +1255,43 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
} else {
|
||||
ball.vy *= -1;
|
||||
|
||||
gameState.perks.extra_life -= 1
|
||||
if(gameState.perks.extra_life <0){
|
||||
gameState.perks.extra_life=0
|
||||
}else if(gameState.perks.sacrifice){
|
||||
if(liveCount(gameState.coins)<gameState.MAX_COINS/2){
|
||||
gameState.perks.extra_life -= 1;
|
||||
if (gameState.perks.extra_life < 0) {
|
||||
gameState.perks.extra_life = 0;
|
||||
} else if (gameState.perks.sacrifice) {
|
||||
if (liveCount(gameState.coins) < gameState.MAX_COINS / 2) {
|
||||
// true duplication
|
||||
let remaining = liveCount(gameState.coins)
|
||||
let remaining = liveCount(gameState.coins);
|
||||
|
||||
forEachLiveOne(gameState.coins, (source, index)=>{
|
||||
if(!remaining) return
|
||||
append(gameState.coins, copy=>{
|
||||
copy.points=source.points
|
||||
copy.color=source.color
|
||||
copy.x=source.x
|
||||
copy.y=source.y
|
||||
copy.size=source.size
|
||||
copy.previousX=source.previousX
|
||||
copy.previousY=source.previousY
|
||||
copy.vx=-source.vx
|
||||
copy.vy=-source.vy
|
||||
copy.sx=source.sx
|
||||
copy.sy=source.sy
|
||||
copy.a=source.a
|
||||
copy.sa=-source.sa
|
||||
copy.weight=source.weight
|
||||
copy.coloredABrick=source.coloredABrick
|
||||
})
|
||||
remaining--
|
||||
})
|
||||
}else{
|
||||
forEachLiveOne(gameState.coins, (source, index)=>{
|
||||
source.points*=2
|
||||
})
|
||||
forEachLiveOne(gameState.coins, (source, index) => {
|
||||
if (!remaining) return;
|
||||
append(gameState.coins, (copy) => {
|
||||
copy.points = source.points;
|
||||
copy.color = source.color;
|
||||
copy.x = source.x;
|
||||
copy.y = source.y;
|
||||
copy.size = source.size;
|
||||
copy.previousX = source.previousX;
|
||||
copy.previousY = source.previousY;
|
||||
copy.vx = -source.vx;
|
||||
copy.vy = -source.vy;
|
||||
copy.sx = source.sx;
|
||||
copy.sy = source.sy;
|
||||
copy.a = source.a;
|
||||
copy.sa = -source.sa;
|
||||
copy.weight = source.weight;
|
||||
copy.coloredABrick = source.coloredABrick;
|
||||
});
|
||||
remaining--;
|
||||
});
|
||||
} else {
|
||||
forEachLiveOne(gameState.coins, (source, index) => {
|
||||
source.points *= 2;
|
||||
});
|
||||
// spawn a few coins for effect, but mostly increment poitns counter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
schedulGameSound(gameState, "lifeLost", ball.x, 1);
|
||||
if (!isOptionOn("basic")) {
|
||||
for (let i = 0; i < 10; i++)
|
||||
|
@ -1276,16 +1312,15 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
resetCombo(gameState, ball.x, ball.y);
|
||||
}
|
||||
if (gameState.perks.trampoline) {
|
||||
gameState.combo+=gameState.perks.trampoline
|
||||
gameState.combo += gameState.perks.trampoline;
|
||||
}
|
||||
if (gameState.perks.nbricks) {
|
||||
if (ball.hitSinceBounce) {
|
||||
if (gameState.perks.nbricks === ball.hitSinceBounce) {
|
||||
gameState.combo += gameState.perks.nbricks
|
||||
gameState.combo += gameState.perks.nbricks;
|
||||
} else {
|
||||
resetCombo(gameState, ball.x, ball.y)
|
||||
resetCombo(gameState, ball.x, ball.y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1293,7 +1328,7 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
ball.hitItem
|
||||
.slice(0, -1)
|
||||
.slice(0, gameState.perks.respawn)
|
||||
.forEach(({index, color}) => {
|
||||
.forEach(({ index, color }) => {
|
||||
if (!gameState.bricks[index] && color !== "black")
|
||||
gameState.bricks[index] = color;
|
||||
});
|
||||
|
@ -1302,12 +1337,13 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
if (!ball.hitSinceBounce) {
|
||||
gameState.runStatistics.misses++;
|
||||
gameState.levelMisses++;
|
||||
if(gameState.perks.forgiving){
|
||||
const indexes = gameState.bricks.map((b,i)=>b ? i:-1)
|
||||
.filter(i=>i>-1)
|
||||
const pick = sample(indexes)
|
||||
explodeBrick(gameState,pick, ball, false)
|
||||
}else{
|
||||
if (gameState.perks.forgiving) {
|
||||
const indexes = gameState.bricks
|
||||
.map((b, i) => (b ? i : -1))
|
||||
.filter((i) => i > -1);
|
||||
const pick = sample(indexes);
|
||||
explodeBrick(gameState, pick, ball, false);
|
||||
} else {
|
||||
resetCombo(gameState, ball.x, ball.y);
|
||||
}
|
||||
makeText(
|
||||
|
@ -1326,23 +1362,25 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
|||
ball.piercedSinceBounce = 0;
|
||||
}
|
||||
|
||||
const lostOnSides = gameState.perks.unbounded && ball.x < 50 || ball.x > gameState.canvasWidth + 50
|
||||
if (gameState.running &&
|
||||
const lostOnSides =
|
||||
(gameState.perks.unbounded && ball.x < 50) ||
|
||||
ball.x > gameState.canvasWidth + 50;
|
||||
if (
|
||||
gameState.running &&
|
||||
(ball.y > gameState.gameZoneHeight + gameState.ballSize / 2 || lostOnSides)
|
||||
|
||||
) {
|
||||
ball.destroyed = true;
|
||||
gameState.runStatistics.balls_lost++;
|
||||
if (!gameState.balls.find((b) => !b.destroyed)) {
|
||||
gameOver(
|
||||
t("gameOver.lost.title"),
|
||||
t("gameOver.lost.summary", {score: gameState.score}),
|
||||
t("gameOver.lost.summary", { score: gameState.score }),
|
||||
);
|
||||
}
|
||||
}
|
||||
const radius = gameState.ballSize / 2;
|
||||
// Make ball/coin bonce, and return bricks that were hit
|
||||
const {x, y, previousX, previousY} = ball;
|
||||
const { x, y, previousX, previousY } = ball;
|
||||
|
||||
const vhit = hitsSomething(previousX, y, radius);
|
||||
const hhit = hitsSomething(x, previousY, radius);
|
||||
|
@ -1542,7 +1580,7 @@ export function append<T>(
|
|||
makeItem(where.list[where.indexMin]);
|
||||
where.indexMin++;
|
||||
} else {
|
||||
const p = {destroyed: false};
|
||||
const p = { destroyed: false };
|
||||
makeItem(p);
|
||||
where.list.push(p);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Ball, GameState, PerkId, PerksMap} from "./types";
|
||||
import {icons, upgrades} from "./loadGameData";
|
||||
import { Ball, GameState, PerkId, PerksMap } from "./types";
|
||||
import { icons, upgrades } from "./loadGameData";
|
||||
|
||||
export function getMajorityValue(arr: string[]): string {
|
||||
const count: { [k: string]: number } = {};
|
||||
|
@ -103,9 +103,8 @@ export function distanceBetween(
|
|||
return Math.sqrt(distance2(a, b));
|
||||
}
|
||||
|
||||
|
||||
export function clamp(value, min, max){
|
||||
return Math.max(min, Math.min(value, max))
|
||||
export function clamp(value: number, min: number, max: number) {
|
||||
return Math.max(min, Math.min(value, max));
|
||||
}
|
||||
export function defaultSounds() {
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {baseCombo, forEachLiveOne, liveCount} from "./gameStateMutators";
|
||||
import { baseCombo, forEachLiveOne, liveCount } from "./gameStateMutators";
|
||||
import {
|
||||
brickCenterX,
|
||||
brickCenterY,
|
||||
|
@ -7,10 +7,10 @@ import {
|
|||
isYoyoActive,
|
||||
max_levels,
|
||||
} from "./game_utils";
|
||||
import {colorString, GameState} from "./types";
|
||||
import {t} from "./i18n/i18n";
|
||||
import {gameState} from "./game";
|
||||
import {isOptionOn} from "./options";
|
||||
import { colorString, GameState } from "./types";
|
||||
import { t } from "./i18n/i18n";
|
||||
import { gameState } from "./game";
|
||||
import { isOptionOn } from "./options";
|
||||
|
||||
export const gameCanvas = document.getElementById("game") as HTMLCanvasElement;
|
||||
export const ctx = gameCanvas.getContext("2d", {
|
||||
|
@ -29,7 +29,7 @@ export const backgroundCanvas = document.createElement("canvas");
|
|||
|
||||
export function render(gameState: GameState) {
|
||||
const level = currentLevelInfo(gameState);
|
||||
const {width, height} = gameCanvas;
|
||||
const { width, height } = gameCanvas;
|
||||
if (!width || !height) return;
|
||||
|
||||
if (gameState.currentLevel || gameState.levelTime) {
|
||||
|
@ -82,13 +82,13 @@ export function render(gameState: GameState) {
|
|||
});
|
||||
ctx.globalAlpha = 1;
|
||||
forEachLiveOne(gameState.lights, (flash) => {
|
||||
const {x, y, time, color, size, duration} = flash;
|
||||
const { x, y, time, color, size, duration } = flash;
|
||||
const elapsed = gameState.levelTime - time;
|
||||
ctx.globalAlpha = Math.min(1, 2 - (elapsed / duration) * 2);
|
||||
drawFuzzyBall(ctx, color, size, x, y);
|
||||
});
|
||||
forEachLiveOne(gameState.particles, (flash) => {
|
||||
const {x, y, time, color, size, duration} = flash;
|
||||
const { x, y, time, color, size, duration } = flash;
|
||||
const elapsed = gameState.levelTime - time;
|
||||
ctx.globalAlpha = Math.min(1, 2 - (elapsed / duration) * 2);
|
||||
drawFuzzyBall(ctx, color, size * 3, x, y);
|
||||
|
@ -131,7 +131,7 @@ export function render(gameState: GameState) {
|
|||
ctx.fillStyle = level.color || "#000";
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
forEachLiveOne(gameState.particles, (flash) => {
|
||||
const {x, y, time, color, size, duration} = flash;
|
||||
const { x, y, time, color, size, duration } = flash;
|
||||
const elapsed = gameState.levelTime - time;
|
||||
ctx.globalAlpha = Math.min(1, 2 - (elapsed / duration) * 2);
|
||||
drawBall(ctx, color, size, x, y);
|
||||
|
@ -194,7 +194,7 @@ export function render(gameState: GameState) {
|
|||
|
||||
ctx.globalCompositeOperation = "screen";
|
||||
forEachLiveOne(gameState.texts, (flash) => {
|
||||
const {x, y, time, color, size, duration} = flash;
|
||||
const { x, y, time, color, size, duration } = flash;
|
||||
const elapsed = gameState.levelTime - time;
|
||||
ctx.globalAlpha = Math.max(0, Math.min(1, 2 - (elapsed / duration) * 2));
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
|
@ -202,7 +202,7 @@ export function render(gameState: GameState) {
|
|||
});
|
||||
|
||||
forEachLiveOne(gameState.particles, (particle) => {
|
||||
const {x, y, time, color, size, duration} = particle;
|
||||
const { x, y, time, color, size, duration } = particle;
|
||||
const elapsed = gameState.levelTime - time;
|
||||
ctx.globalAlpha = Math.max(0, Math.min(1, 2 - (elapsed / duration) * 2));
|
||||
ctx.globalCompositeOperation = "screen";
|
||||
|
@ -218,7 +218,9 @@ export function render(gameState: GameState) {
|
|||
ctx.fillRect(
|
||||
gameState.perks.unbounded ? 0 : gameState.offsetXRoundedDown,
|
||||
gameState.gameZoneHeight - gameState.puckHeight / 2 + 2 * i,
|
||||
gameState.perks.unbounded ? gameState.canvasWidth : gameState.gameZoneWidthRoundedUp,
|
||||
gameState.perks.unbounded
|
||||
? gameState.canvasWidth
|
||||
: gameState.gameZoneWidthRoundedUp,
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
@ -240,7 +242,7 @@ export function render(gameState: GameState) {
|
|||
if (isTelekinesisActive(gameState, ball) || isYoyoActive(gameState, ball)) {
|
||||
ctx.strokeStyle = gameState.puckColor;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(gameState.puckPosition, gameState.gameZoneHeight );
|
||||
ctx.moveTo(gameState.puckPosition, gameState.gameZoneHeight);
|
||||
ctx.bezierCurveTo(
|
||||
gameState.puckPosition,
|
||||
gameState.gameZoneHeight,
|
||||
|
@ -251,9 +253,6 @@ export function render(gameState: GameState) {
|
|||
);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
// The puck
|
||||
ctx.globalAlpha = 1;
|
||||
|
@ -318,7 +317,7 @@ export function render(gameState: GameState) {
|
|||
const hasCombo = gameState.combo > baseCombo(gameState);
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
|
||||
ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1
|
||||
ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1;
|
||||
if (gameState.offsetXRoundedDown) {
|
||||
// draw outside of gaming area to avoid capturing borders in recordings
|
||||
ctx.fillStyle =
|
||||
|
|
2
src/types.d.ts
vendored
2
src/types.d.ts
vendored
|
@ -244,7 +244,7 @@ export type GameState = {
|
|||
runStatistics: RunStats;
|
||||
lastOffered: Partial<{ [k in PerkId]: number }>;
|
||||
levelTime: number;
|
||||
noBricksSince: number ;
|
||||
noBricksSince: number;
|
||||
levelWallBounces: number;
|
||||
autoCleanUses: number;
|
||||
aboutToPlaySound: {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
import _rawLevelsList from "./data/levels.json";
|
||||
import {rawUpgrades} from "./upgrades";
|
||||
import { rawUpgrades } from "./upgrades";
|
||||
|
||||
describe("rawUpgrades", ()=>{
|
||||
|
||||
it('has an icon for each upgrade',()=>{
|
||||
const missingIcon = rawUpgrades.map(u=>u.id).filter(id=>!_rawLevelsList.find(l=>l.name === 'icon:'+id))
|
||||
expect(missingIcon.join(', ')).toEqual('')
|
||||
})
|
||||
})
|
||||
describe("rawUpgrades", () => {
|
||||
it("has an icon for each upgrade", () => {
|
||||
const missingIcon = rawUpgrades
|
||||
.map((u) => u.id)
|
||||
.filter((id) => !_rawLevelsList.find((l) => l.name === "icon:" + id));
|
||||
expect(missingIcon.join(", ")).toEqual("");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -383,7 +383,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:70000,
|
||||
threshold: 70000,
|
||||
giftable: false,
|
||||
id: "asceticism",
|
||||
max: 1,
|
||||
|
@ -393,7 +393,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:75000,
|
||||
threshold: 75000,
|
||||
giftable: false,
|
||||
id: "unbounded",
|
||||
max: 1,
|
||||
|
@ -403,7 +403,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:80000,
|
||||
threshold: 80000,
|
||||
giftable: false,
|
||||
id: "shunt",
|
||||
max: 1,
|
||||
|
@ -413,7 +413,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:85000,
|
||||
threshold: 85000,
|
||||
giftable: false,
|
||||
id: "yoyo",
|
||||
max: 2,
|
||||
|
@ -423,17 +423,17 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:90000,
|
||||
threshold: 90000,
|
||||
giftable: false,
|
||||
id: "nbricks",
|
||||
max: 3,
|
||||
name: t("upgrades.nbricks.name"),
|
||||
help: (lvl: number) => t("upgrades.nbricks.help",{lvl}),
|
||||
help: (lvl: number) => t("upgrades.nbricks.help", { lvl }),
|
||||
fullHelp: t("upgrades.nbricks.fullHelp"),
|
||||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:95000,
|
||||
threshold: 95000,
|
||||
giftable: false,
|
||||
id: "etherealcoins",
|
||||
max: 1,
|
||||
|
@ -443,7 +443,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "multiball",
|
||||
threshold:100000,
|
||||
threshold: 100000,
|
||||
giftable: false,
|
||||
id: "shocks",
|
||||
max: 1,
|
||||
|
@ -453,7 +453,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:105000,
|
||||
threshold: 105000,
|
||||
giftable: false,
|
||||
id: "zen",
|
||||
max: 1,
|
||||
|
@ -463,7 +463,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "extra_life",
|
||||
threshold:110000,
|
||||
threshold: 110000,
|
||||
giftable: false,
|
||||
id: "sacrifice",
|
||||
max: 1,
|
||||
|
@ -474,27 +474,27 @@ export const rawUpgrades = [
|
|||
|
||||
{
|
||||
requires: "",
|
||||
threshold:115000,
|
||||
threshold: 115000,
|
||||
giftable: false,
|
||||
id: "trampoline",
|
||||
max: 3,
|
||||
name: t("upgrades.trampoline.name"),
|
||||
help: (lvl: number) => t("upgrades.trampoline.help",{lvl}),
|
||||
help: (lvl: number) => t("upgrades.trampoline.help", { lvl }),
|
||||
fullHelp: t("upgrades.trampoline.fullHelp"),
|
||||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:120000,
|
||||
threshold: 120000,
|
||||
giftable: false,
|
||||
id: "ghost_coins",
|
||||
max: 1,
|
||||
name: t("upgrades.ghost_coins.name"),
|
||||
help: (lvl: number) => t("upgrades.ghost_coins.help",{lvl}),
|
||||
help: (lvl: number) => t("upgrades.ghost_coins.help", { lvl }),
|
||||
fullHelp: t("upgrades.ghost_coins.fullHelp"),
|
||||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:125000,
|
||||
threshold: 125000,
|
||||
giftable: false,
|
||||
id: "forgiving",
|
||||
max: 1,
|
||||
|
@ -504,7 +504,7 @@ export const rawUpgrades = [
|
|||
},
|
||||
{
|
||||
requires: "",
|
||||
threshold:130000,
|
||||
threshold: 130000,
|
||||
giftable: false,
|
||||
id: "ball_attracts_coins",
|
||||
max: 3,
|
||||
|
@ -512,5 +512,4 @@ export const rawUpgrades = [
|
|||
help: (lvl: number) => t("upgrades.ball_attracts_coins.help"),
|
||||
fullHelp: t("upgrades.ball_attracts_coins.fullHelp"),
|
||||
},
|
||||
|
||||
] as const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue