Added level and fixed a bug

This commit is contained in:
Renan LE CARO 2025-06-28 07:46:45 +02:00
parent 0df5d218a3
commit 31d22b52f3
6 changed files with 80 additions and 37 deletions

View file

@ -325,8 +325,8 @@
},
{
"name": "icon:rainbow",
"size": 7,
"bricks": "b_b_b_b_b_b_b_r_O_y_C_r_O_y_r_O_y_C_b_b_b_b_b_b_b",
"size": 8,
"bricks": "_____________bb_____ccb____yyc____SSy____rrS______r_____________",
"credit": ""
},
{
@ -1648,5 +1648,12 @@
"size": 8,
"bricks": "ggWRRWggggWrrWggggWRRWggggWRRWggggWRyWggggWRRWggggWRRWggggWWWWgg",
"credit": "Modern slave dress, with luxury. By Obigre"
},
{
"color": "#000000",
"size": 12,
"bricks": "__________________________bbbbbbbb____bbbbkkbb____bkkkkkkk____kkkkkkkk____kBBkkBBk____kkkbbkkb____kkbkkbkb____bbbbkbkb__________________________",
"name": "Zombie",
"credit": "Minecraft Zombie by CHRISS Vector"
}
]
]

View file

@ -976,7 +976,8 @@ export function restart(params: RunParams) {
if (window.location.search.match(/autoplay|stress/)) {
startComputerControlledGame(window.location.search.includes("stress"));
} else {
restart({});
restart({
});
}
export function startComputerControlledGame(stress: boolean = false) {

View file

@ -1962,12 +1962,26 @@ export function ballTick(gameState: GameState, ball: Ball, frames: number) {
ball.piercePoints = gameState.perks.pierce * 3;
}
if (
ball.y > gameState.gameZoneHeight + gameState.ballSize / 2 ||
const outOfBounds=ball.y > gameState.gameZoneHeight + gameState.ballSize / 2 ||
ball.y < -gameState.gameZoneHeight ||
ball.x < -gameState.gameZoneHeight ||
ball.x > gameState.canvasWidth + gameState.gameZoneHeight
) {
ball.x > gameState.canvasWidth + gameState.gameZoneHeight;
if(outOfBounds && gameState.perks.extra_life && gameState.balls.filter((b) => !b.destroyed).length==1){
// Rescue the ball using an extra life
gameState.balls.forEach(b=>{
// there should be just one but just in case
b.vx=getBallDefaultVx(gameState)
b.previousVX=b.vx
b.vy= -gameState.baseSpeed
b.previousVY = b.vy
})
schedulGameSound(gameState, "lifeLost", ball.x, 1);
putBallsAtPuck(gameState)
gameState.ballStickToPuck = true;
pause(false)
gameState.perks.extra_life -= 1;
}else if (outOfBounds) {
ball.destroyed = true;
gameState.runStatistics.balls_lost++;
if (gameState.perks.happy_family) {

View file

@ -66,6 +66,7 @@ export function newGameState(params: RunParams): GameState {
perks[randomGift] = 1;
}
const runLevels = getRunLevels(params, randomGift);
const gameState: GameState = {
@ -118,7 +119,6 @@ export function newGameState(params: RunParams): GameState {
ballSize: 20,
coinSize: 14,
puckHeight: 20,
pauseUsesDuringRun: 0,
keyboardPuckSpeed: 0,
lastTick: performance.now(),