From 5860e6119e8d4a5a60ffcdb6cf6e46ac34c27e2c Mon Sep 17 00:00:00 2001
From: Renan LE CARO
Date: Sat, 1 Mar 2025 14:20:27 +0100
Subject: [PATCH] Explanation for perks in help, coins speed limit to avoid
clipping, adapted coin spawn rate
---
Readme.md | 15 +-
app/src/main/assets/game.js | 854 +++++++++++++++++++---------------
app/src/main/assets/levels.js | 174 ++-----
editclient.js | 4 -
4 files changed, 533 insertions(+), 514 deletions(-)
diff --git a/Readme.md b/Readme.md
index cde2c22..1455cf1 100644
--- a/Readme.md
+++ b/Readme.md
@@ -127,7 +127,14 @@ There's also an easy mode for kids (slower ball) and a color-blind mode (no colo
# Roadmap
The "engine" could be better
-- shift text on puck when too large
+- handle high combo better
+- avoid coin clip through puck
+- upgrade that boost coins +x% should change number of spawned coins
+- explain the miss thing better
+- apk version soft locks at start.
+- add particles for respawn bricks
+- remove color blind mode and just highlight bricks of the wrong color in the render with a pattern or something.
+- replace "menu" by "L2/7" once you pass level 1
- shinier coins by applying glow to them ?
- It's a bit confusing at first to grasp that one upgrade is applied randomly at the start of the game
- on mobile, add an element that feels like it can be "grabbed" and make it shine while writing "Push here to play"
@@ -156,11 +163,14 @@ The "engine" could be better
- webgl rendering
- enable export of gameplay capture in webview
- endgame histograms could work as filters, when you hover a bar, all other histograms would show the stats of those runs only, without changing reference of categories
-
+- sound when ball changes color
There are many possible perks left to implement :
+- offer next level choice after upgrade pick
+- 3 random perks immediately, or maybe "all level get twice as many upgrades, but they are applied randomly, and you aren't told which ones you have."
- wrap left / right
+- wrap top / bottom : coins fall back from top of screen, ball flies to the top and comes back from the screen bottom ?
- faster coins, double value
- +1 upgrade per level but -2 choices
- n% of the broken bricks respawn when the ball touches the puck
@@ -207,6 +217,7 @@ Some extra levels wouldn't hurt
Potential big features
- final bosses (large vertical level that scrolls down faster and faster)
- split screen multiplayer
+- translation
# Credits
diff --git a/app/src/main/assets/game.js b/app/src/main/assets/game.js
index f47530d..aca1ee9 100644
--- a/app/src/main/assets/game.js
+++ b/app/src/main/assets/game.js
@@ -8,9 +8,9 @@ const coinSize = Math.round(ballSize * 0.8);
const puckHeight = ballSize;
-allLevels.forEach(l=>{
- if(!l.color && !l.svg){
- l.svg=``
+allLevels.forEach(l => {
+ if (!l.color && !l.svg) {
+ l.svg = ``
}
})
@@ -50,7 +50,7 @@ let baseSpeed = 12; // applied to x and y
let combo = 1;
function baseCombo() {
- return 1 + perks.base_combo * 3;
+ return 1 + perks.base_combo * 3 + perks.smaller_puck * 5;
}
function resetCombo(x, y) {
@@ -123,7 +123,7 @@ function pause(playerAskedForPause) {
if (!running) return
if (pauseTimeout) return
- pauseTimeout=setTimeout(()=>{
+ pauseTimeout = setTimeout(() => {
running = false
needsRender = true
if (audioContext) {
@@ -133,15 +133,15 @@ function pause(playerAskedForPause) {
}, 1000)
}
pauseRecording()
- pauseTimeout=null
- },Math.min(Math.max(0,pauseUsesDuringRun-5)*50,500))
+ pauseTimeout = null
+ }, Math.min(Math.max(0, pauseUsesDuringRun - 5) * 50, 500))
- if(playerAskedForPause) {
+ if (playerAskedForPause) {
// Pausing many times in a run will make pause slower
pauseUsesDuringRun++
}
- if(document.exitPointerLock) {
+ if (document.exitPointerLock) {
document.exitPointerLock()
}
@@ -216,7 +216,7 @@ function getRowColIndex(row, col) {
function spawnExplosion(count, x, y, color, duration = 150, size = coinSize) {
if (!!isSettingOn("basic")) return;
- if(flashes.length>MAX_PARTICLES) {
+ if (flashes.length > MAX_PARTICLES) {
// Avoid freezing when lots of explosion happen at once
count = 1
}
@@ -270,7 +270,7 @@ function addToScore(coin) {
lastPlayedCoinGrab = Date.now()
sounds.coinCatch(coin.x)
}
- runStatistics.score+=coin.points
+ runStatistics.score += coin.points
}
@@ -347,7 +347,7 @@ function pickedUpgradesHTMl() {
async function openUpgradesPicker() {
- const catchRate = (score - levelStartScore) / (levelSpawnedCoins || 1);
+ const catchRate = (score - levelStartScore) / (levelSpawnedCoins || 1);
let repeats = 1;
let choices = 3;
@@ -380,7 +380,7 @@ async function openUpgradesPicker() {
while (repeats--) {
- const actions = pickRandomUpgrades(choices+perks.one_more_choice-perks.instant_upgrade);
+ const actions = pickRandomUpgrades(choices + perks.one_more_choice - perks.instant_upgrade);
if (!actions.length) break
let textAfterButtons = `
Upgrades picked so far :
${pickedUpgradesHTMl()}
@@ -396,8 +396,8 @@ You caught ${score - levelStartScore} coins ${catchGain} out of ${levelSpawnedCo
textAfterButtons
});
perks[upgradeId]++;
- if(upgradeId==='instant_upgrade'){
- repeats+=2
+ if (upgradeId === 'instant_upgrade') {
+ repeats += 2
}
runStatistics.upgrades_picked++
@@ -437,7 +437,7 @@ function setLevel(l) {
// This caused problems with accented characters like the ô of côte d'ivoire for odd reasons
// background.src = 'data:image/svg+xml;base64,' + btoa(lvl.svg)
- background.src = 'data:image/svg+xml;UTF8,' + lvl.svg
+ background.src = 'data:image/svg+xml;UTF8,' + lvl.svg
stopRecording()
startRecordingGame()
}
@@ -473,7 +473,9 @@ const upgrades = [
"name": "+1 life",
"max": 7,
"help": "Survive dropping the ball",
- extraLevelsHelp: `One more life just in case`
+ extraLevelsHelp: `One more life just in case`,
+ fullHelp: `Normally, you just have one life, and the run is over as soon as you drop it.
+ With this perk, you can survive dropping the ball once. A heart in the top right corner will remind you of how many extra lives you have. `
},
{
"threshold": 0,
@@ -481,7 +483,11 @@ const upgrades = [
"giftable": true,
"name": "Single puck hit streak",
"max": 1,
- "help": "Break many bricks at once."
+ "help": "More coins in you break many bricks at once.",
+ fullHelp: `Every time you break a brick, your combo (number of coins per bricks) increases by one. However, as soon as the ball touches your puck,
+ the combo is reset to it's default value, and you'll just get one coin per brick. So you should to hit many bricks in one go for more score.
+ Once your combo rises above the base value, your puck will become red to remind you that it will destroy your combo to touch it with the ball.
+ This can stack with other combo related perks, the combo will rise faster but reset more easily as any of the conditions is enough to reset it. `
},
{
@@ -490,8 +496,12 @@ const upgrades = [
"giftable": true,
"name": "+3 base combo",
"max": 7,
- "help": "Your combo starts at 4",
- extraLevelsHelp: `Combo starts 3 points higher`
+ "help": "3 more coins from every brick.",
+ extraLevelsHelp: `Combo starts 3 points higher`,
+
+ fullHelp: `Your combo (number of coins per bricks) normally starts at 1 at the beginning of the level, and resets to one when you bounce around without hitting anything.
+ With this perk, the combo starts 3 points higher, so you'll always get at least 4 coins per brick. Whenever your combo reset, it will go back to 4 and not 1.
+ Your ball will glitter a bit to indicate that its combo is higher than one.`
},
{
"threshold": 0,
@@ -499,7 +509,10 @@ const upgrades = [
"name": "Slower ball",
"max": 2,
"help": "slow down the ball",
- extraLevelsHelp: `Make it even slower`
+ extraLevelsHelp: `Make it even slower`,
+
+ fullHelp: `The ball starts relatively slow, but every level of your run it will start a bit faster, and it will also accelerate if you spend a lot of time in one level. This perk makes it
+ more manageable. You can get it at the start every time by enabling kid mode in the menu.`
},
{
"threshold": 0,
@@ -507,7 +520,9 @@ const upgrades = [
"name": "Bigger puck",
"max": 2,
"help": "Catches more coins",
- extraLevelsHelp: `Even bigger puck`
+ extraLevelsHelp: `Even bigger puck`,
+ fullHelp: `A bigger puck makes it easier to never miss the ball and to catch more coins, and also to precisely angle the bounces (the ball's angle only depends on where it hits the puck).
+ However, a large puck is harder to use around the sides of the level, and will make it sometimes unavoidable to miss (not hit anything) which comes with downsides. `
},
{
"threshold": 0,
@@ -519,7 +534,9 @@ const upgrades = [
tryout: {
perks: {viscosity: 3, base_combo: 3},
level: 'Waves'
- }
+ },
+ fullHelp: `Coins normally accelerate with gravity and explosions to pretty high speeds. This perk constantly makes them slow down, as if they were in some sort of viscous liquid.
+ This makes catching them easier, and combines nicely with perks that influence the coin's movement. `
},
{
"threshold": 0,
@@ -527,7 +544,12 @@ const upgrades = [
"giftable": true,
"name": "Shoot straight",
"max": 1,
- "help": "Avoid the sides for more coins."
+ "help": "More coins in you don't touch the sides.",
+
+ fullHelp: `Whenever you break a brick, your combo will increase by one, so you'll get one more coin all the next bricks you break.
+ However, your combo will reset as soon as your ball hits the left or right side.
+ As soon as your combo rises, the sides become red to remind you that you should avoid hitting them. The effect stacks with other combo perks, combo rises faster with more upgrades but will also reset if any
+ of the reset conditions are met.`
},
{
"threshold": 0,
@@ -535,7 +557,11 @@ const upgrades = [
"giftable": true,
"name": "Sky is the limit",
"max": 1,
- "help": "Avoid the top for more coins."
+ "help": "More coins in you don't touch the top.",
+
+ fullHelp: `Whenever you break a brick, your combo will increase by one. However, your combo will reset as soon as your ball hit the top of the screen.
+ When your combo is above the minimum, a red bar will appear at the top to remind you that you should avoid hitting it.
+ The effect stacks with other combo perks.`
},
{
"threshold": 0,
@@ -544,6 +570,9 @@ const upgrades = [
"max": 7,
"help": "The last brick will self-destruct",
extraLevelsHelp: `Level clears one brick earlier`,
+ fullHelp: `You need to break all bricks to go to the next level. However, it can be hard to get the last ones.
+ Clearing a level early brings extra choices when upgrading. Never missing the bricks is also very beneficial.
+ So if you find it difficult to the the last bricks, getting this perk a few time can help.`
},
{
"threshold": 500,
@@ -553,6 +582,8 @@ const upgrades = [
"max": 2,
"help": "Control the ball's trajectory",
extraLevelsHelp: `Stronger effect on the ball`,
+ fullHelp: `Right after the ball hits your puck, you'll be able to direct it left and right by moving your puck.
+ The effect stops when the ball hits a brick and resets the next time it touches the puck. It also does nothing when the ball is going downward after bouncing at the top. `
},
{
"threshold": 1000,
@@ -562,7 +593,10 @@ const upgrades = [
"help": "Puck attracts coins",
tryout: {
perks: {coin_magnet: 3, base_combo: 3}
- }, extraLevelsHelp: `Stronger effect on the coins`,
+ },
+ extraLevelsHelp: `Stronger effect on the coins`,
+ fullHelp: `Directs the coins to the puck. The effect is stronger if the coin is close to it already. Catching 90% or 100% of coins bring special bonuses in the game.
+ Another way to catch more coins is to hit bricks from the bottom. The ball's speed and direction impacts the spawned coins's velocity. `
},
{
"threshold": 1500,
@@ -572,14 +606,19 @@ const upgrades = [
"max": 6,
"help": "Start with two balls",
extraLevelsHelp: `One more ball`,
+ fullHelp: `As soon as you drop the ball in Breakout 71, you loose. With this perk, you get two balls, and so you can afford to loose one.
+ The lost balls come back on the next level or whenever you use one of your exta lives, if you picked that perk. Having more than one balls makes
+ some further perks avaliable, and of course clears the level faster.`
},
{
"threshold": 2000,
"id": "smaller_puck",
"name": "Smaller puck",
"max": 2,
- "help": "Gives you more control",
- extraLevelsHelp: `Even smaller puck`,
+ "help": "Also gives +5 base combo",
+ extraLevelsHelp: `Even smaller puck and higher base combo`,
+ fullHelp: `This makes the puck smaller, which in theory makes some corner shots easier, but really just raises the difficulty.
+ That's why you also get a nice bonus of +5 coins per brick for all bricks you'll break after picking this. `
},
{
"threshold": 3000,
@@ -589,32 +628,41 @@ const upgrades = [
"max": 3,
"help": "Ball pierces 3 bricks",
extraLevelsHelp: `Pierce 3 more bricks`,
+ fullHelp: `The ball normally bouces as soon as it touches something. With this perk, it will continue its trajectory for up to 3 bricks broken. A
+ fter that, it will bounce on the 4th brick, and you'll need to touch the puck to reset the counter. This combines particularily well with Sapper. `
},
{
"threshold": 4000,
"id": "picky_eater",
"giftable": true,
"name": "Picky eater",
- "color_blind_exclude": true,
"max": 1,
- "help": "Break bricks color by color",
+ "help": "More coins in you break bricks color by color.",
tryout: {
perks: {picky_eater: 1},
level: 'Mountain'
- }
+ },
+ fullHelp: `Whenever you break a brick the same color as your ball, your combo increses by one. If it's a different color, the ball takes that new color, but the combo resets.
+ The bricks with the right color will get a white border. Once you get a combo higher than your minimum, the bricks of the wrong color will get a red halo. If you have more than
+ one ball, for example a blue and red ball, then you can hit both red and blue bricks and your combo won't reset. This is to make it manageable based on brick border effects alone
+ for color blind players.
+ `
},
{
"threshold": 5000,
"id": "metamorphosis",
"name": "Stain",
- "color_blind_exclude": true,
"max": 1,
"help": "Coins color the bricks they touch",
tryout: {
perks: {metamorphosis: 3},
level: 'Lines'
- }
+ },
+
+ fullHelp: `With this perk, coins will be of the color of the brick they come from, and will color the first brick they touch in the same color. Coins spawn with the speed
+ of the ball that broke them, which means you can aim a bit in the direction of the bricks you want to "paint".
+ `
},
{
"threshold": 6000,
@@ -622,8 +670,13 @@ const upgrades = [
"giftable": true,
"name": "Compound interest",
"max": 3,
- "help": "Avoid missing coins with your puck",
+ "help": "More coins in you catch them all.",
extraLevelsHelp: `Combo grows faster but missed coins hurt it more`,
+
+ fullHelp: `Your combo will grow by one every time you break a brick, spawning more and more coin with every brick you break. Be sure however to catch every one of those coins
+ with your puck, as any lost coin will decrease your combo by one point, quickly reseting it to the baseline. One your combo is above the minimum, the bottom of the play area will
+ have a red line to remind you that coins should not go there. This perk combines with other combo perks, the combo will rise faster but reset mor easily.
+ `
},
{
"threshold": 7000,
@@ -631,8 +684,13 @@ const upgrades = [
"giftable": true,
"name": "Hot start",
"max": 3,
- "help": "Clear the level quickly",
+ "help": "More coins for 15s.",
extraLevelsHelp: `Combo starts higher but shrinks faster`,
+
+ fullHelp: `At the start of every level, your combo will start at +15 points, but then every second it will be decreased by one. This means the first 15 seconds in a level will spawn
+ many more coins that the following ones, and you should make sure that you clear the level quickly. The effect stacks with other combo related perks, so you might be able to raise
+ the combo after the 15s timeout, but it will keep ticking down. Every time you take the perk again, the effect will be more dramatic.
+ `
},
{
"threshold": 9000,
@@ -642,6 +700,10 @@ const upgrades = [
"max": 7,
"help": "1st brick hit becomes bomb",
extraLevelsHelp: `1 more brick replaced by a bomb`,
+ fullHelp: `Instead of just dissappearing, the first brick you break will be replaced by a bomb brick. Bouncing the ball on the puck re-arms the effect. "Piercing" will instantly
+ detonate the bomb that was just placed. Leveling up this perk will allow you to place more bombs. Rember that bombs impact the velocity of nearby coins, so too many explosions
+ could make it hard to catch the fruits of your hard work.
+ `
},
{
"threshold": 11000,
@@ -652,7 +714,8 @@ const upgrades = [
tryout: {
perks: {bigger_explosions: 1},
level: 'Ship'
- }
+ },
+ fullHelp: `The default explosion clears a 3x3 square, with this it becomes a 5x5 square, and the blowback on the coins is also significantly stronger. `
},
{
"threshold": 13000,
@@ -661,14 +724,17 @@ const upgrades = [
"max": 3,
"help": "Play 8 levels instead of 7",
extraLevelsHelp: `1 more level to play`,
+ fullHelp: `The default run can last a max of 7 levels, after which the game is over and whatever score you reached is your run score.
+ Each level of this perk lets you go one level higher. The last levels are often the ones where you make the most score so the difference can be dramatic.`
},
{
"threshold": 15000,
"id": "pierce_color",
"name": "Color pierce",
- "color_blind_exclude": true,
"max": 1,
- "help": "Ball breaks same color bricks"
+ "help": "Ball breaks same color bricks",
+ fullHelp: `Whenever a ball hits a brick of the same color, it will just go through unimpeded.
+ Once it reaches a brick of a different color, it will break it, take its color and bounce.`
},
{
"threshold": 18000,
@@ -677,6 +743,7 @@ const upgrades = [
"max": 2,
"help": "Combo grows slower but resets less",
extraLevelsHelp: `Even slower combo growth but softer reset`,
+ fullHelp: `The combo normally climbs every time you break a brick. This will sometimes cancel that climb, but also limit the impact of a combo reset.`
},
{
"threshold": 21000,
@@ -688,7 +755,9 @@ const upgrades = [
extraLevelsHelp: 'Stronger repulsion force ',
tryout: {
perks: {ball_repulse_ball: 1, multiball: 2},
- }
+ },
+ fullHelp: `Balls that are less than half a screen width away will start repulsing each other. The repulsion force is stronger if they are close to each other.
+ Particles will jet out to symbolise this force being applied. This perk is only offered if you have more than one ball already.`
},
{
"threshold": 25000,
@@ -699,7 +768,9 @@ const upgrades = [
"help": "Balls attract balls.", extraLevelsHelp: 'Stronger attraction force ',
tryout: {
perks: {ball_attract_ball: 1, multiball: 2},
- }
+ },
+ fullHelp: `Balls that are more than half a screen width away will start attracting each other. The attraction force is stronger when they are furthest away from each other.
+ Rainbow particles will fly to symbolise the attraction force force. This perk is only offered if you have more than one ball already.`
},
{
"threshold": 30000,
@@ -708,13 +779,17 @@ const upgrades = [
extraLevelsHelp: 'Stronger repulsion force ',
"max": 3,
"help": "Puck repulses balls.",
+ fullHelp: `When a ball gets close to the perk, it will start slowing down, and even potentially bouncing without touching the puck.`
},
{
"threshold": 35000,
"id": "wind",
"name": "Wind",
"max": 3,
- "help": "Puck position creates wind.", extraLevelsHelp: 'Stronger wind force ',
+ "help": "Puck position creates wind.",
+ extraLevelsHelp: 'Stronger wind force ',
+ fullHelp: `The wind depends on where your puck is, if it's in the center of the screen nothing happens, if it's on the left it will blow leftwise, if its on the right of the screen
+ then it will blow rightwise. The wind affects both the balls and coins.`
},
{
"threshold": 40000,
@@ -723,13 +798,20 @@ const upgrades = [
"max": 4,
"help": "Bricks sometimes resist hits but drop more coins.",
extraLevelsHelp: 'Bricks resist more and drop more coins ',
+ fullHelp: `With level one of this perk, the ball has a 20% chance to bounce harmlessly on bricks,
+ but generates 10% more coins when it does break one.
+ This +10% is not shown in the combo number. At level 4 the ball has 80% chance of bouncing and brings 40% more coins.`
},
{
"threshold": 45000,
"id": "respawn",
"name": "Respawn",
"max": 4,
- "help": "The first brick hit will respawn.", extraLevelsHelp: 'More bricks can respawn ',
+ "help": "The first brick hit of two+ will respawn.",
+ extraLevelsHelp: 'More bricks can respawn ',
+ fullHelp: `After breaking two or more bricks, when the ball hits the puck, the first brick will be put back in place, provided that space is free and the brick wasn't a bomb.
+ Some particle effect will let you know where bricks will appear. Levelling this up lets you respawn up to 4 bricks at a time, but there should always be at least on destroyed.
+ `
},
{
"threshold": 50000,
@@ -738,6 +820,9 @@ const upgrades = [
"max": 3,
"help": "Further level ups will offer one more option in the list",
extraLevelsHelp: 'Even more options ',
+ fullHelp: `Every upgrades menu will have one more option.
+ Doesn't increase the number of upgrades you can pick.
+ `
},
{
"threshold": 55000,
@@ -746,6 +831,9 @@ const upgrades = [
"max": 2,
"help": "-1 choice permanently",
extraLevelsHelp: 'Even fewer options ',
+ fullHelp: `Immediately pick two upgrades, so that you get one free one and one to repay the one used to get this perk.
+ Every further menu to pick upgrades will have fewer options to choose from.
+ `
},
]
@@ -754,7 +842,6 @@ let totalScoreAtRunStart = getTotalScore()
function getPossibleUpgrades() {
return upgrades
- .filter(u => !(isSettingOn('color_blind') && u.color_blind_exclude))
.filter(u => totalScoreAtRunStart >= u.threshold)
.filter(u => !u.requires || perks[u.requires])
}
@@ -782,7 +869,6 @@ function getUpgraderUnlockPoints() {
let list = []
upgrades
- .filter(u => !(isSettingOn('color_blind') && u.color_blind_exclude))
.forEach(u => {
if (u.threshold) {
list.push({
@@ -825,7 +911,7 @@ function pickRandomUpgrades(count) {
return list.map(u => ({
text: u.name + (perks[u.id] ? ' lvl ' + (perks[u.id] + 1) : ''),
icon: u.icon,
- value: u.id ,
+ value: u.id,
help: (perks[u.id] && u.extraLevelsHelp) || u.help,
// max: u.max,
// checked: perks[u.id]
@@ -835,7 +921,7 @@ function pickRandomUpgrades(count) {
}
let nextRunOverrides = {level: null, perks: null}
-let hadOverrides = false, pauseUsesDuringRun=0
+let hadOverrides = false, pauseUsesDuringRun = 0
function restart() {
hadOverrides = !!(nextRunOverrides.level || nextRunOverrides.perks)
@@ -845,7 +931,7 @@ function restart() {
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
resetRunStatistics()
score = 0;
- pauseUsesDuringRun=0
+ pauseUsesDuringRun = 0
const randomGift = reset_perks();
@@ -855,7 +941,8 @@ function restart() {
pauseRecording()
}
-let keyboardPuckSpeed=0
+let keyboardPuckSpeed = 0
+
function setMousePos(x) {
needsRender = true;
@@ -879,19 +966,17 @@ canvas.addEventListener("mouseup", (e) => {
pause(true)
} else {
play()
- if(isSettingOn('pointerLock')){
+ if (isSettingOn('pointerLock')) {
canvas.requestPointerLock()
}
}
});
canvas.addEventListener("mousemove", (e) => {
- if(document.pointerLockElement === canvas){
- setMousePos(puck+e.movementX);
- }else{
-
-
- setMousePos(e.x);
+ if (document.pointerLockElement === canvas) {
+ setMousePos(puck + e.movementX);
+ } else {
+ setMousePos(e.x);
}
});
@@ -918,16 +1003,6 @@ canvas.addEventListener("touchmove", (e) => {
let lastTick = performance.now();
function brickIndex(x, y) {
- //this worked great but coins got stuck in corner between bricks, will need to rework it
- // if(!currentLevelInfo().squared){
- //
- // const offsetToLeftSide = (x - offsetX) % brickWidth
- // const offsetToTopSide = y % brickWidth
- // const bricksMargin=12/(12+120)*brickWidth/2
- // if(offsetToLeftSide< bricksMargin || offsetToLeftSide>brickWidth-bricksMargin || offsetToTopSide< bricksMargin || offsetToTopSide>brickWidth-bricksMargin ){return -1}
- //
- // }
- //
return getRowColIndex(Math.floor(y / brickWidth), Math.floor((x - offsetX) / brickWidth))
}
@@ -1050,12 +1125,12 @@ function tick() {
puckWidth = (gameZoneWidth / 12) * (3 - perks.smaller_puck + perks.bigger_puck);
- if(keyboardPuckSpeed){
- setMousePos(puck+keyboardPuckSpeed)
+ if (keyboardPuckSpeed) {
+ setMousePos(puck + keyboardPuckSpeed)
}
- if (running ) {
+ if (running) {
levelTime += currentTick - lastTick;
runStatistics.runTime += currentTick - lastTick
@@ -1105,7 +1180,11 @@ function tick() {
coin.vy *= ratio;
coin.vx *= ratio;
- coin.a+=coin.sa
+ if(coin.vx>7*baseSpeed) coin.vx=7*baseSpeed
+ if(coin.vx<-7*baseSpeed) coin.vx=-7*baseSpeed
+ if(coin.vy>7*baseSpeed) coin.vy=7*baseSpeed
+ if(coin.vy<-7*baseSpeed) coin.vy=-7*baseSpeed
+ coin.a += coin.sa
// Gravity
coin.vy += delta * coin.weight * 0.8;
@@ -1135,7 +1214,7 @@ function tick() {
if (typeof hitBrick !== "undefined" || hitBorder) {
coin.vx *= 0.8;
coin.vy *= 0.8;
- coin.sa*=0.9
+ coin.sa *= 0.9
if (speed > 20 && !playedCoinBounce) {
playedCoinBounce = true;
sounds.coinBounce(coin.x, 0.2);
@@ -1184,6 +1263,63 @@ function tick() {
}
});
}
+
+
+ if (combo > baseCombo()) {
+ // The red should still be visible on a white bg
+ const baseParticle = !isSettingOn('basic') && (combo - baseCombo()) * Math.random() > 5 && running && {
+ type: "particle",
+ duration: 100 * (Math.random() + 1),
+ time: levelTime,
+ size: coinSize / 2,
+ color: 'red',
+ ethereal: true,
+ }
+
+ if (perks.top_is_lava) {
+ baseParticle && flashes.push({
+ ...baseParticle,
+ x: offsetXRoundedDown + Math.random() * gameZoneWidthRoundedUp,
+ y: 0,
+ vx: (Math.random() - 0.5) * 10,
+ vy: 5,
+ })
+ }
+ if (perks.sides_are_lava) {
+ const fromLeft = Math.random() > 0.5
+ baseParticle && flashes.push({
+ ...baseParticle,
+ x: offsetXRoundedDown + (fromLeft ? 0 : gameZoneWidthRoundedUp),
+ y: Math.random() * gameZoneHeight,
+ vx: fromLeft ? 5 : -5,
+ vy: (Math.random() - 0.5) * 10,
+ })
+ }
+ if (perks.catch_all_coins) {
+ let x = puck
+ do {
+ x = offsetXRoundedDown + gameZoneWidthRoundedUp * Math.random()
+ } while (Math.abs(x - puck) < puckWidth / 2)
+ baseParticle && flashes.push({
+ ...baseParticle,
+ x,
+ y: gameZoneHeight,
+ vx: (Math.random() - 0.5) * 10,
+ vy: -5,
+ })
+ }
+ if (perks.streak_shots) {
+ const pos = (0.5 - Math.random())
+ baseParticle && flashes.push({
+ ...baseParticle,
+ duration: 100,
+ x: puck + puckWidth * pos,
+ y: gameZoneHeight - puckHeight,
+ vx: (pos) * 10,
+ vy: -5,
+ })
+ }
+ }
}
render();
@@ -1237,6 +1373,28 @@ function ballTick(ball, delta) {
}, perks.puck_repulse_ball, false)
}
+ if (perks.respawn && ball.hitItem?.length > 1 && !isSettingOn('basic')) {
+ for (let i = 0; i < ball.hitItem?.length - 1 && i < perks.respawn; i++) {
+ const {index, color} = ball.hitItem[i]
+ if (bricks[index] || color === 'black') continue
+ const vertical = Math.random() > 0.5
+ const dx = Math.random() > 0.5 ? 1 : -1
+ const dy = Math.random() > 0.5 ? 1 : -1
+
+ flashes.push({
+ type: "particle",
+ duration: 250,
+ ethereal: true,
+ time: levelTime,
+ size: coinSize / 2,
+ color,
+ x: brickCenterX(index) + dx * brickWidth / 2,
+ y: brickCenterY(index) + dy * brickWidth / 2,
+ vx: vertical ? 0 : -dx * baseSpeed,
+ vy: vertical ? -dy * baseSpeed : 0,
+ });
+ }
+ }
const borderHitCode = bordersHitCheck(ball, ballSize / 2, delta);
if (borderHitCode) {
@@ -1264,9 +1422,11 @@ function ballTick(ball, delta) {
}
if (perks.respawn) {
-
ball.hitItem.slice(0, -1).slice(0, perks.respawn)
- .forEach(({index, color}) => bricks[index] = bricks[index] || color)
+ .forEach(({index, color}) => {
+ if (!bricks[index] && color !== 'black')
+ bricks[index] = color
+ })
}
ball.hitItem = []
if (!ball.hitSinceBounce) {
@@ -1402,8 +1562,8 @@ function gameOver(title, intro) {
if (!running) return;
pause(true)
stopRecording()
-addToTotalPlayTime(runStatistics.runTime)
- runStatistics.max_level = currentLevel+1
+ addToTotalPlayTime(runStatistics.runTime)
+ runStatistics.max_level = currentLevel + 1
let animationDelay = -300
const getDelay = () => {
@@ -1449,7 +1609,6 @@ addToTotalPlayTime(runStatistics.runTime)
}
-
// Avoid the sad sound right as we restart a new games
combo = 1
asyncAlert({
@@ -1463,20 +1622,22 @@ addToTotalPlayTime(runStatistics.runTime)
}).then(() => restart());
}
-function getHistograms(saveStats){
+function getHistograms(saveStats) {
- if (hadOverrides) {return''}
+ if (hadOverrides) {
+ return ''
+ }
- let runStats=''
+ let runStats = ''
try {
// Stores only top 100 runs
let runsHistory = JSON.parse(localStorage.getItem('breakout_71_runs_history') || '[]');
- runsHistory.sort((a,b)=>a.score-b.score).reverse()
- runsHistory=runsHistory.slice(0, 10)
- runsHistory.push(runStatistics)
+ runsHistory.sort((a, b) => a.score - b.score).reverse()
+ runsHistory = runsHistory.slice(0, 10)
+ runsHistory.push(runStatistics)
// Generate some histogram
- if(saveStats) {
+ if (saveStats) {
localStorage.setItem('breakout_71_runs_history', JSON.stringify(runsHistory, null, 2))
}
const makeHistogram = (title, getter, unit) => {
@@ -1484,38 +1645,38 @@ function getHistograms(saveStats){
let min = Math.min(...values)
let max = Math.max(...values)
// No point
- if(min===max) return '';
- if(max-min<10) {
- // This is mostly useful for levels
- min=Math.max(0,max-10)
- max=Math.max(max,min+10)
+ if (min === max) return '';
+ if (max - min < 10) {
+ // This is mostly useful for levels
+ min = Math.max(0, max - 10)
+ max = Math.max(max, min + 10)
}
// One bin per unique value, max 10
- const binsCount = Math.min(values.length,10)
- if(binsCount<3) return ''
+ const binsCount = Math.min(values.length, 10)
+ if (binsCount < 3) return ''
const bins = []
const binsTotal = []
- for(let i=0;i Math.min(bins.length - 1, Math.floor((v - min) / binSize))
values.forEach(v => {
- if(isNaN(v)) return
- const index=binIndexOf(v)
+ if (isNaN(v)) return
+ const index = binIndexOf(v)
bins[index]++
- binsTotal[index]+=v
+ binsTotal[index] += v
})
- if(bins.filter(b=>b).length<3) return ''
+ if (bins.filter(b => b).length < 3) return ''
const maxBin = Math.max(...bins)
const lastValue = values[values.length - 1]
const activeBin = binIndexOf(lastValue)
return `