diff --git a/dist/index.html b/dist/index.html
index bef147b..d4f02f7 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -2578,7 +2578,8 @@ function getBallDefaultVx(gameState) {
return (gameState.perks.concave_puck ? 0 : 1) * (Math.random() > 0.5 ? gameState.baseSpeed : -gameState.baseSpeed);
}
function resetBalls(gameState) {
- console.log('resetBalls', gameState);
+ // Always compute speed first
+ normalizeGameState(gameState);
const count = 1 + (gameState.perks?.multiball || 0);
const perBall = gameState.puckWidth / (count + 1);
gameState.balls = [];
@@ -2596,8 +2597,8 @@ function resetBalls(gameState) {
previousVX: vx,
vy: -gameState.baseSpeed,
previousVY: -gameState.baseSpeed,
- sx: 0,
- sy: 0,
+ // sx: 0,
+ // sy: 0,
piercePoints: gameState.perks.pierce * 3,
hitSinceBounce: 0,
brokenSinceBounce: 0,
@@ -2622,8 +2623,8 @@ function putBallsAtPuck(gameState) {
// ball.previousVX = ball.vx;
// ball.vy = -gameState.baseSpeed;
// ball.previousVY = ball.vy;
- ball.sx = 0;
- ball.sy = 0;
+ // ball.sx = 0;
+ // ball.sy = 0;
ball.hitItem = [];
ball.hitSinceBounce = 0;
ball.brokenSinceBounce = 0;
@@ -2940,12 +2941,12 @@ function bordersHitCheck(gameState, coin, radius, delta) {
coin.previousY = coin.y;
coin.x += coin.vx * delta;
coin.y += coin.vy * delta;
- coin.sx ||= 0;
- coin.sy ||= 0;
- coin.sx += coin.previousX - coin.x;
- coin.sy += coin.previousY - coin.y;
- coin.sx *= 0.9;
- coin.sy *= 0.9;
+ // coin.sx ||= 0;
+ // coin.sy ||= 0;
+ // coin.sx += coin.previousX - coin.x;
+ // coin.sy += coin.previousY - coin.y;
+ // coin.sx *= 0.9;
+ // coin.sy *= 0.9;
if (gameState.perks.wind) coin.vx += (gameState.puckPosition - (gameState.offsetX + gameState.gameZoneWidth / 2)) / gameState.gameZoneWidth * gameState.perks.wind * 0.5;
let vhit = 0, hhit = 0;
if (coin.x < gameState.offsetXRoundedDown + radius && !gameState.perks.unbounded) {
@@ -3019,9 +3020,9 @@ 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, coin.color, true, 5, 250);
}
- const speed = Math.abs(coin.sx) + Math.abs(coin.sx);
+ const speed = (Math.abs(coin.vx) + Math.abs(coin.vy)) * 10;
const hitBorder = bordersHitCheck(gameState, coin, coin.size / 2, frames);
if (coin.y > gameState.gameZoneHeight - coinRadius - gameState.puckHeight && coin.y < gameState.gameZoneHeight + gameState.puckHeight + coin.vy && Math.abs(coin.x - gameState.puckPosition) < coinRadius + gameState.puckWidth / 2 + // a bit of margin to be nice
gameState.puckHeight) {
@@ -3193,8 +3194,8 @@ function ballTick(gameState, ball, delta) {
copy.previousY = source.previousY;
copy.vx = -source.vx;
copy.vy = -source.vy;
- copy.sx = source.sx;
- copy.sy = source.sy;
+ // copy.sx = source.sx;
+ // copy.sy = source.sy;
copy.a = source.a;
copy.sa = -source.sa;
copy.weight = source.weight;
@@ -3302,8 +3303,8 @@ function makeCoin(gameState, x, y, vx, vy, color = "gold", points = 1) {
p.previousY = y;
p.vx = vx;
p.vy = vy;
- p.sx = 0;
- p.sy = 0;
+ // p.sx = 0;
+ // p.sy = 0;
p.color = color;
p.a = Math.random() * Math.PI * 2;
p.sa = Math.random() - 0.5;
diff --git a/src/gameStateMutators.ts b/src/gameStateMutators.ts
index e60376e..b8a3ea7 100644
--- a/src/gameStateMutators.ts
+++ b/src/gameStateMutators.ts
@@ -70,7 +70,8 @@ function getBallDefaultVx(gameState: GameState) {
}
export function resetBalls(gameState: GameState) {
- console.log('resetBalls',gameState)
+ // Always compute speed first
+ normalizeGameState(gameState)
const count = 1 + (gameState.perks?.multiball || 0);
const perBall = gameState.puckWidth / (count + 1);
gameState.balls = [];
@@ -94,8 +95,8 @@ export function resetBalls(gameState: GameState) {
vy: -gameState.baseSpeed,
previousVY: -gameState.baseSpeed,
- sx: 0,
- sy: 0,
+ // sx: 0,
+ // sy: 0,
piercePoints: gameState.perks.pierce * 3,
hitSinceBounce: 0,
brokenSinceBounce: 0,
@@ -123,8 +124,8 @@ export function putBallsAtPuck(gameState: GameState) {
// ball.previousVX = ball.vx;
// ball.vy = -gameState.baseSpeed;
// ball.previousVY = ball.vy;
- ball.sx = 0;
- ball.sy = 0;
+ // ball.sx = 0;
+ // ball.sy = 0;
ball.hitItem = [];
ball.hitSinceBounce = 0;
ball.brokenSinceBounce = 0;
@@ -772,12 +773,12 @@ export function bordersHitCheck(
coin.previousY = coin.y;
coin.x += coin.vx * delta;
coin.y += coin.vy * delta;
- coin.sx ||= 0;
- coin.sy ||= 0;
- coin.sx += coin.previousX - coin.x;
- coin.sy += coin.previousY - coin.y;
- coin.sx *= 0.9;
- coin.sy *= 0.9;
+ // coin.sx ||= 0;
+ // coin.sy ||= 0;
+ // coin.sx += coin.previousX - coin.x;
+ // coin.sy += coin.previousY - coin.y;
+ // coin.sx *= 0.9;
+ // coin.sy *= 0.9;
if (gameState.perks.wind) {
coin.vx +=
@@ -952,7 +953,7 @@ export function gameStateTick(
coin.y,
0,
gameState.baseSpeed,
- rainbowColor(),
+ coin.color,
true,
5,
250,
@@ -960,7 +961,7 @@ export function gameStateTick(
}
}
- const speed = Math.abs(coin.sx) + Math.abs(coin.sx);
+ const speed =( Math.abs(coin.vx) + Math.abs(coin.vy)) * 10;
const hitBorder = bordersHitCheck(gameState, coin, coin.size / 2, frames);
if (
@@ -1229,7 +1230,6 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
ball.vx +=
((gameState.puckPosition - ball.x) / 1000) * delta * gameState.perks.yoyo;
}
-
if (
ball.vx * ball.vx + ball.vy * ball.vy <
gameState.baseSpeed * gameState.baseSpeed * 2
@@ -1393,8 +1393,8 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
copy.previousY = source.previousY;
copy.vx = -source.vx;
copy.vy = -source.vy;
- copy.sx = source.sx;
- copy.sy = source.sy;
+ // copy.sx = source.sx;
+ // copy.sy = source.sy;
copy.a = source.a;
copy.sa = -source.sa;
copy.weight = source.weight;
@@ -1613,8 +1613,8 @@ function makeCoin(
p.previousY = y;
p.vx = vx;
p.vy = vy;
- p.sx = 0;
- p.sy = 0;
+ // p.sx = 0;
+ // p.sy = 0;
p.color = color;
p.a = Math.random() * Math.PI * 2;
p.sa = Math.random() - 0.5;
diff --git a/src/types.d.ts b/src/types.d.ts
index 72d5758..58ecadc 100644
--- a/src/types.d.ts
+++ b/src/types.d.ts
@@ -75,8 +75,8 @@ export type Coin = {
previousY: number;
vx: number;
vy: number;
- sx: number;
- sy: number;
+ // sx: number;
+ // sy: number;
a: number;
sa: number;
weight: number;
@@ -92,8 +92,8 @@ export type Ball = {
vy: number;
previousVX: number;
previousVY: number;
- sx: number;
- sy: number;
+ // sx: number;
+ // sy: number;
// Ability to pierce N HP
piercePoints: number;
// Any bounce counts, even if brick resisted the hit