diff --git a/Readme.md b/Readme.md
index a29f201..b90c49e 100644
--- a/Readme.md
+++ b/Readme.md
@@ -10,20 +10,14 @@ Break colourful bricks, catch bouncing coins and select powerful upgrades !
- [F-Droid](https://f-droid.org/en/packages/me.lecaro.breakout/)
- [Google Play](https://play.google.com/store/apps/details?id=me.lecaro.breakout)
- [GitLab](https://gitlab.com/lecarore/breakout71)
-
-# Current priorities
-
-The goal of this project is to make a game used by many people.
-The game is already pretty fun.
-
-I'm now trying to translate it to (Lebanese) Arabic, Russian and (Chilean) Spanish.
-Other translation are very welcome, contact me if you'd like to submit one.
-
# Changelog
## To do
## Done
+- apply percentage boost to combo shown on brick
+- smaller puck now gives +50% coins per level
+- transparency now gives +50% coins if ALL balls are fully transparent, less otherwise
- new perk : sticky coins (coins stick to bricks)
- left/top/right is laval perks : at level 2+, the corresponding borders completely disappears (reachable with limitless)
- new perk : three cushion (gain point for indirect hits)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 8058c74..e0e732c 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -29,8 +29,8 @@ android {
applicationId = "me.lecaro.breakout"
minSdk = 21
targetSdk = 34
- versionCode = 29085904
- versionName = "29085904"
+ versionCode = 29087244
+ versionName = "29087244"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html
index ce5cadd..9e51522 100644
--- a/app/src/main/assets/index.html
+++ b/app/src/main/assets/index.html
@@ -1 +1 @@
-
Breakout 71
\ No newline at end of file
+Breakout 71
\ No newline at end of file
diff --git a/dist/index.html b/dist/index.html
index 558f431..108b14a 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -1130,7 +1130,7 @@ async function openMainMenu() {
}
function donationNag(gameState) {
if (!(0, _options.isOptionOn)("donation_reminder")) return [];
- const hours = (0, _pureFunctions.hoursSpentPlaying)();
+ const hours = (0, _gameUtils.hoursSpentPlaying)();
return [
{
text: (0, _i18N.t)("main_menu.donate", {
@@ -1578,7 +1578,7 @@ module.exports = JSON.parse("{\"_\":\"\",\"B\":\"black\",\"W\":\"#FFFFFF\",\"g\"
module.exports = JSON.parse('[{"name":"71 mini","size":5,"bricks":"bbb____bt__btt__b_t___ttt","color":""},{"name":"Butterfly","bricks":"_________bb_t_t_bbbbb_t_bbbbbbbtbbbb_bbbtbbb____btb____bbbtbbb__bb_t_bb__________","size":9,"color":""},{"name":"Castle","size":7,"bricks":"s_s_s_ssssssssssBBBssssBBBssttbbbttttbbbtttbtbtbt","color":""},{"name":"Eyes","size":9,"bricks":"ttttttt__tWWWWWWW_tWrrWttW_tWWWWWWW_ttttttt_____t______ttttt____ttttt_____t_t","color":"","credit":"My favorite character in https://nuclearthrone.com/"},{"name":"Creeper","size":10,"bricks":"___________ccGGccGG__cGccGcGc__GBBccBBc__cBBGcBBc__GccBBGGc__ccBBBBcG__GGBBBBcG__cGBccBGc___________","credit":"https://en.wikipedia.org/wiki/Creeper_(Minecraft)","color":""},{"name":"Stairs","size":8,"bricks":"tt______tt______bbtt____bbtt____vvbbtt__vvbbtt__ppvvbbttppvvbbtt","color":""},{"name":"Dots","size":9,"bricks":"b_t_a_c_c__________b_t_a_c__________P_b_t_a_c__________P_b_t_a__________P_P_b_t_a","color":""},{"name":"Lines","size":9,"bricks":"aaaaaaaa___________tttttttt_________aaaaaaaa___________tttttttt_________aaaaaaaa","color":""},{"name":"Heart","size":15,"bricks":"__________________RRR___RRR_____RSSSR_RSSSR___RSWWSSRSSSSSR__RSWSSSSSSSSSR__RSSSSSSSSSSSR__RSWSSSSSSSSSR___RSSSSSSSSSR_____RSSSSSSSR_______RSSSSSR_________RSSSR___________RSR_____________R____________________________________","color":"","credit":"https://www.youtube.com/watch?v=gdWiTfzXb1g"},{"name":"Swiss","size":7,"bricks":"________RRRRR__RRWRR__RWWWR__RRWRR__RRRRR________","color":""},{"name":"Germany","size":4,"bricks":"____ggggrrrryyyy","color":"#5da3ea"},{"name":"France","size":6,"bricks":"______ttWWrrttWWrrttWWrrttWWrrttWWrr","color":""},{"name":"Smiley","size":8,"bricks":"_________yy__yy__yy__yy__________________yyyyyy___yyyy__________","color":""},{"name":"Labyrinthe","size":11,"bricks":"_______tttS_Stttt_S________t___S__Stt_ttttt____t_____S__ttt_S_S____t___t_tttt_t_S_t____tSt_t_t_Sttt___t_t_____Sttt_tttttS"},{"name":"Temple","size":11,"bricks":"_______________WWW______WWWWWWW___WWWWWWWWW___b_b_b_b____b_b_b_b____v_v_v_v____P_P_P_P____P_P_P_P____WWWWWWW___WWWWWWWWW_","color":""},{"name":"Pacman","size":12,"bricks":"____yyyy______yyyyyyyy___yyyyByyyyy__yyyyyyyyy__yyyyyyyy____yyyyyy______yyyyyy___S_Syyyyyyyy_____yyyyyyyyy___yyyyyyyyyy___yyyyyyyy______yyyy","color":"","credit":"https://en.wikipedia.org/wiki/Pacman"},{"name":"Ship","size":11,"bricks":"____sWW________sWWW_______sWWW_______s___OOOOOOOOOOOOOO_OBOBOBOBOO__OOOOOOOO_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb___________"},{"name":"We come in peace","size":13,"bricks":"________________a_____a_______a___a_______aaaaaaa_____aaBaaaBaa___aaaaaaaaaaa__aaaaaaaaaaa__a_aaaaaaa_a__a_a_____a_a_____aa_aa_____________________________","color":"","credit":"https://en.wikipedia.org/wiki/Space_invaders"},{"name":"Space mushroom","size":10,"bricks":"______________WW_______WWWW_____WWWWWW___WWBWWBWW__WWWWWWWW____W__W_____W_WW_W___W_W__W_W","color":"","credit":"https://en.wikipedia.org/wiki/Space_invaders"},{"name":"Wololo","size":9,"bricks":"____WW_OOW___WW__OWW__W___OWWWbbbW_WWW_WbW_WOW__WWb__OW__bbb__O___W_W__O___W_W__O","color":"","credit":"https://aoe.heavengames.com/theacademy/unitsboatsandbuildings/priest/"},{"name":"Small heart","size":15,"bricks":"________________________________RRRR___RRRR___RrWWrR_RWWrrR__RWWrrrRWWrrrR__RrrrrrrrrrrrR__RrrrrrrrrrrrR___RrrrrrrrrrR_____RrrrrrrrR_______RrrrrrR_________RrrrR___________RrR_____________R______________________","color":""},{"name":"Eye","size":9,"bricks":"____________ggg_____gWWWg___gWbbbWg_gWWbBbWWg_gWbbbWg___gWWWg_____ggg____________","color":"#5da3ea"},{"name":"Enderman","size":10,"bricks":"___________gggggggg__gggggggg__gggggggg__gggggggg__vvvggvvv__gggggggg__gggggggg__gggggggg_____________________","color":"#154b07","credit":"https://minecraft.wiki/w/Enderman"},{"name":"Mushroom","size":16,"bricks":"_____________________rrrrWW________WWrrrrWWWW_____WWrrrrrrWWWW____WrrWWWWrrWWW___rrrWWWWWWrrrrr__rrrWWWWWWrrWWr__WrrWWWWWWrWWWW__WWrrWWWWrrWWWW__WWrrrrrrrrrWWr__WrrWWWWWWWWrrr_____WWBWWBWW_______WWWBWWBWWW______WWWWWWWWWW_______WWWWWWWW____________________","color":"","credit":"https://pixelartmaker.com/art/cce4295a92035ea"},{"name":"Tulip","size":11,"bricks":"______________R_R_R______RRRRR______RRRRR______RRRRR_______RRR_________k________k_k_k______k_k_k_______kkk_________k________________","color":""},{"name":"Chain","size":7,"bricks":"yyy____yBy____yyyyy____yBy____yyyyy____yBy____yyy","color":""},{"name":"Marion","size":9,"bricks":"rr_____rr_rr___rr__rrr_rrr__rrrrrrr__rr_r_rr__rr___rr__rr___rr__rr___rr_rrr___rrr","color":""},{"name":"Renan","size":9,"bricks":"yyyyyyy___yyyyyyy__yy___yy__yy___yy__yyyyyy___yy_yy____yy__yy___yy___yy_yyy___yyy","color":""},{"name":"Violet Pairs","size":8,"bricks":"b_b_b_b_b_b_b_b__________t_t_t_t_t_t_t_t________b_b_b_b_b_b_b_b","color":""},{"name":"Red Cups","size":11,"bricks":"___________rBr_rBr_rBrrrr_rrr_rrr___________r_rBr_rBr_rr_rrr_rrr_r___________rBr_rBr_rBrrrr_rrr_rrr__________","color":""},{"name":"Cactus","size":10,"bricks":"____G______rG_Gk______G_Gk______kkkk_r_____kkk_G______GkGk_____rGkk_______Gk________kk________kk_____","color":""},{"name":"Sunny Face","size":11,"bricks":"____yyy______yyyyyyy___yyyyyyyyy__yyyyyyyyy_yyyWWyWWyyyyyyyyyyyyyyyyyyyyyyyyy_yyWWWWWyy__yyyWWWyyy___yyyyyyy______yyy","color":"#5da3ea"},{"name":"Mountain","size":9,"bricks":"_______________W_______WWW______GGWW__W_GGGGG_kkkGGGGG_kkkkGGGGkkkkkGGGGkkkkkkGGG_________","color":""},{"name":"Dollar","size":17,"bricks":"________________________G_G______________G_G____________GGGGGGG_________GGGGGGGGG_______GG__G_G__GG______GG__G_G__GG______GG__G_G___________GGGGGGGG__________GGGGGGGG___________G_G__GG______GG__G_G__GG______GG__G_G__GG_______GGGGGGGGG_________GGGGGGG____________G_G______________G_G________________________","color":""},{"name":"Waves","size":8,"bricks":"___bbb____bbb____bbttbbbbbttbbbbttttaatttttaattttaaaaaaa","color":""},{"name":"Box","size":8,"bricks":"yyyyyyyyy______yy_bbbb_yy_b__b_yy_b__b_yy_bbbb_yy______yyyyyyyyy","color":"","squared":false},{"name":"Rose","size":9,"bricks":"__SS______SSSS_____SSSS_____SSSS______SS_k______k_kk_____kk_k______kk________k","color":""},{"name":"Time","size":9,"bricks":"__________WWWWWWW___WWWWW_____yyy_______y________y_______WyW_____WyyyW___yyyyyyy__________","color":"","squared":false},{"name":"Watermelon","size":8,"bricks":"_____Sk_____SSBk___SBSSk__SSSSSk_SSBSSk_SBSSSSk_kSSSkk___kkk____","color":""},{"name":"Worms","size":13,"bricks":"___sssss_______sssssss______WWsWWsss_____WBsBWsss_____WBsBWsss_____WWsWWsss_____sssssss_______ssssss_____WWWWWWss_______WssWs__s_____ssss__sss___sssssssssss__sssssssss_ss","color":"","squared":false,"credit":"https://en.wikipedia.org/wiki/Worms_(series)"},{"name":"Ocean Sunrise","size":8,"bricks":"SSSSSSSSSSSyySSSSSyyyySSSyyyyyySbttttttbbbttttbbbbbttbbbbbbbbbbb","color":""},{"name":"Crosses","size":13,"bricks":"b___b___b___b__v___v___v___vvv_vvv_vvv___v___v___v__p___p___p___ppp_ppp_ppp_ppp___p___p___p__P___P___P___PPP_PPP_PPP___P___P___P__p___p___p___ppp_ppp_ppp_ppp___p___p___p","color":""},{"name":"Negative space","size":9,"bricks":"tttttttttt_t_t_t_t_________b_b_b_b_bbbbbbbbbb_b_b_b_b___________t_t_t_t_ttttttttt_________"},{"name":"UK","size":11,"bricks":"brbbWrWbbrbbbrbWrWbrbbbbbrWrWrbbbWWWWWrWWWWWrrrrrrrrrrrWWWWWrWWWWWbbbrWrWrbbbbbrbWrWbrbbbrbbWrWbbrb__________","color":""},{"name":"Greece","size":11,"bricks":"ttWttttttttttWttWWWWWWWWWWWttttttttWttWWWWWWttWttttttttWWWWWWWWWWWtttttttttttWWWWWWWWWWWttttttttttt__________","color":""},{"name":"Russia","size":8,"bricks":"________WWWWWWWWWWWWWWWWttttttttttttttttrrrrrrrrrrrrrrrr________________","color":""},{"name":"Ukraine","size":8,"bricks":"________ttttttttttttttttttttttttyyyyyyyyyyyyyyyyyyyyyyyy________","color":""},{"name":"Poland","size":7,"bricks":"________WWWWW__WWWWW__rrrrr__rrrrr_______________","color":""},{"name":"Yellow 71","size":9,"bricks":"_________yyyyy__yyyyyyy_yyy___yy__yy__yyy__yy_yyy___yy_yy____yy_yy____yy__________________","color":""},{"name":"71 on white","size":6,"bricks":"WWWWWWrrrWWrWWrWrrWrWWWrWrWWWrWWWWWW______"},{"name":"Blue 71","size":8,"bricks":"ttttt__bttttt_bb___ttbbb__tt__bb__tt__bb_tt___bb_tt___bb_tt___bb","color":""},{"name":"Seventy one","size":21,"bricks":"rr_yy_rrry_yrrry_yrrrr_ry_yr__y_yr_ry_y_r_rr_yy_rr_yy_r_ry_y_r_r_ry_yr__y_yr_ry_y_r_rr_y_yrrry_yrrryyy_r_yyy__________________y______________r_____yyyrrry_yrrryyyrr_y_y__yrr_y_yrr_y_yr__y_yyyyrrr_y_rrry_yrrryyy____________________yrrryyyrrr_________yy_r_ry_yrr_____________rrry_yrrryyyyyyyyyyyy_____________________________________________________________________________________________________________________________"},{"name":"B71","size":10,"bricks":"__________bbbtttt_b_b__b__tbb_b__b__t_b_bbb__t__b_b__b_t__b_b__bt___b_bbb_t__bbb__________"},{"name":"Pig","size":9,"bricks":"__________PP___PP__PPP_PPP__WWPPPWW__WBPPPBW__PPsssPP__PsBsBsP__PPsssPP___________"},{"name":"Big Pig","size":15,"bricks":"________________sss_______sss__ss__sssss__ss____sssssssss_____sWBsssssBWs___ssBBsssssBBss__ssss_____ssss__sss_sssss_sss__sss_sBsBs_sss__sss_sssss_sss___sss_____sss____sssssssssss__GGGsssssssssGGGGGGsGsssssGsGGGGGGssGGGGGssGGG_______________","color":""},{"name":"Donkey Kong","size":9,"bricks":"OOr__a___OOr__a___ppppppp_O______a________a____pppppppr_a______b_a___O__ppppppp__","color":""},{"name":"Banana","size":12,"bricks":"_________________e__________eee_________eee_________eee_________eeeyy_____yyeeyyyy___yyyyey_yC___yy_yyy___C_____yyyy_________yyyy_________yyyy"},{"name":"Fox","size":8,"bricks":"e______eee_OO_eeeeOOOOeeeOBOOBOeOOOOOOOO_WWBBWW___WWWW_____WW___"},{"name":"Wiki","size":10,"bricks":"_______________________GGGG_____GGkkGG___GkggggkG__GgWWWWgG__GkggggkG___GGkkGG_____GGGG_______________________","color":"#1c71d8"},{"name":"Baby Dog","size":8,"bricks":"_______W__eeeeWWWWeeWeWWWeBWeBeeeeWWWWee_eWBBWe__eWWWWe____WW___"},{"name":"dog 21","size":9,"bricks":"__________O_____O_OOOWWWOOOOOWWWWWOOOOeWWWWOO_eBeWWBW__eBeWWBW___eWBWW_____WRW____________","credit":"https://prohama.com/dog-21-pattern/"},{"name":"icon:extra_life","size":9,"bricks":"___________rr_rr___rrrrrrr_rrrrrrrrrrrrrrrrrr_rrrrrrr___rrrrr_____rrr_______r_____________"},{"name":"icon:streak_shots","size":8,"bricks":"_W_W_W__W_W_W_W_tttttt_WttttttW________W______W______W_____WWWW_"},{"name":"icon:base_combo","size":7,"bricks":"________bbbbb__bybyb__bbbbb__bybyb__bbbbb________"},{"name":"icon:slow_down","size":10,"bricks":"_____________kk_______kkkk_____kkkkkkGG__kkkkkkGBG_kkkkkkGGGGkkkkkkGG__GGGGGG____GG__GG_____________"},{"name":"icon:bigger_puck","size":8,"bricks":"_________tttttt__tttttt______________________W___________WWWWWW_"},{"name":"icon:viscosity","size":8,"bricks":"________tt______bbtt__ttbbbbttbbbtbbtbbbbbtbbtbbbbbybbybbbbbbbbb"},{"name":"icon:left_is_lava","size":8,"bricks":"r_______rtttttt_rtttttt_r_______r_______r____W__r_______r_WWW___"},{"name":"icon:right_is_lava","size":8,"bricks":"_______r_ttttttr_ttttttr_______r_______r_____W_r_______r__WWW__r"},{"name":"icon:telekinesis","size":8,"bricks":"_____PW_____s______P______s_______P_______s_______P_____WWWWW"},{"name":"icon:top_is_lava","size":8,"bricks":"rrrrrrrr_tttttt__tttttt____________________W_______________WWW__"},{"name":"icon:coin_magnet","size":8,"bricks":"__y__y_yy_________y_y_y_y________y_y______________y______WWW____"},{"name":"icon:skip_last","size":5,"bricks":"_ttt_t_t_ttt_ttt_t_t_ttt_"},{"name":"icon:multiball","size":8,"bricks":"_________tttttt__tttttt___________W__W____________________WWW___"},{"name":"icon:smaller_puck","size":8,"bricks":"_________tttttt__tttttt_____________W_____________________WW____"},{"name":"icon:pierce","size":6,"bricks":"ttttttttttWtttt__ttt__ttt__ttt__tttt"},{"name":"icon:picky_eater","size":8,"bricks":"_rrr_______ry_____ryy_____r_y______yyy______________y_____WWWW__"},{"name":"icon:metamorphosis","size":8,"bricks":"aaaaaa__aaaa__________W___________ttaatt__tttttt_________WWW"},{"name":"icon:compound_interest","size":8,"bricks":"_________tttttt__ttt__t______y_____________W__y_________rrWWWrrr"},{"name":"icon:hot_start","size":7,"bricks":"ttttttttttt_tt_____W_____y_y_____y_____y_y_WWW_y_"},{"name":"icon:sapper","size":9,"bricks":"_____WW______W__W_tttWttt_yttgggtt__tgggggt__tgggggt__tgggggt__ttgggtt__ttttttt___________","color":"#000000"},{"name":"icon:bigger_explosions","size":8,"bricks":"__r_______ry_rr___ryry__ryyyWBrr_rrWyyy__Byryrr__yrryBrr_rr_____"},{"name":"icon:extra_levels","size":6,"bricks":"__________b__t_bb_ttt_b__t_bbb____________"},{"name":"icon:pierce_color","size":8,"bricks":"bb___bbbb__b_bbb_____bbb____bbbbb____bbbbb____bbbbb____bbbbb____"},{"name":"icon:soft_reset","size":9,"bricks":"__rr______rrr_yy__rrrr_yyy_rrrr_yyyy_____yyyy_yyyyyyyy_yyyyyyyy__yyyyyy____yyyy__"},{"name":"icon:ball_repulse_ball","size":8,"bricks":"WsP__PsWs______sP______P________________P______Ps______sWsP__PsW"},{"name":"icon:ball_attract_ball","size":8,"bricks":"__P__P____s__s__PsW__WsP________________PsW__WsP__s__s____P__P__"},{"name":"icon:puck_repulse_ball","size":8,"bricks":"__________________W_______s___W___P__s______P____________WWW__"},{"name":"A","size":7,"bricks":"__ttt___ttttt_ttt_ttttt___ttttttttttt___tttt___tt"},{"name":"B","size":9,"bricks":"_bbbbb_____bb_bb____bb_bb____bb_bb____bbbb_____bb_bb____bb_bb____bb_bb___bbbbb____"},{"name":"C","size":8,"bricks":"__rrrr___rrrrrr_rrr___rrrr______rr______rrr___rr_rrrrrr___rrrr"},{"name":"D","size":8,"bricks":"_GGGGG____GG__G___GG__GG__GG__GG__GG__GG__GG__GG__GG__G__GGGGG"},{"name":"e","size":8,"bricks":"__tttt___tttttt_tt____tttt____tttttttttttt_______tt__tt___tttt_"},{"name":"icon:wind","size":9,"bricks":"_ss______s___PPPP_s_________sssssss___________sssssss_s________s___PPPP__ss"},{"name":"icon:sturdy_bricks","size":7,"bricks":"ttbttttbtttbtt____W_____W_W___W___W_______WWW____"},{"name":"icon:respawn","size":9,"bricks":"tttt___ttttt__t__ttta_ttt_______________________________W_________________WWW"},{"name":"Elephant","size":18,"bricks":"_________________________llll_________lll_llllll_lll___lsssllllllllsssl__lsssllllllllsssl__lsssllBllBllsssl__lssllWllllWllssl___ll__llllll__ll_________llll_______________ll______________llll______________ll________________________________________________________________________________________________________________________________________","color":"","credit":"https://prohama.com/elephant-5-pattern/"},{"name":"Orca","size":20,"bricks":"____________________________________________________________________________________________ggggg____ggg_ggg___ggggggg____ggggg___ggggggggg____ggg___ggggWggWWW_____gggggggggggWWWW_____ggggggggggWWWWW_____gggggggggWWWWW_______gggggggWWWWW___________WWggWWW______________ggg_gg______________gg__g__________________________________________________________________________________________________________","color":"#1c71d8","credit":"https://prohama.com/whale-2-pattern/"},{"name":"Shark","size":17,"bricks":"__________________________________________g_______________ggg____________ggggggg_________ggggggggg_______ggggggggggg_____gggggWWWggggg____gBgWWWWWWWgBg___ggWWWWrWrWWWWgg__ggWWWrrrrrWWWgg_ggWWWrrrrrrrWWWggggWWrrrrrrrrrWWgggWWWrWrWrWrWrWWWggWWrrWWWWWWWrrWWggWWWWWWWWWWWWWWWg_________________","color":"#3584e4","credit":"https://prohama.com/shark-2-pattern/"},{"name":"Bird","size":13,"bricks":"_______RRR____R____RSSSR___RR__RSSWWWR__RSR_RSWWBWR__RSSRRSWWWWyy_RSSSRSWWWR___RSSSSSSRR_____RRSSyyyy______RSyyyyy___RRRRSyyyy____RSSSRyyy_____RRRR______________________","color":"","credit":"https://prohama.com/bird-1-size-13x12/"},{"name":"Tux","size":14,"bricks":"_____gggg________gggggggg_____gggggggggg____gggggggggg___gggggggggggg__gggWBggWBggg__gggBBggBBggg__ggggyyyygggg_ggggggyyggggggggggWWWWWWggggg_gWWWWWWWWg_g__WWWWWWWWWW____WWWWWWWWWW____yyy____yyy__","color":"#62a0ea","credit":"https://prohama.com/pingwin-4-pattern/"},{"name":"Armenia","size":6,"bricks":"_______rrrr__bbbb__yyyy_____________","color":""},{"name":"Austria","size":6,"bricks":"_______rrrr__WWWW__rrrr______","color":""},{"name":"Benin","size":8,"bricks":"_________kkyyyy__kkyyyy__kkrrrr__kkrrrr__________________________","color":""},{"name":"Botswana","size":10,"bricks":"___________tttttttt__tttttttt__tttttttt__WWWWWWWW__BBBBBBBB__WWWWWWWW__tttttttt__tttttttt__tttttttt___________","color":""},{"name":"Bulgaria","size":6,"bricks":"_______WWWW__cccc__rrrr_____________","color":""},{"name":"Canada","size":7,"bricks":"________rWWWr__rWrWr__rWWWr______________________","color":""},{"name":"Chad","size":8,"bricks":"_________bbyyRR__bbyyRR__bbyyRR","color":""},{"name":"China","size":6,"bricks":"______RRyRRRRyRyRRRRyRRRRRRRRR______","color":""},{"name":"Colombia","size":7,"bricks":"________yyyyy__yyyyy__bbbbb__RRRRR_______________","color":""},{"name":"Republic of the Congo","size":7,"bricks":"________kkkyy__kkyyr__kyyrr__yyrrr_______________","color":""},{"name":"C\xf4te d\'Ivoire","size":8,"bricks":"_________OOWWGG__OOWWGG__OOWWGG","color":""},{"name":"Denmark","size":8,"bricks":"_________rrWrrr__rrWrrr__WWWWWW__rrWrrr__rrWrrr","color":""},{"name":"El Salvador","size":8,"bricks":"_________bbbbbb__bbbbbb__WWWkWW__WWkWWW__bbbbbb__bbbbbb","color":""},{"name":"Egypt","size":8,"bricks":"_________RRRRRR__RRRRRR__WWWyWW__WWyWWW__gggggg__gggggg","color":"#1c71d8"},{"name":"Estonia","size":8,"bricks":"_________tttttt__tttttt__gggggg__gggggg__WWWWWW__WWWWWW","color":"#26a269"},{"name":"Finland","size":6,"bricks":"_______WtWW__tttt__WtWW_____________","color":""},{"name":"Gabon","size":5,"bricks":"______CCC__yyy__ttt______","color":""},{"name":"Georgia","size":9,"bricks":"__________WrWrWrW__WWWrWWW__rrrrrrr__WWWrWWW__WrWrWrW__________________","color":""},{"name":"Guinea","size":8,"bricks":"_________rryycc__rryycc__rryycc","color":""},{"name":"Indonesia","size":6,"bricks":"_______rrrr__rrrr__WWWW__WWWW_______","color":""},{"name":"icon:one_more_choice","size":7,"bricks":"ttt____tbbb___tbttt__tbtbbb__btbbb___tbbb____bbb_"},{"name":"icon:instant_upgrade","size":5,"bricks":"ttt__tbbb_tbbb_tbbb__bbb_"},{"name":"icon:checkmark_checked","size":6,"bricks":"_ggggbgBBBbbbbBbbggbbbBggBbBBg_gggg_"},{"name":"icon:checkmark_unchecked","size":6,"bricks":"_gggg_gBBBBggBBBBggBBBBggBBBBg_gggg_"},{"name":"icon:concave_puck","size":7,"bricks":"___W_____________W__________W__W__WWW___WWWWWWWWW","color":""},{"name":"icon:helium","size":8,"bricks":"v______vvv____vvv______vv______vv______vv______vv______v__WWWW__","color":""},{"name":"icon:asceticism","size":8,"bricks":"_________y____y____W____y______y_________y____y_________y_WWWW_y","color":""},{"name":"icon:unbounded","size":9,"bricks":"WWWWWWWWWW_ttttt_WWrtttttrWW_ttttt_WWr_____rWW_______WWr___W_rWW_______WWrWWW__rW","color":""},{"name":"icon:shunt","size":8,"bricks":"_______y______yy______yy__yCCyyy__y__yyy_yy__yyy_yy__yyyyyy__yyy","color":""},{"name":"icon:yoyo","size":8,"bricks":"_rrrrrr_rrrrrrrrrrrrrrrr_WWWWWW_rWrrrrrrrrWrrrrr_rrWrrr_____W___","color":""},{"name":"icon:nbricks","size":6,"bricks":"yy__yyyyy_yyyyyyyyyyyyyyyy_yyyyy__yy","color":""},{"name":"icon:etherealcoins","size":11,"bricks":"_____v_________vvv________ttt________ttt_______vtttv_____vvtttvv____vvtttvv____vvtttvv____v_ryr_v_______r________________","color":""},{"name":"icon:shocks","size":8,"bricks":"_r__r_r_rWWWyy_r_WWW__r_yWWWyry_y_ryyy_rry__WWW___ryWWWryr__WWWy","color":""},{"name":"icon:zen","size":9,"bricks":"___tt______tttt_____BttB_____bbbb____bbbbbb___BbbbbB___tttttt__tttttttt__tttttt__","color":""},{"name":"icon:sacrifice","size":9,"bricks":"__r___r___rrr_rrr_rrWWWWWrrrrWrWrWrrrrWWrWWrr_rrWWWrr___rWrWr_____rrr_______r____","color":""},{"name":"icon:trampoline","size":8,"bricks":"___y_____y____y___bbyb___bttttb_bttytttb_bttttb__tbbbbt__t____t_","color":""},{"name":"icon:ghost_coins","size":7,"bricks":"__yyy___yyyyy_yyOyOyyyyyyyyyyyOOOyyyyyyyyyyy_y_yy","color":""},{"name":"icon:forgiving","size":8,"bricks":"____G______G_G____G___G__G_____GG_____G__G___G____G_G____WWWWW__","color":""},{"name":"icon:ball_attracts_coins","size":8,"bricks":"WWW_____WWW_y___WWW____y__y_y____y____y_____y_____y____y___y_y__","color":""},{"name":"icon:reach","size":8,"bricks":"________ttt__tttttt_Wttt__t__t____r__r___________________WWW____","color":""},{"name":"icon:passive_income","size":8,"bricks":"__________tttt____tttt_______________W___________________rWWWr__","color":""},{"name":"icon:clairvoyant","size":9,"bricks":"__y___y__y__y_y__y_y__t__y____ttt_____tWWWt___tWWgWWt_tttWWWttt__________________","color":""},{"name":"icon:implosions","size":8,"bricks":"y______W__ryW_W__yrBWW____rBWWWy_WWWBrr___WWBrrryW_Wy___W_____y_","color":""},{"name":"icon:corner_shot","size":9,"bricks":"___W____y___W_y______W___y____W_y______W___y____W______W_W_WWW_WW_W_WWWWWW_W_WWWW","color":""},{"name":"icon:premium","size":11,"bricks":"__g____g___g____g____g_g__gbg__g______g______gg_gbg_gg_gbbgbbbgbbggbbgbbbgbbg_gbgbbbgbg___ggggggg____ggggggg_____________","color":""},{"name":"icon:reroll","size":8,"bricks":"__llllll_llBlBlelllllleBWWWWWeeeWBWBWeBeWWWWWeeeWBWBWBe_WWWWWe__","color":""},{"name":"icon:loop","size":7,"bricks":"bbbbbbbtttttt_aaaaa__cccc___CCC____GG_____y______","color":""},{"name":"icon:addiction","size":9,"bricks":"__________________________l__WWWWW_lWWWyylllly_WWWWW_ly_______l__________________","color":""},{"name":"icon:help","size":8,"bricks":"___bb_____bbbb___bb__bb__bb__bb_____bb_____bb______________bb___","color":""},{"name":"Pingwin","size":13,"bricks":"______gggg________ggWWgg_______gWWgWgy______ggWWWg_______ggggg_______gggWWW______gggggWWW___gggggggWWW____ggggggWWW_____ggggWWWW____gggWWWWW______ggWWWW________gWWyyy___","color":"#3584e4","credit":"https://prohama.com/pingwin-2-pattern/"},{"name":"Dog 8","size":17,"bricks":"_____________________________________gg_ggggg_gg____ggWWgWWWWWgWWgg__gWWgWWWWWWWgWWg__gWWgWWWWWWWgWWg__gggWWWWWWWWWggg___gWggWWWWWggWg____gWggWWWWWggWg____gWWWWgggWWWWg_____gWgWWgWWgWg______gWWggsggWWg_______gWgsssgWg_________ggsssgg____________ggg_________________________________________","color":"#62a0ea","credit":"https://prohama.com/dog-8-pattern/"},{"name":"Sunglasses","size":24,"bricks":"____________________________________________________ggggg______ggggg_______gg___g______g___gg_____gg________________gg___gg__________________gg_gggggggggg____gggggggggggggtttttggggggggbbbbbgggggtWWWttttggggbbbbWWWbgg_gtWttttttggggbbbbWbbbg__gtttttttgg__ggbbbbbbbg__gtttttttg____gbbbbbbbg__ggtttttgg____ggbbbbbgg___ggtttgg______ggbbbgg_____ggggg________ggggg___________________________________________________________________________________________________________________________________________________________________________________________________________________________","color":"#26a269","credit":"https://prohama.com/sunglasses-pattern-1/"},{"name":"Balloon","size":21,"bricks":"_____bbbWbbbWbbb_________PWbWPWbWPWbWP_______bWbbbWbbbWbbbWb_____WbbbWbbbWbbbWbbbW___WPWbWPWbWPWbWPWbWPW__bWbbbWbbbWbbbWbbbWb__bbbPbbbPbbbPbbbPbbb__bbPPPbPPPbPPPbPPPbb___PPWPPPWPPPWPPPWPP____PWbWPWbWPWbWPWbWP_____PWPPPWPPPWPPPWP_______PPWPPPWPPPWPP_________WbWPWbWPWbW___________bbbbbbbbb_____________b_____b______________b_____b______________b_____b______________WWWWWWW_______________PPPPP________________PPPPP________________PPPPP________","color":"#240a8b","credit":"https://prohama.com/balloon-1/"},{"name":"Opening","size":14,"bricks":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbyyyyyyyyyyyybbyB___BB___Bybby__________ybbyyy______yyybbbbyyB__Byybbbbbbbyy__yybbbbbbbbby__ybbbbbyyyyby__ybyyyy___yby__yby______yby__yby______yBy__yBy______yyy__yyy___","color":"#000000"},{"name":"Stripes","size":17,"bricks":"bbb______tttttt________tttttt________tttttt______bbtttttt______bbbbbttt______bbbbbb________bbbbbb________bbbbbb______ttbbbbbb______tttttbbb______tttttt________tttttt________tttttt______bbtttttt______bbbbbttt______bbbbbb________bbbbbb________bbbbbb________bbbbbb___________bbb______________","color":""},{"name":"icon:starting_perks","size":8,"bricks":"_________b_b_b___________g_g_g_g_________g_g_g_g_________g_g_g_g","color":""},{"name":"icon:download","size":8,"bricks":"___bb______bb______bb______bb______bb____bbbbbb___bbbb__gggbbggg","color":""},{"name":"icon:upload","size":8,"bricks":"gggbbggg__bbbb___bbbbbb____bb______bb______bb______bb______bb___","color":""},{"name":"icon:coins","size":8,"bricks":"__bbbb___bbggbb_bbggggbbbggggggbbggggggbbbggggbb_bbggbb___bbbb__","color":""},{"name":"icon:reset","size":8,"bricks":"bb____bbbbb__bbb_bbbbbb___bbbb____bbbb___bbbbbb_bbb__bbbbb____bb","color":""},{"name":"icon:fountain_toss","size":12,"bricks":"__________________________________________________WWWWWWWW___WttttttttW_WtytttytyttWWtttyttttttWlWtyttttytWl_lWWWWWWWWl___llllllll______________","color":""},{"name":"You are here","size":13,"bricks":"_____rrr_________rrrrr_______rrr_rrr______rr___rr______rr___rr_______rr_rr________rrrrr_________rrr__________rrr_________WWrWW_______WWWrWWW______WWWWWWW_______WWWWW____","color":""},{"name":"Gear","size":13,"bricks":"_________________l_l_l______l_lllll_l_____lllllll____lllll_lllll___lll___lll___lll_____lll___lll___lll___lllll_lllll____lllllll_____l_lllll_l______l_l_l_________________","color":""},{"name":"Play","size":15,"bricks":"_________________rrrrrrrrrrr___rrrrWWrrrrrrr__rrrrWWWrrrrrr__rrrrWWWWrrrrr__rrrrWWWWWrrrr__rrrrWWWWWWrrr__rrrrWWWWWrrrr__rrrrWWWWrrrrr__rrrrWWWrrrrrr__rrrrWWrrrrrrr___rrrrrrrrrrr_______________________________________________","color":""},{"name":"City","size":18,"bricks":"_______yyy___bbbbb________yyy__ybyyb________yyy__ybyyb__tt___yyy_b_ybbbb_tttt______bbbbbbbtttttt_______ybyybbbbbbb_______ybyybbyybyb_____b_ybbbbbyybyb_____bbbbbbbbbbbbb__bb___bbbbbbybyyb_bbbb__ybyybbybyybbbbbbb_ybyybbbbbbbtttttt_ybbbbbyybybtyyyyt_bbbbbbyybybtyyyyt_bbbbbbbbbbbtttttt_byybybybyybtytyyt_byybybybyybtttttt_byybb","color":""},{"name":"Wiggle","size":17,"bricks":"__________________cccccc_ccc_cccc__c____c_c_c_c__c__ccc_cc_c_ccc_cc____c_c__c_____c___ccc_cccc_ccc_cc__c________c_c__c__ccc_ccc_cc_cccc____c_c_c_c________ccc_c_c_ccccccc__c___c_________c__ccc_ccccccccccc____c______________ccc_ccc_ccc_ccc__c___c_c_c_c_c_c__ccccc_ccc_ccc_c__________________","color":""},{"name":"Graph","size":18,"bricks":"_______________________yy________________yyt__yytttt______tt_tttyy___t____yyt____t_____t____yy____tt_____t____t_____t______yy___t_____t______yy__tt_____yytttttt___tt___ttyy_____t___t____t__t_____t___yytttt__t_____t___yy______tt____t____t_______yy___t____ttt_____yyttyy______tyy___t___yy_______yytttt_________________________","color":""},{"name":"Lightbulb","size":14,"bricks":"_______________y__yyyyy___y____yyyyyyy______yyyyyyyyy_____yyyyyyyyy___y_yyyyyyyyy__y__yyyyyyyyy_____yyyyyyyyy_____yyyBBByyy___y__yyByByy___y____yByBy_________lllll______y___lll___y_______lll______","color":""},{"name":"Note","size":16,"bricks":"_____________WWW__________WWWWWW_______WWWWWW__W____WWWWWW_____W____WWW________W____W__________W____W__________W____W__________W____W__________W____W________WWW____W_______WWWW____W_______WWW___WWW____________WWWW____________WWW____________________________","color":""},{"name":"Rocket","size":13,"bricks":"______b___________bbb_________bbBbb________btttb________ttBtt________ttttt________ttBtt________ttttt________ttBtt_______bbtttbb_____bbbyyybbb____bbbyyybbb____bb_ByB_bb__","color":""},{"name":"Abstract","size":16,"bricks":"________________aaaaa_cccc_aaaaaaaaaa_cccc_aaaaa________________aaaa_cccc_aaaaaaaaaa_cccc_aaaaaa________________aaa_cccc_aaaaaaaaaa_cccc_aaaaaaa________________aa_cccc_aaaaaaaaaa_cccc_aaaaaaaa________________a_cccc_aaaaaaaaaa_cccc_aaaaaaaaa________________","color":""},{"name":"Fingerprint","size":15,"bricks":"___SSSSSSSS______S_______SS____S__SSSSS__SS__S__S____SS__S____S__SS__SS_S___S__S_SS__S__S_S__S___SS_SS__SS_S_____S___S__S_S__SS__S__SS_S_S_SS_S__S__S_S_S_S___S_S__S_S_S_S___S_S__S___S_S___S_S__S__S__S___S_S__S__S__S__S___S_S_","color":""},{"name":"Leaf","size":14,"bricks":"____________________________________________________________GGkGG________GGkGGkGG_____GGkGGkGGkkG_kkkkkkkkkkkGGG__GGkGGkGGkkG____GGkGGkGG_______GGkGG_______________________________________________","color":""},{"name":"Abstract 2","size":14,"bricks":"______________yyyy______yyyy______________bbb_bbbbbb_bbbbb___bbbb___bbb__y__bb__y__b______________bbb_bbbbbb_bbbbb___bbbb___bbb__y__bb__y__b______________bbb_bbbbbb_bbbbb___bbbb___bbb__y__bb__y__b","color":""},{"name":"Abstract 3","size":13,"bricks":"______________p_aaa_ppp_a__p___a_p___a__ppp_a_p_aaa_______________aaa_p_a_ppp__a___p_a___p__a_ppp_aaa_p_______________p_aaa_ppp_a__p___a_p___a__ppp_a_p_aaa______________","color":""},{"name":"Abstract 4","size":13,"bricks":"______________y_y_y_y_y_y__y_y_y_y_y_y__y_y_y_y_y_y_______________bbb_bbb_bbb_______________bbb_bbb_bbb_______________y_y_y_y_y_y__y_y_y_y_y_y__y_y_y_y_y_y______________","color":""},{"name":"Abstract 5","size":13,"bricks":"______________ccc_ccc_ccc__c_a_c_c_a_c__caa_aaa_aac_______________cca_aaa_acc__c_a_a_a_a_c__cca_aaa_acc_______________caa_aaa_aac__c_a_c_c_a_c__ccc_ccc_ccc______________","color":""},{"name":"Abstract 6","size":13,"bricks":"_vvvvv_vvvvv__v___v_v___v__v_bbbbbbb_v__v_b_v_v_b_v__v_b_v_v_b_v__v_b_v_v_b_v__v_b_v_v_b_v__v_b_v_v_b_v__v_b_v_v_b_v__v_b_vvv_b_v__v_b_____b_v__vvvvvvvvvvv_bbbb_____bbbb","color":""},{"name":"icon:new_run","size":7,"bricks":"_ggg____gbgg___gbbgg__gbbbg__gbbgg__gbgg___ggg___","color":""},{"name":"icon:unlocks","size":6,"bricks":"_bbbb__b__b__b__b_gggggggggggggggggg","color":""},{"name":"icon:settings","size":9,"bricks":"___g_g____g_ggg_g___ggbgg__gggbbbggg_gbb_bbg_gggbbbggg__ggbgg___g_ggg_g____g_g___","color":""},{"name":"icon:creative","size":7,"bricks":"bbg_bgg_______bbb_bgg_______bgg_bbg_______bbg_bbb","color":""},{"name":"icon:limitless","size":12,"bricks":"_________________________bbb____ttb_bbbbb__tttbbbb_bbbttt_bbbb__bbbt__bbbb_ttbbb__bbttttttbbbbbb_ttt___bbbb_____________________________________","color":""},{"name":"icon:history","size":8,"bricks":"__gggg___ggbggg_gggbgggggggbggggggggbbgggggggggg_gggggg___gggg__","color":""},{"name":"Hemiola","size":11,"bricks":"___gggg_____gggrrgg_____ggrrg_______gggg_____gggyygg_____ggyyg_______gggg_____gggCCgg_____ggCCg_______gggg________gg_____","color":"#240a8b","credit":"Left a wonderful review on the play store."},{"name":"Obigre","size":13,"bricks":"_______________________________________OOOORgRgRgOOOOWOORgRgRgOOOOOWORgRgRgOWOOWOORgRgRgOOWOOWORgRgRgOWOOWOORgRgRgOOOOOOORgRgRgOOO_______________________________________","color":"#62a0ea","credit":"Colin helped a lot with the game design https://colin-crapahute.bearblog.dev/"},{"name":"Noodlemire","size":15,"bricks":"_________________________________ggggggggg_____g_________g___g___________g_g_____________gg_____________gg_____yyy_____ggg__yyyyyyy__ggggtyyyyyyyyytggggtttttttttttgggg_ttttttttt_gg_____ttttt___________________________________","color":"#240a8b","credit":"Early adopter of the game"},{"name":"Bearded axe","size":12,"bricks":"______________WyyyOOy_____WyyyOOy_____Wyy_OO______Wyy_OO______Wyy_OO__________OO__________OO__________OO__________OO__________OO__________OO____","color":"","credit":"Did some nice bug reports"},{"name":"icon:minefield","size":7,"bricks":"W__B__WWWBBBWWB__W__BBBWWWBBW__B__WWWBBBWW_______","color":""},{"name":"icon:side_flip","size":7,"bricks":"________ttttt__rttty__rttty__rttty__ttttt________","color":""},{"name":"icon:side_kick","size":7,"bricks":"________ttttt__ytttr__ytttr__ytttr__ttttt________","color":""},{"name":"Lebanon","size":9,"bricks":"_________rrrrrrrrrWWWWkWWWWWWWkkkWWWWWkkkkkWWWWWWkWWWWrrrrrrrrr__________________","color":""},{"name":"Spain","size":9,"bricks":"_________rrrrrrrrryyyyyyyyyyWrWyyyyyyrWryyyyyyWrWyyyyyyyyyyyyyyrrrrrrrrr_________","color":""},{"name":"Uzbekistan","size":8,"bricks":"tWtttWttWtttWttttWtWtWttWWWWWWWWWWWWWWWWGGGGGGGGGGGGGGGGGGGGGGGG","color":""},{"name":"Pakistan","size":8,"bricks":"________WWkkkkkkWWkkWkWkWWkWkkkkWWkWkkWkWWkkWWkkWWkkkkkk________","color":""},{"name":"Korea","size":10,"bricks":"__________WWWWWWWWWWWgWWWWWWgWWgWrrrrWgWWWWrrbbWWWWWWrrbbWWWWgWbbbbWgWWgWWWWWWgWWWWWWWWWWW__________","color":"#62a0ea"},{"name":"icon:trickledown","size":8,"bricks":"_ytttttt_________y_y_y__tttttt____________y_y_y___tttttt_y______","color":""},{"name":"icon:transparency","size":9,"bricks":"__W_W_W___________W_W_W_W_W_________W_W_W_W_W_________W_W_W_W_W___________W_W_W__","color":""},{"name":"icon:superhot","size":11,"bricks":"____________________________________________W_W_WWW_WWWWWW_W_W__W_W_W_WWW__W_____________________________________________","color":""},{"name":"icon:bricks_attract_coins","size":7,"bricks":"_y__y___tttttyyttttt__ttttt_yttttty_ttttt___y__y_","color":""},{"name":"icon:rainbow","size":6,"bricks":"__rOyC_rOyCa_rOyCarOyCatrOyCatrOyCat","color":""},{"name":"icon:hypnosis","size":8,"bricks":"WrrrrrrrWrWWWWWrWrWrrrWrWrWrWrWrWrWWWrWrWrrrrrWrWWWWWWWrrrrrrrrr","color":""},{"name":"icon:bricks_attract_ball","size":8,"bricks":"llW_____ll_v________p________bll____t_ll___G____lly_____ll_r____","color":""},{"name":"Chile","size":9,"bricks":"_________tttWWWWWWtWtWWWWWWtttWWWWWWrrrrrrrrrrrrrrrrrrrrrrrrrrr__________________","color":""},{"name":"T\xfcrkiye","size":12,"bricks":"____________rrrrrrrrrrrrrrrWWWrrrrrrrrWWrrrrrrrrrWWrrWrWrrrrrWWrrrWrrrrrrWWrrWrWrrrrrrWWrrrrrrrrrrrWWWrrrrrrrrrrrrrrrrrr________________________","color":""},{"name":"icon:editor","size":10,"bricks":"_______ggg______gggg_____ggggg____ggggg____ggggg____ggggg____ggggg____bgggg_____bbgg______bbb_______","color":""},{"color":"","size":11,"bricks":"_____e________WWWWW_____WWWWWWW____WWWWWWW____WWWWWWW__W__lllll__WWWeeeeeeeWWeeeeeWeeeeeeleeWWWeeleeeeWWWWWeeeeleWWlWWele","name":"Taj Mahal","credit":"An approximative reproduction "},{"color":"","size":9,"bricks":"__________SS_t_SS__S_____S____t_t____t_____t____t_t____S_____S__SS_t_SS__________","name":"Abstract 7","credit":""},{"color":"","size":8,"bricks":"PP_vv_PP_P__v__P________vv_PP_vvv__P__v_________PP_vv_PP_P__v__P","name":"Abstract 9","credit":""},{"color":"","size":9,"bricks":"____W_____WWWWWWW__WB_W_BW__W_____W_WWW_B_WWW_W_____W__WB_W_BW__WWWWWWW_____W____","name":"Crosshair","credit":""},{"color":"","size":15,"bricks":"bbbB_ttttt_BbbbbBbb_ttBtt_bbBbb____tt_tt____bbbbb_tt_tt_bbbb_______________ttttt_b_b_tttttt_____b_b_____tt_ttt_b_b_ttt_ttBtBt_bBb_tBtBtttt_t_bbb_t_ttt________________bb_ttttttt_bb__Bb_tB___Bt_bB__Bb_ttt_ttt_bB_bbb_________bbb","name":"Abstract 10","credit":""},{"color":"","size":6,"bricks":"SSSSSSSOOOOSSBOOBSSOOOOSSOOOOS_OSSO_","name":"Face","credit":""},{"color":"","size":11,"bricks":"_____O__________O__________O__________O_________OOO________OOO____k___O_O___kkk_OO_OO_kkkkkOOOOOkkkkkOOO_OOOkkkOOO___OOOk","name":"Eiffel tower","credit":""},{"color":"","size":9,"bricks":"P_t_s_t_PP_t___t_PP_ttttt_PP_______PPPPPPPPPPP_______PP_sssss_PP_s___s_PP_s_t_s_P","name":"Abstract 11","credit":""},{"color":"","size":8,"bricks":"BbBb____bbbb____BbBb____bbbb________tBtB____tttt____tBtB____tttt","name":"Abstract 12","credit":""},{"color":"","size":9,"bricks":"SSSSbSSSSSbbSbSbbSSbbS_SbbSSSSS_SSSSbb_____bbSSSS_SSSSSbbS_SbbSSbbSbSbbSSSSSbSSSS","name":"Abstract 13","credit":""},{"color":"","size":11,"bricks":"aa_tt_aa_ttaa_tt_aa_tt__B__B__B__bb_aa_bb_aabb_aa_bb_aa__B__B__B__aa_bb_tt_bbaa_bb_tt_bb__B__B__B__tt_aa_bb_aatt_aa_bb_aa","name":"Abstract 14","credit":""},{"color":"","size":10,"bricks":"___________Oyyyyyyy__Oyyyyyyy__Oyy__Oyy__Oyy_______Oyyyyyyy_______Oyy__Oyy__Oyy__Oyyyyyyy__Oyyyyyyy_","name":"S","credit":""},{"color":"","size":11,"bricks":"____________S_vvv_SSS__S___v___S__SSS_vvv_S__________S__S_vvv_SSS__S___v______SSS_vvv_S____S_____S__v_SSS_SSS____________","name":"Abstract 15","credit":"Just random strokes"},{"color":"","size":11,"bricks":"________________________RRRRR_____RRRRRRRRR__kkkOOkO___kOkOOOkOOO_kOkkOOOkOOOkkOOOOkkkk___OOOOOOO________________________","name":"Mario!","credit":"Suggested by Nicolas03. A Mario level ! Sprite taken from https://art.pixilart.com/sr2d5c0683c82aws3.png . The sprite belongs to Nintendo"},{"color":"","size":16,"bricks":"___llltCCttBC______lllCBBttCB______lttbBbtltt______ltBrBClttt______lttCCCttBt______llttCBtttt______ltCBCttlll______ltBCCtCtCt______lttCCBCBrB______llltBCCtrB______ttttttlltt______CBrttlllll______CBrBCttttl______ttCCBttBtl______tttCCCtCCt______tBttBtltBt___","name":"Minesweeper","credit":"Suggested by Noodlemire. For once, you\'ll want to trigger as many mines as possible."},{"color":"","size":19,"bricks":"__________________________________________________________________________________________________________________________WWW_______________WrrrW_____________WrWWWrW____________WrWBWrW____________WrWWWrW_____________WrrrW_______________WWW__________________________________________________________________________________________________________________________","name":"Target","credit":"Suggested by Noodlemire. Unusually small level, with lots of room to miss your shots. Acts as decent aim practice."},{"color":"","size":10,"bricks":"__________rrrrr_____WWrWWrrrrrWWrWWWWrWWWWrWWWWrWWrWrWWWWrWWWrWWWrWrWW_____WrWWW____________________","name":"The Boys","credit":"Suggested by Bearded-Axe. My boys initals"},{"color":"#115988","size":21,"bricks":"__________________________________________________yy_______________yy__yy__yy___________yy__yy__yy____________yy__yy_yy_________y__yy__yy_yy________yyy_yyy_yy_yy_________yy__yy_yyyyy__________yy_yyyyyyyy___yyy____yyyyygggyyy__yyy______yyygBBBgyy_yyy________ygBBBBBgyyyy__W______ygBBBBBgyyy__________yygBBBgyyyy___________yygBgyyyy____________yyyByyyy_____________yyyyByy_______________yyByy_________________r_________________________________","name":"A Very Dangerous High-Five","credit":"Suggested by Noodlemire. A unique shape, fun to bounce the ball between fingers. The palm was initially boring on its own, so I gave it a big bomb. It adds a distinct feeling between the top and bottom halves."},{"name":"icon:buoy","size":7,"bricks":"___b______b_____bbb__abbbbbaaatttaaaaataaaaaaaaaa","svg":null,"color":""},{"name":"icon:ottawa_treaty","size":8,"bricks":"BBtWWtBBBttWWttBtWWtttWtttWWWWtttttWWtttttWWWtttBWWtWttBBBtttWBB","svg":null,"color":""},{"name":"icon:three_cushion","size":8,"bricks":"BkkkkkkBk___W__kk__W_W_kk_W___WkkW___y_kk_W____kk__W___kBkkkkkkB","svg":null,"color":""},{"name":"icon:sticky_coins","size":8,"bricks":"__________yy_yy___tttty__ytttt___ytttt____tttty______yy_________","svg":null,"color":""}]');
},{}],"iyP6E":[function(require,module,exports,__globalThis) {
-module.exports = JSON.parse("\"29085904\"");
+module.exports = JSON.parse("\"29087244\"");
},{}],"1u3Dx":[function(require,module,exports,__globalThis) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
@@ -2523,7 +2523,7 @@ try {
warnedUserAboutLSIssue = true;
(0, _toast.toast)(`Storage issue : ${e?.message}`);
}
- console.warn('Reading ' + key, e);
+ console.warn("Reading " + key, e);
}
} catch (e) {
console.warn(e);
@@ -2627,8 +2627,8 @@ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "clamp", ()=>clamp);
parcelHelpers.export(exports, "comboKeepingRate", ()=>comboKeepingRate);
-parcelHelpers.export(exports, "hoursSpentPlaying", ()=>hoursSpentPlaying);
parcelHelpers.export(exports, "shouldCoinsStick", ()=>shouldCoinsStick);
+parcelHelpers.export(exports, "ballTransparency", ()=>ballTransparency);
parcelHelpers.export(exports, "coinsBoostedCombo", ()=>coinsBoostedCombo);
parcelHelpers.export(exports, "miniMarkDown", ()=>miniMarkDown);
parcelHelpers.export(exports, "firstWhere", ()=>firstWhere);
@@ -2640,31 +2640,25 @@ parcelHelpers.export(exports, "catchRateBest", ()=>catchRateBest);
parcelHelpers.export(exports, "catchRateGood", ()=>catchRateGood);
parcelHelpers.export(exports, "missesBest", ()=>missesBest);
parcelHelpers.export(exports, "missesGood", ()=>missesGood);
-var _settings = require("./settings");
-var _gameUtils = require("./game_utils");
function clamp(value, min, max) {
return Math.max(min, Math.min(value, max));
}
function comboKeepingRate(level) {
return clamp(1 - 1 / (1 + level) * 1.5, 0, 1);
}
-function hoursSpentPlaying() {
- try {
- const timePlayed = (0, _settings.getSettingValue)("breakout_71_total_play_time", 0);
- return Math.floor(timePlayed / 1000 / 60 / 60);
- } catch (e) {
- return 0;
- }
-}
function shouldCoinsStick(gameState) {
return gameState.perks.sticky_coins && (!gameState.lastExplosion || gameState.lastExplosion < gameState.levelTime - 300 * gameState.perks.sticky_coins);
}
+function ballTransparency(ball, gameState) {
+ if (!gameState.perks.transparency) return 0;
+ return clamp(gameState.perks.transparency * (1 - ball.y / gameState.gameZoneHeight * 1.2), 0, 1);
+}
function coinsBoostedCombo(gameState) {
let boost = 1 + gameState.perks.sturdy_bricks / 2 + gameState.perks.smaller_puck / 2;
if (gameState.perks.transparency) {
let min = 1;
gameState.balls.forEach((ball)=>{
- const bt = (0, _gameUtils.ballTransparency)(ball, gameState);
+ const bt = ballTransparency(ball, gameState);
if (bt < min) min = bt;
});
boost += min * gameState.perks.transparency / 2;
@@ -2716,7 +2710,379 @@ function firstWhere(arr, mapper) {
}
const wallBouncedBest = 3, wallBouncedGood = 10, levelTimeBest = 30, levelTimeGood = 60, catchRateBest = 95, catchRateGood = 90, missesBest = 3, missesGood = 6;
-},{"./settings":"5blfu","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3","./game_utils":"cEeac"}],"cEeac":[function(require,module,exports,__globalThis) {
+},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"7OIPf":[function(require,module,exports,__globalThis) {
+var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
+parcelHelpers.defineInteropFlag(exports);
+parcelHelpers.export(exports, "getLevelBackground", ()=>getLevelBackground);
+parcelHelpers.export(exports, "hashCode", ()=>hashCode);
+var _backgroundsJson = require("./data/backgrounds.json");
+var _backgroundsJsonDefault = parcelHelpers.interopDefault(_backgroundsJson);
+const backgrounds = (0, _backgroundsJsonDefault.default);
+function getLevelBackground(level) {
+ return backgrounds[hashCode(level.name) % backgrounds.length];
+}
+function hashCode(string) {
+ let hash = 0;
+ for(let i = 0; i < string.length; i++){
+ let code = string.charCodeAt(i);
+ hash = (hash << 5) - hash + code;
+ hash = hash & hash; // Convert to 32bit integer
+ }
+ return Math.abs(hash);
+}
+
+},{"./data/backgrounds.json":"31wW4","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"31wW4":[function(require,module,exports,__globalThis) {
+module.exports = JSON.parse("[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"]");
+
+},{}],"6rQoT":[function(require,module,exports,__globalThis) {
+var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
+parcelHelpers.defineInteropFlag(exports);
+parcelHelpers.export(exports, "levelIconHTML", ()=>levelIconHTML);
+let levelIconHTMLCanvas = document.createElement("canvas");
+const levelIconHTMLCanvasCtx = levelIconHTMLCanvas.getContext("2d", {
+ antialias: false,
+ alpha: true
+});
+function levelIconHTML(bricks, levelSize, color) {
+ const size = 46;
+ const c = levelIconHTMLCanvas;
+ const ctx = levelIconHTMLCanvasCtx;
+ if (!ctx) return "";
+ c.width = size;
+ c.height = size;
+ ctx.clearRect(0, 0, size, size);
+ const pxSize = size / levelSize;
+ for(let x = 0; x < levelSize; x++)for(let y = 0; y < levelSize; y++){
+ const c = bricks[y * levelSize + x];
+ if (c) {
+ ctx.fillStyle = c;
+ ctx.fillRect(Math.floor(pxSize * x), Math.floor(pxSize * y), Math.ceil(pxSize), Math.ceil(pxSize));
+ }
+ }
+ return ` `;
+}
+
+},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"dQKPV":[function(require,module,exports,__globalThis) {
+var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
+parcelHelpers.defineInteropFlag(exports);
+parcelHelpers.export(exports, "playPendingSounds", ()=>playPendingSounds);
+parcelHelpers.export(exports, "sounds", ()=>sounds);
+parcelHelpers.export(exports, "getAudioContext", ()=>getAudioContext);
+parcelHelpers.export(exports, "getAudioRecordingTrack", ()=>getAudioRecordingTrack);
+var _options = require("./options");
+let lastPlay = Date.now();
+function playPendingSounds(gameState) {
+ if (lastPlay > Date.now() - 60) return;
+ lastPlay = Date.now();
+ for(let key in gameState.aboutToPlaySound){
+ const soundName = key;
+ const ex = gameState.aboutToPlaySound[soundName];
+ if (ex.vol) {
+ sounds[soundName](// In stress test, dim the sounds but play them
+ Math.min(1, ex.vol), pixelsToPan(gameState, ex.x), gameState.combo);
+ ex.vol = 0;
+ }
+ }
+}
+const sounds = {
+ wallBeep: (volume, pan)=>{
+ if (!(0, _options.isOptionOn)("sound")) return;
+ createSingleBounceSound(800, pan, volume);
+ },
+ plouf: (volume, pan)=>{
+ if (!(0, _options.isOptionOn)("sound")) return;
+ createSingleBounceSound(500, pan, volume * 0.5);
+ // createWaterDropSound(800, pan, volume*0.2, 0.2,'triangle')
+ },
+ comboIncreaseMaybe: (volume, pan, combo)=>{
+ if (!(0, _options.isOptionOn)("sound")) return;
+ let delta = 0;
+ if (!isNaN(lastComboPlayed)) {
+ if (lastComboPlayed < combo) delta = 1;
+ if (lastComboPlayed > combo) delta = -1;
+ }
+ playShepard(delta, pan, volume);
+ lastComboPlayed = combo;
+ },
+ comboDecrease (volume, pan, combo) {
+ if (!(0, _options.isOptionOn)("sound")) return;
+ playShepard(-1, pan, volume);
+ },
+ coinBounce: (volume, pan, combo)=>{
+ if (!(0, _options.isOptionOn)("sound")) return;
+ createSingleBounceSound(1200, pan, volume, 0.1, "triangle");
+ },
+ // void: (volume: number, pan: number) => {
+ // if (!isOptionOn("sound")) return;
+ // createSingleBounceSound(1200, pan, volume, 0.5, "sawtooth");
+ // createSingleBounceSound(600, pan, volume, 0.3, "sawtooth");
+ // },
+ // freeze: (volume: number, pan: number) => {
+ // if (!isOptionOn("sound")) return;
+ // createSingleBounceSound(220, pan, volume, 0.5, "square");
+ // createSingleBounceSound(440, pan, volume, 0.5, "square");
+ // },
+ explode: (volume, pan, combo)=>{
+ if (!(0, _options.isOptionOn)("sound")) return;
+ createExplosionSound(pan);
+ },
+ lifeLost (volume, pan, combo) {
+ if (!(0, _options.isOptionOn)("sound")) return;
+ createShatteredGlassSound(pan);
+ },
+ coinCatch (volume, pan, combo) {
+ if (!(0, _options.isOptionOn)("sound")) return;
+ createSingleBounceSound(900, pan, volume, 0.1, "triangle");
+ },
+ colorChange (volume, pan, combo) {
+ createSingleBounceSound(400, pan, volume, 0.5, "sine");
+ createSingleBounceSound(800, pan, volume * 0.5, 0.2, "square");
+ }
+};
+// How to play the code on the leftconst context = new window.AudioContext();
+let audioContext, audioRecordingTrack;
+function getAudioContext() {
+ if (!audioContext) {
+ if (!(0, _options.isOptionOn)("sound")) return null;
+ audioContext = new (window.AudioContext || window.webkitAudioContext)();
+ audioRecordingTrack = audioContext.createMediaStreamDestination();
+ }
+ return audioContext;
+}
+function getAudioRecordingTrack() {
+ getAudioContext();
+ return audioRecordingTrack;
+}
+function createSingleBounceSound(baseFreq = 800, pan = 0.5, volume = 1, duration = 0.1, type = "sine") {
+ const context = getAudioContext();
+ if (!context) return;
+ const oscillator = createOscillator(context, baseFreq, type);
+ // Create a gain node to control the volume
+ const gainNode = context.createGain();
+ oscillator.connect(gainNode);
+ // Create a stereo panner node for left-right panning
+ const panner = context.createStereoPanner();
+ panner.pan.setValueAtTime(pan * 2 - 1, context.currentTime);
+ gainNode.connect(panner);
+ panner.connect(context.destination);
+ panner.connect(audioRecordingTrack);
+ // Set up the gain envelope to simulate the impact and quick decay
+ gainNode.gain.setValueAtTime(0.8 * volume, context.currentTime); // Initial impact
+ gainNode.gain.exponentialRampToValueAtTime(0.001, context.currentTime + duration); // Quick decay
+ // Start the oscillator
+ oscillator.start(context.currentTime);
+ // Stop the oscillator after the decay
+ oscillator.stop(context.currentTime + duration);
+}
+let noiseBuffer;
+function getNoiseBuffer(context) {
+ if (!noiseBuffer) {
+ const bufferSize = context.sampleRate * 2; // 2 seconds
+ noiseBuffer = context.createBuffer(1, bufferSize, context.sampleRate);
+ const output = noiseBuffer.getChannelData(0);
+ // Fill the buffer with random noise
+ for(let i = 0; i < bufferSize; i++)output[i] = Math.random() * 2 - 1;
+ }
+ return noiseBuffer;
+}
+function createExplosionSound(pan = 0.5) {
+ const context = getAudioContext();
+ if (!context) return;
+ // Create an audio buffer
+ // Create a noise source
+ const noiseSource = context.createBufferSource();
+ noiseSource.buffer = getNoiseBuffer(context);
+ // Create a gain node to control the volume
+ const gainNode = context.createGain();
+ noiseSource.connect(gainNode);
+ // Create a filter to shape the explosion sound
+ const filter = context.createBiquadFilter();
+ filter.type = "lowpass";
+ filter.frequency.setValueAtTime(1000, context.currentTime); // Set the initial frequency
+ gainNode.connect(filter);
+ // Create a stereo panner node for left-right panning
+ const panner = context.createStereoPanner();
+ panner.pan.setValueAtTime(pan * 2 - 1, context.currentTime); // pan 0 to 1 maps to -1 to 1
+ // Connect filter to panner and then to the destination (speakers)
+ filter.connect(panner);
+ panner.connect(context.destination);
+ panner.connect(audioRecordingTrack);
+ // Ramp down the gain to simulate the explosion's fade-out
+ gainNode.gain.setValueAtTime(1, context.currentTime);
+ gainNode.gain.exponentialRampToValueAtTime(0.01, context.currentTime + 1);
+ // Lower the filter frequency over time to create the "explosive" effect
+ filter.frequency.exponentialRampToValueAtTime(60, context.currentTime + 1);
+ // Start the noise source
+ noiseSource.start(context.currentTime);
+ // Stop the noise source after the sound has played
+ noiseSource.stop(context.currentTime + 1);
+}
+function pixelsToPan(gameState, pan) {
+ return Math.max(0, Math.min(1, (pan - gameState.offsetXRoundedDown) / gameState.gameZoneWidthRoundedUp));
+}
+let lastComboPlayed = NaN, shepard = 6;
+function playShepard(delta, pan, volume) {
+ const shepardMax = 11, factor = 1.05945594920268, baseNote = 392;
+ shepard += delta;
+ if (shepard > shepardMax) shepard = 0;
+ if (shepard < 0) shepard = shepardMax;
+ const play = (note)=>{
+ const freq = baseNote * Math.pow(factor, note);
+ const diff = Math.abs(note - shepardMax * 0.5);
+ const maxDistanceToIdeal = 1.5 * shepardMax;
+ const vol = Math.max(0, volume * (1 - diff / maxDistanceToIdeal));
+ createSingleBounceSound(freq, pan, vol);
+ return freq.toFixed(2) + " at " + Math.floor(vol * 100) + "% diff " + diff;
+ };
+ play(1 + shepardMax + shepard);
+ play(shepard);
+ play(-1 - shepardMax + shepard);
+}
+function createShatteredGlassSound(pan) {
+ const context = getAudioContext();
+ if (!context) return;
+ const oscillators = [
+ createOscillator(context, 3000, "square"),
+ createOscillator(context, 4500, "square"),
+ createOscillator(context, 6000, "square")
+ ];
+ const gainNode = context.createGain();
+ const noiseSource = context.createBufferSource();
+ noiseSource.buffer = getNoiseBuffer(context);
+ oscillators.forEach((oscillator)=>oscillator.connect(gainNode));
+ noiseSource.connect(gainNode);
+ gainNode.gain.setValueAtTime(0.2, context.currentTime);
+ oscillators.forEach((oscillator)=>oscillator.start());
+ noiseSource.start();
+ oscillators.forEach((oscillator)=>oscillator.stop(context.currentTime + 0.2));
+ noiseSource.stop(context.currentTime + 0.2);
+ gainNode.gain.exponentialRampToValueAtTime(0.001, context.currentTime + 0.2);
+ // Create a stereo panner node for left-right panning
+ const panner = context.createStereoPanner();
+ panner.pan.setValueAtTime(pan * 2 - 1, context.currentTime);
+ gainNode.connect(panner);
+ panner.connect(context.destination);
+ panner.connect(audioRecordingTrack);
+ gainNode.connect(panner);
+}
+// Helper function to create an oscillator with a specific frequency
+function createOscillator(context, frequency, type) {
+ const oscillator = context.createOscillator();
+ oscillator.type = type;
+ oscillator.frequency.setValueAtTime(frequency, context.currentTime);
+ return oscillator;
+}
+
+},{"./options":"d5NoS","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"d5NoS":[function(require,module,exports,__globalThis) {
+var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
+parcelHelpers.defineInteropFlag(exports);
+parcelHelpers.export(exports, "options", ()=>options);
+parcelHelpers.export(exports, "isOptionOn", ()=>isOptionOn);
+parcelHelpers.export(exports, "toggleOption", ()=>toggleOption);
+var _i18N = require("./i18n/i18n");
+var _settings = require("./settings");
+var _gameUtils = require("./game_utils");
+const options = {
+ sound: {
+ default: true,
+ name: (0, _i18N.t)("settings.sounds"),
+ help: (0, _i18N.t)("settings.sounds_help")
+ },
+ "mobile-mode": {
+ default: window.innerHeight > window.innerWidth,
+ name: (0, _i18N.t)("settings.mobile"),
+ help: (0, _i18N.t)("settings.mobile_help")
+ },
+ basic: {
+ default: false,
+ name: (0, _i18N.t)("settings.basic"),
+ help: (0, _i18N.t)("settings.basic_help")
+ },
+ colorful_coins: {
+ default: false,
+ name: (0, _i18N.t)("settings.colorful_coins"),
+ help: (0, _i18N.t)("settings.colorful_coins_help")
+ },
+ extra_bright: {
+ default: true,
+ name: (0, _i18N.t)("settings.extra_bright"),
+ help: (0, _i18N.t)("settings.extra_bright_help")
+ },
+ smooth_lighting: {
+ default: true,
+ name: (0, _i18N.t)("settings.smooth_lighting"),
+ help: (0, _i18N.t)("settings.smooth_lighting_help")
+ },
+ precise_lighting: {
+ default: true,
+ name: (0, _i18N.t)("settings.precise_lighting"),
+ help: (0, _i18N.t)("settings.precise_lighting_help")
+ },
+ probabilistic_lighting: {
+ default: false,
+ name: (0, _i18N.t)("settings.probabilistic_lighting"),
+ help: (0, _i18N.t)("settings.probabilistic_lighting_help")
+ },
+ contrast: {
+ default: false,
+ name: (0, _i18N.t)("settings.contrast"),
+ help: (0, _i18N.t)("settings.contrast_help")
+ },
+ show_fps: {
+ default: false,
+ name: (0, _i18N.t)("settings.show_fps"),
+ help: (0, _i18N.t)("settings.show_fps_help")
+ },
+ show_stats: {
+ default: false,
+ name: (0, _i18N.t)("settings.show_stats"),
+ help: (0, _i18N.t)("settings.show_stats_help")
+ },
+ pointerLock: {
+ default: false,
+ name: (0, _i18N.t)("settings.pointer_lock"),
+ help: (0, _i18N.t)("settings.pointer_lock_help")
+ },
+ easy: {
+ default: false,
+ name: (0, _i18N.t)("settings.kid"),
+ help: (0, _i18N.t)("settings.kid_help")
+ },
+ // Could not get the sharing to work without loading androidx and all the modern android things so for now I'll just disable sharing in the android app
+ record: {
+ default: false,
+ name: (0, _i18N.t)("settings.record"),
+ help: (0, _i18N.t)("settings.record_help")
+ },
+ fullscreen: {
+ default: false,
+ name: (0, _i18N.t)("settings.fullscreen"),
+ help: (0, _i18N.t)("settings.fullscreen_help")
+ },
+ donation_reminder: {
+ default: (0, _gameUtils.hoursSpentPlaying)() > 5,
+ name: (0, _i18N.t)("settings.donation_reminder"),
+ help: (0, _i18N.t)("settings.donation_reminder_help")
+ },
+ red_miss: {
+ default: true,
+ name: (0, _i18N.t)("settings.red_miss"),
+ help: (0, _i18N.t)("settings.red_miss_help")
+ },
+ comboIncreaseTexts: {
+ default: true,
+ name: (0, _i18N.t)("settings.comboIncreaseTexts"),
+ help: (0, _i18N.t)("settings.comboIncreaseTexts_help")
+ }
+};
+function isOptionOn(key) {
+ return (0, _settings.getSettingValue)("breakout-settings-enable-" + key, options[key]?.default);
+}
+function toggleOption(key) {
+ (0, _settings.setSettingValue)("breakout-settings-enable-" + key, !isOptionOn(key));
+}
+
+},{"./i18n/i18n":"eNPRm","./settings":"5blfu","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3","./game_utils":"cEeac"}],"cEeac":[function(require,module,exports,__globalThis) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "describeLevel", ()=>describeLevel);
@@ -2748,10 +3114,10 @@ parcelHelpers.export(exports, "highScoreText", ()=>highScoreText);
parcelHelpers.export(exports, "getLevelUnlockCondition", ()=>getLevelUnlockCondition);
parcelHelpers.export(exports, "getBestScoreMatching", ()=>getBestScoreMatching);
parcelHelpers.export(exports, "reasonLevelIsLocked", ()=>reasonLevelIsLocked);
-parcelHelpers.export(exports, "ballTransparency", ()=>ballTransparency);
parcelHelpers.export(exports, "getCoinRenderColor", ()=>getCoinRenderColor);
parcelHelpers.export(exports, "getCornerOffset", ()=>getCornerOffset);
parcelHelpers.export(exports, "isInWebView", ()=>isInWebView);
+parcelHelpers.export(exports, "hoursSpentPlaying", ()=>hoursSpentPlaying);
var _loadGameData = require("./loadGameData");
var _i18N = require("./i18n/i18n");
var _pureFunctions = require("./pure_functions");
@@ -3026,10 +3392,6 @@ function reasonLevelIsLocked(levelIndex, history, mentionBestScore) {
}) + reachedText
};
}
-function ballTransparency(ball, gameState) {
- if (!gameState.perks.transparency) return 0;
- return (0, _pureFunctions.clamp)(gameState.perks.transparency * (1 - ball.y / gameState.gameZoneHeight * 1.2), 0, 1);
-}
function getCoinRenderColor(gameState, coin) {
if (gameState.perks.metamorphosis || (0, _options.isOptionOn)("colorful_coins") || gameState.perks.hypnosis || gameState.perks.rainbow) return coin.color;
return "#ffd300";
@@ -3038,380 +3400,16 @@ function getCornerOffset(gameState) {
return (gameState.levelTime ? gameState.perks.corner_shot * gameState.brickWidth : 0) - gameState.perks.unbounded * gameState.brickWidth;
}
const isInWebView = !!window.location.href.includes("isInWebView=true");
-
-},{"./loadGameData":"l1B4x","./i18n/i18n":"eNPRm","./pure_functions":"6pQh7","./upgrades":"1u3Dx","./getLevelBackground":"7OIPf","./settings":"5blfu","./options":"d5NoS","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"7OIPf":[function(require,module,exports,__globalThis) {
-var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
-parcelHelpers.defineInteropFlag(exports);
-parcelHelpers.export(exports, "getLevelBackground", ()=>getLevelBackground);
-parcelHelpers.export(exports, "hashCode", ()=>hashCode);
-var _backgroundsJson = require("./data/backgrounds.json");
-var _backgroundsJsonDefault = parcelHelpers.interopDefault(_backgroundsJson);
-const backgrounds = (0, _backgroundsJsonDefault.default);
-function getLevelBackground(level) {
- return backgrounds[hashCode(level.name) % backgrounds.length];
-}
-function hashCode(string) {
- let hash = 0;
- for(let i = 0; i < string.length; i++){
- let code = string.charCodeAt(i);
- hash = (hash << 5) - hash + code;
- hash = hash & hash; // Convert to 32bit integer
+function hoursSpentPlaying() {
+ try {
+ const timePlayed = (0, _settings.getSettingValue)("breakout_71_total_play_time", 0);
+ return Math.floor(timePlayed / 1000 / 60 / 60);
+ } catch (e) {
+ return 0;
}
- return Math.abs(hash);
}
-},{"./data/backgrounds.json":"31wW4","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"31wW4":[function(require,module,exports,__globalThis) {
-module.exports = JSON.parse("[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"]");
-
-},{}],"d5NoS":[function(require,module,exports,__globalThis) {
-var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
-parcelHelpers.defineInteropFlag(exports);
-parcelHelpers.export(exports, "options", ()=>options);
-parcelHelpers.export(exports, "isOptionOn", ()=>isOptionOn);
-parcelHelpers.export(exports, "toggleOption", ()=>toggleOption);
-var _i18N = require("./i18n/i18n");
-var _settings = require("./settings");
-var _pureFunctions = require("./pure_functions");
-const options = {
- sound: {
- default: true,
- name: (0, _i18N.t)("settings.sounds"),
- help: (0, _i18N.t)("settings.sounds_help")
- },
- "mobile-mode": {
- default: window.innerHeight > window.innerWidth,
- name: (0, _i18N.t)("settings.mobile"),
- help: (0, _i18N.t)("settings.mobile_help")
- },
- basic: {
- default: false,
- name: (0, _i18N.t)("settings.basic"),
- help: (0, _i18N.t)("settings.basic_help")
- },
- colorful_coins: {
- default: false,
- name: (0, _i18N.t)("settings.colorful_coins"),
- help: (0, _i18N.t)("settings.colorful_coins_help")
- },
- extra_bright: {
- default: true,
- name: (0, _i18N.t)("settings.extra_bright"),
- help: (0, _i18N.t)("settings.extra_bright_help")
- },
- smooth_lighting: {
- default: true,
- name: (0, _i18N.t)("settings.smooth_lighting"),
- help: (0, _i18N.t)("settings.smooth_lighting_help")
- },
- precise_lighting: {
- default: true,
- name: (0, _i18N.t)("settings.precise_lighting"),
- help: (0, _i18N.t)("settings.precise_lighting_help")
- },
- probabilistic_lighting: {
- default: false,
- name: (0, _i18N.t)("settings.probabilistic_lighting"),
- help: (0, _i18N.t)("settings.probabilistic_lighting_help")
- },
- contrast: {
- default: false,
- name: (0, _i18N.t)("settings.contrast"),
- help: (0, _i18N.t)("settings.contrast_help")
- },
- show_fps: {
- default: false,
- name: (0, _i18N.t)("settings.show_fps"),
- help: (0, _i18N.t)("settings.show_fps_help")
- },
- show_stats: {
- default: false,
- name: (0, _i18N.t)("settings.show_stats"),
- help: (0, _i18N.t)("settings.show_stats_help")
- },
- pointerLock: {
- default: false,
- name: (0, _i18N.t)("settings.pointer_lock"),
- help: (0, _i18N.t)("settings.pointer_lock_help")
- },
- easy: {
- default: false,
- name: (0, _i18N.t)("settings.kid"),
- help: (0, _i18N.t)("settings.kid_help")
- },
- // Could not get the sharing to work without loading androidx and all the modern android things so for now I'll just disable sharing in the android app
- record: {
- default: false,
- name: (0, _i18N.t)("settings.record"),
- help: (0, _i18N.t)("settings.record_help")
- },
- fullscreen: {
- default: false,
- name: (0, _i18N.t)("settings.fullscreen"),
- help: (0, _i18N.t)("settings.fullscreen_help")
- },
- donation_reminder: {
- default: (0, _pureFunctions.hoursSpentPlaying)() > 5,
- name: (0, _i18N.t)("settings.donation_reminder"),
- help: (0, _i18N.t)("settings.donation_reminder_help")
- },
- red_miss: {
- default: true,
- name: (0, _i18N.t)("settings.red_miss"),
- help: (0, _i18N.t)("settings.red_miss_help")
- },
- comboIncreaseTexts: {
- default: true,
- name: (0, _i18N.t)("settings.comboIncreaseTexts"),
- help: (0, _i18N.t)("settings.comboIncreaseTexts_help")
- }
-};
-function isOptionOn(key) {
- return (0, _settings.getSettingValue)("breakout-settings-enable-" + key, options[key]?.default);
-}
-function toggleOption(key) {
- (0, _settings.setSettingValue)("breakout-settings-enable-" + key, !isOptionOn(key));
-}
-
-},{"./i18n/i18n":"eNPRm","./settings":"5blfu","./pure_functions":"6pQh7","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"6rQoT":[function(require,module,exports,__globalThis) {
-var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
-parcelHelpers.defineInteropFlag(exports);
-parcelHelpers.export(exports, "levelIconHTML", ()=>levelIconHTML);
-let levelIconHTMLCanvas = document.createElement("canvas");
-const levelIconHTMLCanvasCtx = levelIconHTMLCanvas.getContext("2d", {
- antialias: false,
- alpha: true
-});
-function levelIconHTML(bricks, levelSize, color) {
- const size = 46;
- const c = levelIconHTMLCanvas;
- const ctx = levelIconHTMLCanvasCtx;
- if (!ctx) return "";
- c.width = size;
- c.height = size;
- ctx.clearRect(0, 0, size, size);
- const pxSize = size / levelSize;
- for(let x = 0; x < levelSize; x++)for(let y = 0; y < levelSize; y++){
- const c = bricks[y * levelSize + x];
- if (c) {
- ctx.fillStyle = c;
- ctx.fillRect(Math.floor(pxSize * x), Math.floor(pxSize * y), Math.ceil(pxSize), Math.ceil(pxSize));
- }
- }
- return ` `;
-}
-
-},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"dQKPV":[function(require,module,exports,__globalThis) {
-var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
-parcelHelpers.defineInteropFlag(exports);
-parcelHelpers.export(exports, "playPendingSounds", ()=>playPendingSounds);
-parcelHelpers.export(exports, "sounds", ()=>sounds);
-parcelHelpers.export(exports, "getAudioContext", ()=>getAudioContext);
-parcelHelpers.export(exports, "getAudioRecordingTrack", ()=>getAudioRecordingTrack);
-var _options = require("./options");
-let lastPlay = Date.now();
-function playPendingSounds(gameState) {
- if (lastPlay > Date.now() - 60) return;
- lastPlay = Date.now();
- for(let key in gameState.aboutToPlaySound){
- const soundName = key;
- const ex = gameState.aboutToPlaySound[soundName];
- if (ex.vol) {
- sounds[soundName](// In stress test, dim the sounds but play them
- Math.min(1, ex.vol), pixelsToPan(gameState, ex.x), gameState.combo);
- ex.vol = 0;
- }
- }
-}
-const sounds = {
- wallBeep: (volume, pan)=>{
- if (!(0, _options.isOptionOn)("sound")) return;
- createSingleBounceSound(800, pan, volume);
- },
- plouf: (volume, pan)=>{
- if (!(0, _options.isOptionOn)("sound")) return;
- createSingleBounceSound(500, pan, volume * 0.5);
- // createWaterDropSound(800, pan, volume*0.2, 0.2,'triangle')
- },
- comboIncreaseMaybe: (volume, pan, combo)=>{
- if (!(0, _options.isOptionOn)("sound")) return;
- let delta = 0;
- if (!isNaN(lastComboPlayed)) {
- if (lastComboPlayed < combo) delta = 1;
- if (lastComboPlayed > combo) delta = -1;
- }
- playShepard(delta, pan, volume);
- lastComboPlayed = combo;
- },
- comboDecrease (volume, pan, combo) {
- if (!(0, _options.isOptionOn)("sound")) return;
- playShepard(-1, pan, volume);
- },
- coinBounce: (volume, pan, combo)=>{
- if (!(0, _options.isOptionOn)("sound")) return;
- createSingleBounceSound(1200, pan, volume, 0.1, "triangle");
- },
- // void: (volume: number, pan: number) => {
- // if (!isOptionOn("sound")) return;
- // createSingleBounceSound(1200, pan, volume, 0.5, "sawtooth");
- // createSingleBounceSound(600, pan, volume, 0.3, "sawtooth");
- // },
- // freeze: (volume: number, pan: number) => {
- // if (!isOptionOn("sound")) return;
- // createSingleBounceSound(220, pan, volume, 0.5, "square");
- // createSingleBounceSound(440, pan, volume, 0.5, "square");
- // },
- explode: (volume, pan, combo)=>{
- if (!(0, _options.isOptionOn)("sound")) return;
- createExplosionSound(pan);
- },
- lifeLost (volume, pan, combo) {
- if (!(0, _options.isOptionOn)("sound")) return;
- createShatteredGlassSound(pan);
- },
- coinCatch (volume, pan, combo) {
- if (!(0, _options.isOptionOn)("sound")) return;
- createSingleBounceSound(900, pan, volume, 0.1, "triangle");
- },
- colorChange (volume, pan, combo) {
- createSingleBounceSound(400, pan, volume, 0.5, "sine");
- createSingleBounceSound(800, pan, volume * 0.5, 0.2, "square");
- }
-};
-// How to play the code on the leftconst context = new window.AudioContext();
-let audioContext, audioRecordingTrack;
-function getAudioContext() {
- if (!audioContext) {
- if (!(0, _options.isOptionOn)("sound")) return null;
- audioContext = new (window.AudioContext || window.webkitAudioContext)();
- audioRecordingTrack = audioContext.createMediaStreamDestination();
- }
- return audioContext;
-}
-function getAudioRecordingTrack() {
- getAudioContext();
- return audioRecordingTrack;
-}
-function createSingleBounceSound(baseFreq = 800, pan = 0.5, volume = 1, duration = 0.1, type = "sine") {
- const context = getAudioContext();
- if (!context) return;
- const oscillator = createOscillator(context, baseFreq, type);
- // Create a gain node to control the volume
- const gainNode = context.createGain();
- oscillator.connect(gainNode);
- // Create a stereo panner node for left-right panning
- const panner = context.createStereoPanner();
- panner.pan.setValueAtTime(pan * 2 - 1, context.currentTime);
- gainNode.connect(panner);
- panner.connect(context.destination);
- panner.connect(audioRecordingTrack);
- // Set up the gain envelope to simulate the impact and quick decay
- gainNode.gain.setValueAtTime(0.8 * volume, context.currentTime); // Initial impact
- gainNode.gain.exponentialRampToValueAtTime(0.001, context.currentTime + duration); // Quick decay
- // Start the oscillator
- oscillator.start(context.currentTime);
- // Stop the oscillator after the decay
- oscillator.stop(context.currentTime + duration);
-}
-let noiseBuffer;
-function getNoiseBuffer(context) {
- if (!noiseBuffer) {
- const bufferSize = context.sampleRate * 2; // 2 seconds
- noiseBuffer = context.createBuffer(1, bufferSize, context.sampleRate);
- const output = noiseBuffer.getChannelData(0);
- // Fill the buffer with random noise
- for(let i = 0; i < bufferSize; i++)output[i] = Math.random() * 2 - 1;
- }
- return noiseBuffer;
-}
-function createExplosionSound(pan = 0.5) {
- const context = getAudioContext();
- if (!context) return;
- // Create an audio buffer
- // Create a noise source
- const noiseSource = context.createBufferSource();
- noiseSource.buffer = getNoiseBuffer(context);
- // Create a gain node to control the volume
- const gainNode = context.createGain();
- noiseSource.connect(gainNode);
- // Create a filter to shape the explosion sound
- const filter = context.createBiquadFilter();
- filter.type = "lowpass";
- filter.frequency.setValueAtTime(1000, context.currentTime); // Set the initial frequency
- gainNode.connect(filter);
- // Create a stereo panner node for left-right panning
- const panner = context.createStereoPanner();
- panner.pan.setValueAtTime(pan * 2 - 1, context.currentTime); // pan 0 to 1 maps to -1 to 1
- // Connect filter to panner and then to the destination (speakers)
- filter.connect(panner);
- panner.connect(context.destination);
- panner.connect(audioRecordingTrack);
- // Ramp down the gain to simulate the explosion's fade-out
- gainNode.gain.setValueAtTime(1, context.currentTime);
- gainNode.gain.exponentialRampToValueAtTime(0.01, context.currentTime + 1);
- // Lower the filter frequency over time to create the "explosive" effect
- filter.frequency.exponentialRampToValueAtTime(60, context.currentTime + 1);
- // Start the noise source
- noiseSource.start(context.currentTime);
- // Stop the noise source after the sound has played
- noiseSource.stop(context.currentTime + 1);
-}
-function pixelsToPan(gameState, pan) {
- return Math.max(0, Math.min(1, (pan - gameState.offsetXRoundedDown) / gameState.gameZoneWidthRoundedUp));
-}
-let lastComboPlayed = NaN, shepard = 6;
-function playShepard(delta, pan, volume) {
- const shepardMax = 11, factor = 1.05945594920268, baseNote = 392;
- shepard += delta;
- if (shepard > shepardMax) shepard = 0;
- if (shepard < 0) shepard = shepardMax;
- const play = (note)=>{
- const freq = baseNote * Math.pow(factor, note);
- const diff = Math.abs(note - shepardMax * 0.5);
- const maxDistanceToIdeal = 1.5 * shepardMax;
- const vol = Math.max(0, volume * (1 - diff / maxDistanceToIdeal));
- createSingleBounceSound(freq, pan, vol);
- return freq.toFixed(2) + " at " + Math.floor(vol * 100) + "% diff " + diff;
- };
- play(1 + shepardMax + shepard);
- play(shepard);
- play(-1 - shepardMax + shepard);
-}
-function createShatteredGlassSound(pan) {
- const context = getAudioContext();
- if (!context) return;
- const oscillators = [
- createOscillator(context, 3000, "square"),
- createOscillator(context, 4500, "square"),
- createOscillator(context, 6000, "square")
- ];
- const gainNode = context.createGain();
- const noiseSource = context.createBufferSource();
- noiseSource.buffer = getNoiseBuffer(context);
- oscillators.forEach((oscillator)=>oscillator.connect(gainNode));
- noiseSource.connect(gainNode);
- gainNode.gain.setValueAtTime(0.2, context.currentTime);
- oscillators.forEach((oscillator)=>oscillator.start());
- noiseSource.start();
- oscillators.forEach((oscillator)=>oscillator.stop(context.currentTime + 0.2));
- noiseSource.stop(context.currentTime + 0.2);
- gainNode.gain.exponentialRampToValueAtTime(0.001, context.currentTime + 0.2);
- // Create a stereo panner node for left-right panning
- const panner = context.createStereoPanner();
- panner.pan.setValueAtTime(pan * 2 - 1, context.currentTime);
- gainNode.connect(panner);
- panner.connect(context.destination);
- panner.connect(audioRecordingTrack);
- gainNode.connect(panner);
-}
-// Helper function to create an oscillator with a specific frequency
-function createOscillator(context, frequency, type) {
- const oscillator = context.createOscillator();
- oscillator.type = type;
- oscillator.frequency.setValueAtTime(frequency, context.currentTime);
- return oscillator;
-}
-
-},{"./options":"d5NoS","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"2n0gK":[function(require,module,exports,__globalThis) {
+},{"./loadGameData":"l1B4x","./i18n/i18n":"eNPRm","./pure_functions":"6pQh7","./upgrades":"1u3Dx","./getLevelBackground":"7OIPf","./settings":"5blfu","./options":"d5NoS","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"2n0gK":[function(require,module,exports,__globalThis) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
if ("serviceWorker" in navigator && window.location.href.endsWith("/index.html?isPWA=true")) {
@@ -4318,7 +4316,7 @@ function ballTick(gameState, ball, frames) {
makeLight(gameState, (0, _gameUtils.brickCenterX)(gameState, hitBrick), (0, _gameUtils.brickCenterY)(gameState, hitBrick), "#FFFFFF", gameState.brickWidth + 2, 50 * gameState.brickHP[hitBrick]);
}
}
- if (!(0, _options.isOptionOn)("basic") && (0, _gameUtils.ballTransparency)(ball, gameState) < Math.random()) {
+ if (!(0, _options.isOptionOn)("basic") && (0, _pureFunctions.ballTransparency)(ball, gameState) < Math.random()) {
const remainingPierce = ball.piercePoints;
const remainingSapper = ball.sapperUses < gameState.perks.sapper;
const willMiss = (0, _options.isOptionOn)("red_miss") && ball.vy > 0 && !ball.hitSinceBounce;
@@ -4466,13 +4464,13 @@ function applyOttawaTreatyPerk(gameState, index, ball) {
if (!gameState.perks.ottawa_treaty) return;
if (ball.sapperUses) return;
const originalColor = gameState.bricks[index];
- if (originalColor == 'black') return;
+ if (originalColor == "black") return;
const x = index % gameState.gridSize;
const y = Math.floor(index / gameState.gridSize);
let converted = 0;
for(let dx = -1; dx <= 1; dx++)for(let dy = -1; dy <= 1; dy++)if (dx || dy) {
const nIndex = (0, _gameUtils.getRowColIndex)(gameState, y + dy, x + dx);
- if (gameState.bricks[nIndex] && gameState.bricks[nIndex] === 'black') {
+ if (gameState.bricks[nIndex] && gameState.bricks[nIndex] === "black") {
setBrick(gameState, nIndex, originalColor);
schedulGameSound(gameState, "colorChange", (0, _gameUtils.brickCenterX)(gameState, index), 1);
// Avoid infinite bricks generation hack
@@ -4545,7 +4543,8 @@ function render(gameState) {
max: (0, _gameUtils.max_levels)(gameState)
});
else menuLabel.innerText = (0, _i18N.t)("play.menu_label");
- const catchRate = gameState.levelSpawnedCoins ? (gameState.score - gameState.levelStartScore) / (gameState.levelSpawnedCoins || 1) : 1;
+ const catchRate = gameState.levelSpawnedCoins ? (gameState.score - gameState.levelStartScore) / (gameState.levelSpawnedCoins || 1) : // gameState.levelSpawnedCoins
+ 1;
(0, _game.startWork)("render:scoreDisplay");
scoreDisplay.innerHTML = ((0, _options.isOptionOn)("show_fps") || gameState.startParams.computer_controlled ? `
@@ -4588,7 +4587,7 @@ function render(gameState) {
(0, _game.startWork)("render:halo:balls");
gameState.balls.forEach((ball, index)=>{
if (shouldSkip(index)) return;
- haloCanvasCtx.globalAlpha = 0.3 * (1 - (0, _gameUtils.ballTransparency)(ball, gameState));
+ haloCanvasCtx.globalAlpha = 0.3 * (1 - (0, _pureFunctions.ballTransparency)(ball, gameState));
drawFuzzyBall(haloCanvasCtx, gameState.ballsColor, gameState.ballSize * 2 * brightness / haloScale, ball.x / haloScale, ball.y / haloScale);
});
(0, _game.startWork)("render:halo:bricks");
@@ -4693,7 +4692,7 @@ function render(gameState) {
// Black shadow around balls
ctx.globalCompositeOperation = "source-over";
gameState.balls.forEach((ball)=>{
- ctx.globalAlpha = Math.min(0.8, (0, _gameStateMutators.liveCount)(gameState.coins) / 20) * (1 - (0, _gameUtils.ballTransparency)(ball, gameState));
+ ctx.globalAlpha = Math.min(0.8, (0, _gameStateMutators.liveCount)(gameState.coins) / 20) * (1 - (0, _pureFunctions.ballTransparency)(ball, gameState));
drawBall(ctx, level.color || "#000", gameState.ballSize * 6, ball.x, ball.y);
});
(0, _game.startWork)("render:bricks");
@@ -4736,7 +4735,7 @@ function render(gameState) {
ctx.globalCompositeOperation = "source-over";
gameState.balls.forEach((ball)=>{
const drawingColor = gameState.ballsColor;
- const ballAlpha = 1 - (0, _gameUtils.ballTransparency)(ball, gameState);
+ const ballAlpha = 1 - (0, _pureFunctions.ballTransparency)(ball, gameState);
ctx.globalAlpha = ballAlpha;
// The white border around is to distinguish colored balls from coins/bg
drawBall(ctx, drawingColor, gameState.ballSize, ball.x, ball.y, gameState.puckColor);
@@ -5748,7 +5747,7 @@ async function editRawLevelList(nth, color = "W") {
return;
}
if (action === "copy") {
- let text = "```\n[" + (level.name || 'unnamed level')?.replace(/\[|\]/gi, " ") + "]";
+ let text = "```\n[" + (level.name || "unnamed level")?.replace(/\[|\]/gi, " ") + "]";
bricks.forEach((b, bi)=>{
if (!(bi % level.size)) text += "\n";
text += b;
@@ -5820,7 +5819,7 @@ async function openCreativeModePerksPicker() {
value: l,
disabled: !!problem,
tooltip: problem || (0, _gameUtils.describeLevel)(l),
- className: ''
+ className: ""
};
}),
...customLevels.map((l)=>({
@@ -5829,23 +5828,23 @@ async function openCreativeModePerksPicker() {
value: l,
disabled: !l.bricks.filter((b)=>b !== "_").length,
tooltip: (0, _gameUtils.describeLevel)(l),
- className: ''
+ className: ""
}))
];
- const selectedLeveOption = levelOptions.find((l)=>l.text === (0, _settings.getSettingValue)("creativeModeLevel", '')) || levelOptions[0];
- selectedLeveOption.className = 'highlight';
+ const selectedLeveOption = levelOptions.find((l)=>l.text === (0, _settings.getSettingValue)("creativeModeLevel", "")) || levelOptions[0];
+ selectedLeveOption.className = "highlight";
const choice = await (0, _asyncAlert.asyncAlert)({
title: (0, _i18N.t)("lab.menu_entry"),
className: "actionsAsGrid",
content: [
{
- icon: (0, _loadGameData.icons)['icon:reset'],
+ icon: (0, _loadGameData.icons)["icon:reset"],
value: "reset",
text: (0, _i18N.t)("lab.reset"),
disabled: !(0, _gameUtils.sumOfValues)(creativeModePerks)
},
{
- icon: (0, _loadGameData.icons)['icon:new_run'],
+ icon: (0, _loadGameData.icons)["icon:new_run"],
value: "play",
text: (0, _i18N.t)("lab.play"),
disabled: !(0, _gameUtils.sumOfValues)(creativeModePerks)
@@ -5869,8 +5868,8 @@ async function openCreativeModePerksPicker() {
creativeModePerks[u.id] = 0;
});
(0, _settings.setSettingValue)("creativeModePerks", creativeModePerks);
- (0, _settings.setSettingValue)("creativeModeLevel", '');
- } else if (choice === "play" || "bricks" in choice && choice.name == (0, _settings.getSettingValue)("creativeModeLevel", '')) {
+ (0, _settings.setSettingValue)("creativeModeLevel", "");
+ } else if (choice === "play" || "bricks" in choice && choice.name == (0, _settings.getSettingValue)("creativeModeLevel", "")) {
if (await (0, _game.confirmRestart)((0, _game.gameState))) {
(0, _game.restart)({
perks: creativeModePerks,
@@ -6297,12 +6296,12 @@ migrate("set_breakout_71_unlocked_levels" + (0, _versionJsonDefault.default), ()
});
localStorage.setItem("breakout_71_unlocked_levels", JSON.stringify(breakout_71_unlocked_levels));
});
-migrate('clean_ls', ()=>{
+migrate("clean_ls", ()=>{
for(let key in localStorage)try {
JSON.parse(localStorage.getItem(key) || "null");
} catch (e) {
localStorage.removeItem(key);
- console.warn('Removed invalid key ' + key, e);
+ console.warn("Removed invalid key " + key, e);
}
});
afterMigration();
diff --git a/src/PWA/sw-b71.js b/src/PWA/sw-b71.js
index b3f3dc7..ef018fd 100644
--- a/src/PWA/sw-b71.js
+++ b/src/PWA/sw-b71.js
@@ -1,5 +1,5 @@
// The version of the cache.
-const VERSION = "29085904";
+const VERSION = "29087244";
// The name of the cache
const CACHE_NAME = `breakout-71-${VERSION}`;
diff --git a/src/creative.ts b/src/creative.ts
index a4dc83d..c0036f5 100644
--- a/src/creative.ts
+++ b/src/creative.ts
@@ -36,54 +36,54 @@ export function creativeMode(gameState: GameState) {
export async function openCreativeModePerksPicker() {
let creativeModePerks: Partial<{ [id in PerkId]: number }> = getSettingValue(
- "creativeModePerks",
- {},
- );
+ "creativeModePerks",
+ {},
+ );
const customLevels = (getSettingValue("custom_levels", []) as RawLevel[]).map(
transformRawLevel,
);
- while (true ) {
+ while (true) {
+ const levelOptions = [
+ ...allLevels.map((l, li) => {
+ const problem = reasonLevelIsLocked(li, getHistory(), true)?.text || "";
+ return {
+ icon: icons[l.name],
+ text: l.name,
+ value: l,
+ disabled: !!problem,
+ tooltip: problem || describeLevel(l),
+ className: "",
+ };
+ }),
+ ...customLevels.map((l) => ({
+ icon: levelIconHTML(l.bricks, l.size, l.color),
+ text: l.name,
+ value: l,
+ disabled: !l.bricks.filter((b) => b !== "_").length,
+ tooltip: describeLevel(l),
+ className: "",
+ })),
+ ];
- const levelOptions= [
- ...allLevels.map((l, li) => {
- const problem =
- reasonLevelIsLocked(li, getHistory(), true)?.text || "";
- return {
- icon: icons[l.name],
- text: l.name,
- value: l,
- disabled: !!problem,
- tooltip: problem || describeLevel(l),
- className:''
- };
- }),
- ...customLevels.map((l) => ({
- icon: levelIconHTML(l.bricks, l.size, l.color),
- text: l.name,
- value: l,
- disabled: !l.bricks.filter((b) => b !== "_").length,
- tooltip: describeLevel(l),
- className:''
- }))
- ]
+ const selectedLeveOption =
+ levelOptions.find(
+ (l) => l.text === getSettingValue("creativeModeLevel", ""),
+ ) || levelOptions[0];
+ selectedLeveOption.className = "highlight";
- const selectedLeveOption= levelOptions.find(l=>l.text===getSettingValue("creativeModeLevel", '')) || levelOptions[0]
- selectedLeveOption.className= 'highlight'
-
-
- const choice=await asyncAlert({
+ const choice = await asyncAlert({
title: t("lab.menu_entry"),
className: "actionsAsGrid",
content: [
{
- icon: icons['icon:reset'],
+ icon: icons["icon:reset"],
value: "reset",
text: t("lab.reset"),
disabled: !sumOfValues(creativeModePerks),
},
- {
- icon: icons['icon:new_run'],
+ {
+ icon: icons["icon:new_run"],
value: "play",
text: t("lab.play"),
disabled: !sumOfValues(creativeModePerks),
@@ -106,24 +106,28 @@ export async function openCreativeModePerksPicker() {
tooltip: u.help(creativeModePerks[u.id] || 1),
})),
t("lab.select_level"),
- ...levelOptions
+ ...levelOptions,
],
- })
- if(!choice)return
+ });
+ if (!choice) return;
if (choice === "reset") {
upgrades.forEach((u) => {
creativeModePerks[u.id] = 0;
});
setSettingValue("creativeModePerks", creativeModePerks);
- setSettingValue("creativeModeLevel", '')
- } else if (choice === "play" || ("bricks" in choice && choice.name==getSettingValue("creativeModeLevel", ''))) {
+ setSettingValue("creativeModeLevel", "");
+ } else if (
+ choice === "play" ||
+ ("bricks" in choice &&
+ choice.name == getSettingValue("creativeModeLevel", ""))
+ ) {
if (await confirmRestart(gameState)) {
restart({
perks: creativeModePerks,
level: selectedLeveOption.value,
isCreativeRun: true,
});
- return
+ return;
}
} else if ("bricks" in choice) {
setSettingValue("creativeModeLevel", choice.name);
diff --git a/src/data/levels.json b/src/data/levels.json
index 6ea574f..b646970 100644
--- a/src/data/levels.json
+++ b/src/data/levels.json
@@ -1373,4 +1373,4 @@
"svg": null,
"color": ""
}
-]
\ No newline at end of file
+]
diff --git a/src/data/version.json b/src/data/version.json
index c553969..6d0c81b 100644
--- a/src/data/version.json
+++ b/src/data/version.json
@@ -1 +1 @@
-"29085904"
+"29087244"
diff --git a/src/game.less b/src/game.less
index b57da4f..c061798 100644
--- a/src/game.less
+++ b/src/game.less
@@ -585,8 +585,7 @@ h2.histogram-title strong {
opacity: 0.3;
}
}
-.not-highlighed{
- opacity: 0.8; color: #8a8a8a;
-
-
+.not-highlighed {
+ opacity: 0.8;
+ color: #8a8a8a;
}
diff --git a/src/game.ts b/src/game.ts
index 9bc64c3..b5d7fde 100644
--- a/src/game.ts
+++ b/src/game.ts
@@ -23,6 +23,7 @@ import {
describeLevel,
getRowColIndex,
highScoreText,
+ hoursSpentPlaying,
isInWebView,
levelsListHTMl,
max_levels,
@@ -79,7 +80,6 @@ import {
catchRateBest,
catchRateGood,
clamp,
- hoursSpentPlaying,
levelTimeBest,
levelTimeGood,
missesBest,
@@ -248,7 +248,8 @@ setInterval(() => {
}, 1000);
export async function openUpgradesPicker(gameState: GameState) {
- const catchRate = (gameState.score - gameState.levelStartScore) /
+ const catchRate =
+ (gameState.score - gameState.levelStartScore) /
(gameState.levelSpawnedCoins || 1);
let repeats = 1;
diff --git a/src/gameStateMutators.ts b/src/gameStateMutators.ts
index b83734e..41cae99 100644
--- a/src/gameStateMutators.ts
+++ b/src/gameStateMutators.ts
@@ -1,2177 +1,2177 @@
import {
- Ball,
- BallLike,
- Coin,
- colorString,
- GameState,
- LightFlash,
- ParticleFlash,
- PerkId,
- ReusableArray,
- TextFlash,
+ Ball,
+ BallLike,
+ Coin,
+ colorString,
+ GameState,
+ LightFlash,
+ ParticleFlash,
+ PerkId,
+ ReusableArray,
+ TextFlash,
} from "./types";
import {
- ballTransparency,
- brickCenterX,
- brickCenterY,
- currentLevelInfo,
- distance2,
- distanceBetween,
- getClosestBall,
- getCoinRenderColor,
- getCornerOffset,
- getMajorityValue,
- getPossibleUpgrades,
- getRowColIndex,
- isMovingWhilePassiveIncome,
- isPickyEatingPossible,
- max_levels,
- reachRedRowIndex,
- shouldPierceByColor,
- telekinesisEffectRate,
- yoyoEffectRate,
+ brickCenterX,
+ brickCenterY,
+ currentLevelInfo,
+ distance2,
+ distanceBetween,
+ getClosestBall,
+ getCoinRenderColor,
+ getCornerOffset,
+ getMajorityValue,
+ getPossibleUpgrades,
+ getRowColIndex,
+ isMovingWhilePassiveIncome,
+ isPickyEatingPossible,
+ max_levels,
+ reachRedRowIndex,
+ shouldPierceByColor,
+ telekinesisEffectRate,
+ yoyoEffectRate,
} from "./game_utils";
-import {t} from "./i18n/i18n";
-import {icons} from "./loadGameData";
+import { t } from "./i18n/i18n";
+import { icons } from "./loadGameData";
-import {getCurrentMaxCoins, getCurrentMaxParticles} from "./settings";
-import {background} from "./render";
-import {gameOver} from "./gameOver";
+import { getCurrentMaxCoins, getCurrentMaxParticles } from "./settings";
+import { background } from "./render";
+import { gameOver } from "./gameOver";
import {
- brickIndex,
- fitSize,
- gameState,
- hasBrick,
- hitsSomething,
- openUpgradesPicker,
- pause,
- startComputerControlledGame,
+ brickIndex,
+ fitSize,
+ gameState,
+ hasBrick,
+ hitsSomething,
+ openUpgradesPicker,
+ pause,
+ startComputerControlledGame,
} from "./game";
-import {stopRecording} from "./recording";
-import {isOptionOn} from "./options";
-import {clamp, coinsBoostedCombo, comboKeepingRate, shouldCoinsStick} from "./pure_functions";
-import {addToTotalScore} from "./addToTotalScore";
-import {hashCode} from "./getLevelBackground";
+import { stopRecording } from "./recording";
+import { isOptionOn } from "./options";
+import {
+ ballTransparency,
+ clamp,
+ coinsBoostedCombo,
+ comboKeepingRate,
+ shouldCoinsStick,
+} from "./pure_functions";
+import { addToTotalScore } from "./addToTotalScore";
+import { hashCode } from "./getLevelBackground";
export function setMousePos(gameState: GameState, x: number) {
- if (gameState.startParams.computer_controlled) return;
- gameState.puckPosition = x;
+ if (gameState.startParams.computer_controlled) return;
+ gameState.puckPosition = x;
- // Sets the puck position, and updates the ball position if they are supposed to follow it
- gameState.needsRender = true;
+ // Sets the puck position, and updates the ball position if they are supposed to follow it
+ gameState.needsRender = true;
}
function getBallDefaultVx(gameState: GameState) {
- return (
- (gameState.perks.concave_puck ? 0 : 1) *
- (Math.random() > 0.5 ? gameState.baseSpeed : -gameState.baseSpeed)
- );
+ return (
+ (gameState.perks.concave_puck ? 0 : 1) *
+ (Math.random() > 0.5 ? gameState.baseSpeed : -gameState.baseSpeed)
+ );
}
function computerControl(gameState: GameState) {
- let targetX = gameState.puckPosition;
- const ball = getClosestBall(
- gameState,
- gameState.puckPosition,
- gameState.gameZoneHeight,
- );
- if (!ball) return;
- const puckOffset =
- (((hashCode(gameState.runStatistics.puck_bounces + "goeirjgoriejg") % 100) -
- 50) /
- 100) *
- gameState.puckWidth;
+ let targetX = gameState.puckPosition;
+ const ball = getClosestBall(
+ gameState,
+ gameState.puckPosition,
+ gameState.gameZoneHeight,
+ );
+ if (!ball) return;
+ const puckOffset =
+ (((hashCode(gameState.runStatistics.puck_bounces + "goeirjgoriejg") % 100) -
+ 50) /
+ 100) *
+ gameState.puckWidth;
- if (ball.y > gameState.gameZoneHeight / 2 && ball.vy > 0) {
- targetX = ball.x + puckOffset;
+ if (ball.y > gameState.gameZoneHeight / 2 && ball.vy > 0) {
+ targetX = ball.x + puckOffset;
+ } else {
+ let coinsTotalX = 0,
+ coinsCount = 0;
+ forEachLiveOne(gameState.coins, (c) => {
+ if (c.vy > 0 && c.y > gameState.gameZoneHeight / 2) {
+ coinsTotalX += c.x;
+ coinsCount++;
+ }
+ });
+ if (coinsCount) {
+ targetX = coinsTotalX / coinsCount;
} else {
- let coinsTotalX = 0,
- coinsCount = 0;
- forEachLiveOne(gameState.coins, (c) => {
- if (c.vy > 0 && c.y > gameState.gameZoneHeight / 2) {
- coinsTotalX += c.x;
- coinsCount++;
- }
- });
- if (coinsCount) {
- targetX = coinsTotalX / coinsCount;
- } else {
- targetX = gameState.canvasWidth / 2;
- }
+ targetX = gameState.canvasWidth / 2;
}
+ }
- gameState.puckPosition += clamp(
- (targetX - gameState.puckPosition) / 10,
- -10,
- 10,
- );
- if (gameState.levelTime > 30000) {
- startComputerControlledGame(gameState.startParams.stress);
- }
+ gameState.puckPosition += clamp(
+ (targetX - gameState.puckPosition) / 10,
+ -10,
+ 10,
+ );
+ if (gameState.levelTime > 30000) {
+ startComputerControlledGame(gameState.startParams.stress);
+ }
}
export function resetBalls(gameState: GameState) {
- // Always compute speed first
- normalizeGameState(gameState);
- const count = 1 + (gameState.perks?.multiball || 0);
- const perBall = gameState.puckWidth / (count + 1);
- gameState.balls = [];
- gameState.ballsColor = "#FFFFFF";
- if (gameState.perks.picky_eater || gameState.perks.pierce_color) {
- gameState.ballsColor =
- getMajorityValue(gameState.bricks.filter((i) => i)) || "#FFFFFF";
- }
- for (let i = 0; i < count; i++) {
- const x =
- gameState.puckPosition - gameState.puckWidth / 2 + perBall * (i + 1);
- const vx = getBallDefaultVx(gameState);
+ // Always compute speed first
+ normalizeGameState(gameState);
+ const count = 1 + (gameState.perks?.multiball || 0);
+ const perBall = gameState.puckWidth / (count + 1);
+ gameState.balls = [];
+ gameState.ballsColor = "#FFFFFF";
+ if (gameState.perks.picky_eater || gameState.perks.pierce_color) {
+ gameState.ballsColor =
+ getMajorityValue(gameState.bricks.filter((i) => i)) || "#FFFFFF";
+ }
+ for (let i = 0; i < count; i++) {
+ const x =
+ gameState.puckPosition - gameState.puckWidth / 2 + perBall * (i + 1);
+ const vx = getBallDefaultVx(gameState);
- gameState.balls.push({
- x,
- previousX: x,
- y: gameState.gameZoneHeight - 1.5 * gameState.ballSize,
- previousY: gameState.gameZoneHeight - 1.5 * gameState.ballSize,
- vx,
- previousVX: vx,
- vy: -gameState.baseSpeed,
- previousVY: -gameState.baseSpeed,
- piercePoints: gameState.perks.pierce * 3,
- hitSinceBounce: 0,
- brokenSinceBounce: 0,
- sidesHitsSinceBounce: 0,
- sapperUses: 0,
- });
- }
- gameState.ballStickToPuck = true;
+ gameState.balls.push({
+ x,
+ previousX: x,
+ y: gameState.gameZoneHeight - 1.5 * gameState.ballSize,
+ previousY: gameState.gameZoneHeight - 1.5 * gameState.ballSize,
+ vx,
+ previousVX: vx,
+ vy: -gameState.baseSpeed,
+ previousVY: -gameState.baseSpeed,
+ piercePoints: gameState.perks.pierce * 3,
+ hitSinceBounce: 0,
+ brokenSinceBounce: 0,
+ sidesHitsSinceBounce: 0,
+ sapperUses: 0,
+ });
+ }
+ gameState.ballStickToPuck = true;
}
export function putBallsAtPuck(gameState: GameState) {
- // This reset could be abused to cheat quite easily
- const count = gameState.balls.length;
- const perBall = gameState.puckWidth / (count + 1);
- // const vx = getBallDefaultVx(gameState);
- gameState.balls.forEach((ball, i) => {
- const x =
- gameState.puckPosition - gameState.puckWidth / 2 + perBall * (i + 1);
+ // This reset could be abused to cheat quite easily
+ const count = gameState.balls.length;
+ const perBall = gameState.puckWidth / (count + 1);
+ // const vx = getBallDefaultVx(gameState);
+ gameState.balls.forEach((ball, i) => {
+ const x =
+ gameState.puckPosition - gameState.puckWidth / 2 + perBall * (i + 1);
- ball.x = x;
- ball.previousX = x;
- ball.y = gameState.gameZoneHeight - 1.5 * gameState.ballSize;
- ball.previousY = ball.y;
- ball.hitSinceBounce = 0;
- ball.brokenSinceBounce = 0;
- ball.sidesHitsSinceBounce = 0;
- ball.piercePoints = gameState.perks.pierce * 3;
- });
+ ball.x = x;
+ ball.previousX = x;
+ ball.y = gameState.gameZoneHeight - 1.5 * gameState.ballSize;
+ ball.previousY = ball.y;
+ ball.hitSinceBounce = 0;
+ ball.brokenSinceBounce = 0;
+ ball.sidesHitsSinceBounce = 0;
+ ball.piercePoints = gameState.perks.pierce * 3;
+ });
}
export function normalizeGameState(gameState: GameState) {
- // This function resets most parameters on the state to correct values, and should be used even when the game is paused
+ // This function resets most parameters on the state to correct values, and should be used even when the game is paused
- gameState.baseSpeed = Math.max(
- 3,
- gameState.gameZoneWidth / 12 / 10 +
- gameState.currentLevel / 3 +
- gameState.levelTime / (30 * 1000) -
- gameState.perks.slow_down * 2,
- );
+ gameState.baseSpeed = Math.max(
+ 3,
+ gameState.gameZoneWidth / 12 / 10 +
+ gameState.currentLevel / 3 +
+ gameState.levelTime / (30 * 1000) -
+ gameState.perks.slow_down * 2,
+ );
- gameState.puckWidth = Math.max(
- gameState.ballSize,
- (gameState.gameZoneWidth / 12) *
- Math.min(
- 12,
- 3 - gameState.perks.smaller_puck + gameState.perks.bigger_puck,
- ),
- );
+ gameState.puckWidth = Math.max(
+ gameState.ballSize,
+ (gameState.gameZoneWidth / 12) *
+ Math.min(
+ 12,
+ 3 - gameState.perks.smaller_puck + gameState.perks.bigger_puck,
+ ),
+ );
- const corner = getCornerOffset(gameState);
+ const corner = getCornerOffset(gameState);
- let minX = gameState.offsetXRoundedDown + gameState.puckWidth / 2 - corner;
+ let minX = gameState.offsetXRoundedDown + gameState.puckWidth / 2 - corner;
- let maxX =
- gameState.offsetXRoundedDown +
- gameState.gameZoneWidthRoundedUp -
- gameState.puckWidth / 2 +
- corner;
+ let maxX =
+ gameState.offsetXRoundedDown +
+ gameState.gameZoneWidthRoundedUp -
+ gameState.puckWidth / 2 +
+ corner;
- gameState.puckPosition = clamp(gameState.puckPosition, minX, maxX);
+ gameState.puckPosition = clamp(gameState.puckPosition, minX, maxX);
- if (gameState.ballStickToPuck) {
- putBallsAtPuck(gameState);
- }
+ if (gameState.ballStickToPuck) {
+ putBallsAtPuck(gameState);
+ }
- if (
- Math.abs(gameState.lastPuckPosition - gameState.puckPosition) > 1 &&
- gameState.running
- ) {
- gameState.lastPuckMove = gameState.levelTime;
- }
- gameState.lastPuckPosition = gameState.puckPosition;
+ if (
+ Math.abs(gameState.lastPuckPosition - gameState.puckPosition) > 1 &&
+ gameState.running
+ ) {
+ gameState.lastPuckMove = gameState.levelTime;
+ }
+ gameState.lastPuckPosition = gameState.puckPosition;
}
export function baseCombo(gameState: GameState) {
- const mineFieldBonus =
- gameState.perks.minefield &&
- gameState.bricks.filter((b) => b === "black").length *
- gameState.perks.minefield;
- return (
- 1 +
- gameState.perks.base_combo * 3 +
- mineFieldBonus
- );
+ const mineFieldBonus =
+ gameState.perks.minefield &&
+ gameState.bricks.filter((b) => b === "black").length *
+ gameState.perks.minefield;
+ return 1 + gameState.perks.base_combo * 3 + mineFieldBonus;
}
export function resetCombo(
- gameState: GameState,
- x: number | undefined,
- y: number | undefined,
+ gameState: GameState,
+ x: number | undefined,
+ y: number | undefined,
) {
- const prev = gameState.combo;
- gameState.combo = baseCombo(gameState);
+ const prev = gameState.combo;
+ gameState.combo = baseCombo(gameState);
- if (prev > gameState.combo && gameState.perks.soft_reset) {
- gameState.combo += Math.floor(
- (prev - gameState.combo) * comboKeepingRate(gameState.perks.soft_reset),
- );
+ if (prev > gameState.combo && gameState.perks.soft_reset) {
+ gameState.combo += Math.floor(
+ (prev - gameState.combo) * comboKeepingRate(gameState.perks.soft_reset),
+ );
+ }
+ const lost = Math.max(0, prev - gameState.combo);
+ if (lost) {
+ for (let i = 0; i < lost && i < 8; i++) {
+ setTimeout(
+ () => schedulGameSound(gameState, "comboDecrease", x, 1),
+ i * 100,
+ );
}
- const lost = Math.max(0, prev - gameState.combo);
- if (lost) {
- for (let i = 0; i < lost && i < 8; i++) {
- setTimeout(
- () => schedulGameSound(gameState, "comboDecrease", x, 1),
- i * 100,
- );
- }
- if (typeof x !== "undefined" && typeof y !== "undefined") {
- makeText(
- gameState,
- x,
- y,
- "#FF0000",
- "-" + lost,
- 20,
- 500 + clamp(lost, 0, 500),
- );
- }
+ if (typeof x !== "undefined" && typeof y !== "undefined") {
+ makeText(
+ gameState,
+ x,
+ y,
+ "#FF0000",
+ "-" + lost,
+ 20,
+ 500 + clamp(lost, 0, 500),
+ );
}
- return lost;
+ }
+ return lost;
}
export function increaseCombo(
- gameState: GameState,
- by: number,
- x: number,
- y: number,
+ gameState: GameState,
+ by: number,
+ x: number,
+ y: number,
) {
- if (by <= 0) {
- return;
- }
- gameState.combo += by;
- if (
- isOptionOn("comboIncreaseTexts") &&
- typeof x !== "undefined" &&
- typeof y !== "undefined"
- ) {
- makeText(gameState, x, y, "#ffd300", "+" + by, 25, 400 + by);
- }
+ if (by <= 0) {
+ return;
+ }
+ gameState.combo += by;
+ if (
+ isOptionOn("comboIncreaseTexts") &&
+ typeof x !== "undefined" &&
+ typeof y !== "undefined"
+ ) {
+ makeText(gameState, x, y, "#ffd300", "+" + by, 25, 400 + by);
+ }
}
export function decreaseCombo(
- gameState: GameState,
- by: number,
- x: number,
- y: number,
+ gameState: GameState,
+ by: number,
+ x: number,
+ y: number,
) {
- const prev = gameState.combo;
- gameState.combo = Math.max(baseCombo(gameState), gameState.combo - by);
- const lost = Math.max(0, prev - gameState.combo);
+ const prev = gameState.combo;
+ gameState.combo = Math.max(baseCombo(gameState), gameState.combo - by);
+ const lost = Math.max(0, prev - gameState.combo);
- if (lost) {
- schedulGameSound(gameState, "comboDecrease", x, 1);
- if (typeof x !== "undefined" && typeof y !== "undefined") {
- makeText(gameState, x, y, "#FF0000", "-" + lost, 20, 400 + lost);
- }
+ if (lost) {
+ schedulGameSound(gameState, "comboDecrease", x, 1);
+ if (typeof x !== "undefined" && typeof y !== "undefined") {
+ makeText(gameState, x, y, "#FF0000", "-" + lost, 20, 400 + lost);
}
+ }
}
export function spawnExplosion(
- gameState: GameState,
- count: number,
- x: number,
- y: number,
- color: string,
+ gameState: GameState,
+ count: number,
+ x: number,
+ y: number,
+ color: string,
) {
- if (!!isOptionOn("basic")) return;
+ if (!!isOptionOn("basic")) return;
- if (liveCount(gameState.particles) > getCurrentMaxParticles()) {
- // Avoid freezing when lots of explosion happen at once
- count = 1;
- }
- for (let i = 0; i < count; i++) {
- makeParticle(
- gameState,
+ if (liveCount(gameState.particles) > getCurrentMaxParticles()) {
+ // Avoid freezing when lots of explosion happen at once
+ count = 1;
+ }
+ 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,
- );
- }
+ 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,
+ );
+ }
}
export function spawnImplosion(
- gameState: GameState,
- count: number,
- x: number,
- y: number,
- color: string,
+ gameState: GameState,
+ count: number,
+ x: number,
+ y: number,
+ color: string,
) {
- if (!!isOptionOn("basic")) return;
+ if (!!isOptionOn("basic")) return;
- if (liveCount(gameState.particles) > getCurrentMaxParticles()) {
- // Avoid freezing when lots of explosion happen at once
- count = 1;
- }
- for (let i = 0; i < count; i++) {
- const dx = ((Math.random() - 0.5) * gameState.brickWidth) / 2;
- const dy = ((Math.random() - 0.5) * gameState.brickWidth) / 2;
- makeParticle(gameState, x - dx * 10, y - dy * 10, dx, dy, color, false);
- }
+ if (liveCount(gameState.particles) > getCurrentMaxParticles()) {
+ // Avoid freezing when lots of explosion happen at once
+ count = 1;
+ }
+ for (let i = 0; i < count; i++) {
+ const dx = ((Math.random() - 0.5) * gameState.brickWidth) / 2;
+ const dy = ((Math.random() - 0.5) * gameState.brickWidth) / 2;
+ makeParticle(gameState, x - dx * 10, y - dy * 10, dx, dy, color, false);
+ }
}
export function explosionAt(
- gameState: GameState,
- index: number,
- x: number,
- y: number,
- ball: Ball,
- extraSize: number = 0,
+ gameState: GameState,
+ index: number,
+ x: number,
+ y: number,
+ ball: Ball,
+ extraSize: number = 0,
) {
- const size =
- 1 +
- gameState.perks.bigger_explosions +
- Math.max(0, gameState.perks.implosions - 1) +
- extraSize;
- schedulGameSound(gameState, "explode", ball.x, 1);
- if (index !== -1) {
- const col = index % gameState.gridSize;
- const row = Math.floor(index / gameState.gridSize);
- // Break bricks around
- for (let dx = -size; dx <= size; dx++) {
- for (let dy = -size; dy <= size; dy++) {
- const i = getRowColIndex(gameState, row + dy, col + dx);
- if (gameState.bricks[i] && i !== -1) {
- // Study bricks resist explosions too
- gameState.brickHP[i]--;
- if (gameState.brickHP[i] <= 0) {
- explodeBrick(gameState, i, ball, true);
- }
- }
- }
+ const size =
+ 1 +
+ gameState.perks.bigger_explosions +
+ Math.max(0, gameState.perks.implosions - 1) +
+ extraSize;
+ schedulGameSound(gameState, "explode", ball.x, 1);
+ if (index !== -1) {
+ const col = index % gameState.gridSize;
+ const row = Math.floor(index / gameState.gridSize);
+ // Break bricks around
+ for (let dx = -size; dx <= size; dx++) {
+ for (let dy = -size; dy <= size; dy++) {
+ const i = getRowColIndex(gameState, row + dy, col + dx);
+ if (gameState.bricks[i] && i !== -1) {
+ // Study bricks resist explosions too
+ gameState.brickHP[i]--;
+ if (gameState.brickHP[i] <= 0) {
+ explodeBrick(gameState, i, ball, true);
+ }
}
+ }
}
+ }
- const factor = gameState.perks.implosions ? -1 : 1;
- // Blow nearby coins
- forEachLiveOne(gameState.coins, (c) => {
- const dx = c.x - x;
- const dy = c.y - y;
- const d2 = Math.max(gameState.brickWidth, Math.abs(dx) + Math.abs(dy));
- c.vx += (((dx / d2) * 10 * size) / c.weight) * factor;
- c.vy += (((dy / d2) * 10 * size) / c.weight) * factor;
- });
- gameState.lastExplosion = gameState.levelTime;
+ const factor = gameState.perks.implosions ? -1 : 1;
+ // Blow nearby coins
+ forEachLiveOne(gameState.coins, (c) => {
+ const dx = c.x - x;
+ const dy = c.y - y;
+ const d2 = Math.max(gameState.brickWidth, Math.abs(dx) + Math.abs(dy));
+ c.vx += (((dx / d2) * 10 * size) / c.weight) * factor;
+ c.vy += (((dy / d2) * 10 * size) / c.weight) * factor;
+ });
+ gameState.lastExplosion = gameState.levelTime;
- if (gameState.perks.implosions) {
- spawnImplosion(gameState, 7 * size, x, y, "#FFFFFF");
- } else {
- spawnExplosion(gameState, 7 * size, x, y, "#FFFFFF");
- }
+ if (gameState.perks.implosions) {
+ spawnImplosion(gameState, 7 * size, x, y, "#FFFFFF");
+ } else {
+ spawnExplosion(gameState, 7 * size, x, y, "#FFFFFF");
+ }
- gameState.runStatistics.bricks_broken++;
+ gameState.runStatistics.bricks_broken++;
- if (gameState.perks.zen) {
- resetCombo(gameState, x, y);
- }
+ if (gameState.perks.zen) {
+ resetCombo(gameState, x, y);
+ }
}
export function explodeBrick(
- gameState: GameState,
- index: number,
- ball: Ball,
- isExplosion: boolean,
+ gameState: GameState,
+ index: number,
+ ball: Ball,
+ isExplosion: boolean,
) {
- const color = gameState.bricks[index];
- if (!color) return;
+ const color = gameState.bricks[index];
+ if (!color) return;
- const wasPickyEaterPossible =
- gameState.perks.picky_eater && isPickyEatingPossible(gameState);
- const redRowReach = reachRedRowIndex(gameState);
+ const wasPickyEaterPossible =
+ gameState.perks.picky_eater && isPickyEatingPossible(gameState);
+ const redRowReach = reachRedRowIndex(gameState);
- gameState.lastBrickBroken = gameState.levelTime;
+ gameState.lastBrickBroken = gameState.levelTime;
- if (color === "black") {
- const x = brickCenterX(gameState, index),
- y = brickCenterY(gameState, index);
+ if (color === "black") {
+ const x = brickCenterX(gameState, index),
+ y = brickCenterY(gameState, index);
- setBrick(gameState, index, "");
- explosionAt(gameState, index, x, y, ball, 0);
- if (gameState.perks.minefield) {
- decreaseCombo(gameState, gameState.perks.minefield, x, y);
- }
- } else if (color) {
- // Even if it bounces we don't want to count that as a miss
+ setBrick(gameState, index, "");
+ explosionAt(gameState, index, x, y, ball, 0);
+ if (gameState.perks.minefield) {
+ decreaseCombo(gameState, gameState.perks.minefield, x, y);
+ }
+ } else if (color) {
+ // Even if it bounces we don't want to count that as a miss
- // Flashing is take care of by the tick loop
- const x = brickCenterX(gameState, index),
- y = brickCenterY(gameState, index);
+ // Flashing is take care of by the tick loop
+ const x = brickCenterX(gameState, index),
+ y = brickCenterY(gameState, index);
- setBrick(gameState, index, "");
+ setBrick(gameState, index, "");
- let coinsToSpawn = coinsBoostedCombo(gameState)
+ let coinsToSpawn = coinsBoostedCombo(gameState);
- gameState.levelSpawnedCoins += coinsToSpawn;
- gameState.runStatistics.coins_spawned += coinsToSpawn;
- gameState.runStatistics.bricks_broken++;
+ gameState.levelSpawnedCoins += coinsToSpawn;
+ gameState.runStatistics.coins_spawned += coinsToSpawn;
+ gameState.runStatistics.bricks_broken++;
- const maxCoins = getCurrentMaxCoins();
- const spawnableCoins =
- liveCount(gameState.coins) > getCurrentMaxCoins()
- ? 1
- : Math.floor((maxCoins - liveCount(gameState.coins)) / 2);
+ const maxCoins = getCurrentMaxCoins();
+ const spawnableCoins =
+ liveCount(gameState.coins) > getCurrentMaxCoins()
+ ? 1
+ : Math.floor((maxCoins - liveCount(gameState.coins)) / 2);
- const pointsPerCoin = Math.max(1, Math.ceil(coinsToSpawn / spawnableCoins));
+ const pointsPerCoin = Math.max(1, Math.ceil(coinsToSpawn / spawnableCoins));
- while (coinsToSpawn > 0) {
- const points = Math.min(pointsPerCoin, coinsToSpawn);
- if (points < 0 || isNaN(points)) {
- console.error({points});
- debugger;
- }
+ while (coinsToSpawn > 0) {
+ const points = Math.min(pointsPerCoin, coinsToSpawn);
+ if (points < 0 || isNaN(points)) {
+ console.error({ points });
+ debugger;
+ }
- coinsToSpawn -= points;
+ coinsToSpawn -= points;
- const cx =
- x +
- (Math.random() - 0.5) * (gameState.brickWidth - gameState.coinSize),
- cy =
- y +
- (Math.random() - 0.5) * (gameState.brickWidth - gameState.coinSize);
+ const cx =
+ x +
+ (Math.random() - 0.5) * (gameState.brickWidth - gameState.coinSize),
+ cy =
+ y +
+ (Math.random() - 0.5) * (gameState.brickWidth - gameState.coinSize);
- makeCoin(
- gameState,
- cx,
- cy,
- ball.previousVX * (0.5 + Math.random()),
- ball.previousVY * (0.5 + Math.random()),
- color,
- points,
- );
- }
+ makeCoin(
+ gameState,
+ cx,
+ cy,
+ ball.previousVX * (0.5 + Math.random()),
+ ball.previousVY * (0.5 + Math.random()),
+ color,
+ points,
+ );
+ }
- increaseCombo(
+ increaseCombo(
+ gameState,
+ gameState.perks.streak_shots +
+ gameState.perks.compound_interest +
+ gameState.perks.left_is_lava +
+ gameState.perks.right_is_lava +
+ gameState.perks.top_is_lava +
+ gameState.perks.picky_eater +
+ gameState.perks.asceticism * 3 +
+ gameState.perks.zen +
+ gameState.perks.passive_income +
+ gameState.perks.addiction,
+ ball.x,
+ ball.y,
+ );
+
+ if (Math.abs(ball.y - y) < Math.abs(ball.x - x)) {
+ if (gameState.perks.side_kick) {
+ if (ball.previousVX > 0) {
+ increaseCombo(gameState, gameState.perks.side_kick, ball.x, ball.y);
+ } else {
+ decreaseCombo(
gameState,
- gameState.perks.streak_shots +
- gameState.perks.compound_interest +
- gameState.perks.left_is_lava +
- gameState.perks.right_is_lava +
- gameState.perks.top_is_lava +
- gameState.perks.picky_eater +
- gameState.perks.asceticism * 3 +
- gameState.perks.zen +
- gameState.perks.passive_income +
- gameState.perks.addiction,
+ gameState.perks.side_kick * 2,
ball.x,
ball.y,
- );
-
- if (Math.abs(ball.y - y) < Math.abs(ball.x - x)) {
- if (gameState.perks.side_kick) {
- if (ball.previousVX > 0) {
- increaseCombo(gameState, gameState.perks.side_kick, ball.x, ball.y);
- } else {
- decreaseCombo(
- gameState,
- gameState.perks.side_kick * 2,
- ball.x,
- ball.y,
- );
- }
- }
- if (gameState.perks.side_flip) {
- if (ball.previousVX < 0) {
- increaseCombo(gameState, gameState.perks.side_flip, ball.x, ball.y);
- } else {
- decreaseCombo(
- gameState,
- gameState.perks.side_flip * 2,
- ball.x,
- ball.y,
- );
- }
- }
+ );
}
-
- if (redRowReach !== -1) {
- if (Math.floor(index / gameState.level.size) === redRowReach) {
- resetCombo(gameState, x, y);
- } else {
- for (let x = 0; x < gameState.level.size; x++) {
- if (gameState.bricks[redRowReach * gameState.level.size + x])
- gameState.combo++;
- }
- }
+ }
+ if (gameState.perks.side_flip) {
+ if (ball.previousVX < 0) {
+ increaseCombo(gameState, gameState.perks.side_flip, ball.x, ball.y);
+ } else {
+ decreaseCombo(
+ gameState,
+ gameState.perks.side_flip * 2,
+ ball.x,
+ ball.y,
+ );
}
-
- if (isMovingWhilePassiveIncome(gameState)) {
- resetCombo(gameState, x, y);
- }
-
- if (!isExplosion) {
- // color change
- if (
- (gameState.perks.picky_eater || gameState.perks.pierce_color) &&
- color !== gameState.ballsColor &&
- color
- ) {
- if (wasPickyEaterPossible) {
- resetCombo(gameState, ball.x, ball.y);
- }
- schedulGameSound(gameState, "colorChange", ball.x, 0.8);
- // gameState.lastExplosion = gameState.levelTime;
- gameState.ballsColor = color;
- if (!isOptionOn("basic")) {
- gameState.balls.forEach((ball) => {
- spawnExplosion(gameState, 7, ball.previousX, ball.previousY, color);
- });
- }
- } else {
- schedulGameSound(gameState, "comboIncreaseMaybe", ball.x, 1);
- }
- }
- // makeLight(gameState, x, y, color, gameState.brickWidth, 40);
-
- spawnExplosion(gameState, 5 + Math.min(gameState.combo, 30), x, y, color);
+ }
}
- if (
- gameState.perks.respawn &&
- color !== "black" &&
- !gameState.bricks[index]
- ) {
- if (Math.random() < comboKeepingRate(gameState.perks.respawn)) {
- append(gameState.respawns, (b) => {
- b.color = color;
- b.index = index;
- b.time = gameState.levelTime + (3 * 1000) / gameState.perks.respawn;
- });
+ if (redRowReach !== -1) {
+ if (Math.floor(index / gameState.level.size) === redRowReach) {
+ resetCombo(gameState, x, y);
+ } else {
+ for (let x = 0; x < gameState.level.size; x++) {
+ if (gameState.bricks[redRowReach * gameState.level.size + x])
+ gameState.combo++;
}
+ }
}
+
+ if (isMovingWhilePassiveIncome(gameState)) {
+ resetCombo(gameState, x, y);
+ }
+
+ if (!isExplosion) {
+ // color change
+ if (
+ (gameState.perks.picky_eater || gameState.perks.pierce_color) &&
+ color !== gameState.ballsColor &&
+ color
+ ) {
+ if (wasPickyEaterPossible) {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+ schedulGameSound(gameState, "colorChange", ball.x, 0.8);
+ // gameState.lastExplosion = gameState.levelTime;
+ gameState.ballsColor = color;
+ if (!isOptionOn("basic")) {
+ gameState.balls.forEach((ball) => {
+ spawnExplosion(gameState, 7, ball.previousX, ball.previousY, color);
+ });
+ }
+ } else {
+ schedulGameSound(gameState, "comboIncreaseMaybe", ball.x, 1);
+ }
+ }
+ // makeLight(gameState, x, y, color, gameState.brickWidth, 40);
+
+ spawnExplosion(gameState, 5 + Math.min(gameState.combo, 30), x, y, color);
+ }
+
+ if (
+ gameState.perks.respawn &&
+ color !== "black" &&
+ !gameState.bricks[index]
+ ) {
+ if (Math.random() < comboKeepingRate(gameState.perks.respawn)) {
+ append(gameState.respawns, (b) => {
+ b.color = color;
+ b.index = index;
+ b.time = gameState.levelTime + (3 * 1000) / gameState.perks.respawn;
+ });
+ }
+ }
}
export function dontOfferTooSoon(gameState: GameState, id: PerkId) {
- gameState.lastOffered[id] = Math.round(Date.now() / 1000);
+ gameState.lastOffered[id] = Math.round(Date.now() / 1000);
}
export function pickRandomUpgrades(gameState: GameState, count: number) {
- let list = getPossibleUpgrades(gameState)
- .map((u) => ({
- ...u,
- score: Math.random() + (gameState.lastOffered[u.id] || 0),
- }))
- .sort((a, b) => a.score - b.score)
- .filter((u) => gameState.perks[u.id] < u.max + gameState.perks.limitless)
- .slice(0, count)
- .sort((a, b) => (a.id > b.id ? 1 : -1));
+ let list = getPossibleUpgrades(gameState)
+ .map((u) => ({
+ ...u,
+ score: Math.random() + (gameState.lastOffered[u.id] || 0),
+ }))
+ .sort((a, b) => a.score - b.score)
+ .filter((u) => gameState.perks[u.id] < u.max + gameState.perks.limitless)
+ .slice(0, count)
+ .sort((a, b) => (a.id > b.id ? 1 : -1));
- list.forEach((u) => {
- dontOfferTooSoon(gameState, u.id);
- });
+ list.forEach((u) => {
+ dontOfferTooSoon(gameState, u.id);
+ });
- return list.map((u) => ({
- text:
- u.name +
- (gameState.perks[u.id]
- ? t("level_up.upgrade_perk_to_level", {
- level: gameState.perks[u.id] + 1,
- })
- : ""),
- icon: icons["icon:" + u.id],
- value: u.id as PerkId,
- help: u.help(gameState.perks[u.id] + 1),
- }));
+ return list.map((u) => ({
+ text:
+ u.name +
+ (gameState.perks[u.id]
+ ? t("level_up.upgrade_perk_to_level", {
+ level: gameState.perks[u.id] + 1,
+ })
+ : ""),
+ icon: icons["icon:" + u.id],
+ value: u.id as PerkId,
+ help: u.help(gameState.perks[u.id] + 1),
+ }));
}
export function schedulGameSound(
- gameState: GameState,
- sound: keyof GameState["aboutToPlaySound"],
- x: number | void,
- vol: number,
+ gameState: GameState,
+ sound: keyof GameState["aboutToPlaySound"],
+ x: number | void,
+ vol: number,
) {
- if (!vol) return;
- if (!isOptionOn("sound")) return;
+ if (!vol) return;
+ if (!isOptionOn("sound")) return;
- x ??= gameState.offsetX + gameState.gameZoneWidth / 2;
- const ex = gameState.aboutToPlaySound[sound] as { vol: number; x: number };
+ x ??= gameState.offsetX + gameState.gameZoneWidth / 2;
+ const ex = gameState.aboutToPlaySound[sound] as { vol: number; x: number };
- ex.x = (x * vol + ex.x * ex.vol) / (vol + ex.vol);
- ex.vol += vol;
+ ex.x = (x * vol + ex.x * ex.vol) / (vol + ex.vol);
+ ex.vol += vol;
}
export function addToScore(gameState: GameState, coin: Coin) {
- gameState.score += coin.points;
- gameState.lastScoreIncrease = gameState.levelTime;
- addToTotalScore(gameState, coin.points);
- if (gameState.score > gameState.highScore && !gameState.creative) {
- gameState.highScore = gameState.score;
- try {
- localStorage.setItem("breakout-3-hs-short", gameState.score.toString());
- } catch (e) {
+ gameState.score += coin.points;
+ gameState.lastScoreIncrease = gameState.levelTime;
+ addToTotalScore(gameState, coin.points);
+ if (gameState.score > gameState.highScore && !gameState.creative) {
+ gameState.highScore = gameState.score;
+ try {
+ localStorage.setItem("breakout-3-hs-short", gameState.score.toString());
+ } catch (e) {}
+ }
+ if (!isOptionOn("basic")) {
+ makeParticle(
+ gameState,
+ coin.previousX,
+ coin.previousY,
+ (gameState.canvasWidth - coin.x) / 100,
+ -coin.y / 100,
+ getCoinRenderColor(gameState, coin),
- }
- }
- if (!isOptionOn("basic")) {
- makeParticle(
- gameState,
- coin.previousX,
- coin.previousY,
- (gameState.canvasWidth - coin.x) / 100,
- -coin.y / 100,
- getCoinRenderColor(gameState, coin),
+ true,
+ gameState.coinSize / 2,
+ 100 + Math.random() * 50,
+ );
+ }
- true,
- gameState.coinSize / 2,
- 100 + Math.random() * 50,
- );
- }
-
- schedulGameSound(gameState, "coinCatch", coin.x, 1);
- gameState.runStatistics.score += coin.points;
- if (gameState.perks.asceticism) {
- decreaseCombo(
- gameState,
- gameState.perks.asceticism * 3 * coin.points,
- coin.x,
- coin.y,
- );
- }
+ schedulGameSound(gameState, "coinCatch", coin.x, 1);
+ gameState.runStatistics.score += coin.points;
+ if (gameState.perks.asceticism) {
+ decreaseCombo(
+ gameState,
+ gameState.perks.asceticism * 3 * coin.points,
+ coin.x,
+ coin.y,
+ );
+ }
}
export async function setLevel(gameState: GameState, l: number) {
- // Here to alleviate double upgrades issues
- if (gameState.upgradesOfferedFor >= l) {
- debugger;
- return console.warn("Extra upgrade request ignored ");
- }
- gameState.upgradesOfferedFor = l;
- pause(false);
- stopRecording();
+ // Here to alleviate double upgrades issues
+ if (gameState.upgradesOfferedFor >= l) {
+ debugger;
+ return console.warn("Extra upgrade request ignored ");
+ }
+ gameState.upgradesOfferedFor = l;
+ pause(false);
+ stopRecording();
- if (l > 0) {
- await openUpgradesPicker(gameState);
- }
- gameState.currentLevel = l;
+ if (l > 0) {
+ await openUpgradesPicker(gameState);
+ }
+ gameState.currentLevel = l;
- gameState.level = gameState.runLevels[l % gameState.runLevels.length];
+ gameState.level = gameState.runLevels[l % gameState.runLevels.length];
- gameState.levelTime = 0;
- gameState.winAt = 0;
- gameState.levelWallBounces = 0;
- gameState.lastPuckMove = 0;
- gameState.autoCleanUses = 0;
- gameState.lastTickDown = gameState.levelTime;
- gameState.levelStartScore = gameState.score;
- gameState.levelSpawnedCoins = 0;
- gameState.levelLostCoins = 0;
- gameState.levelMisses = 0;
- gameState.lastBrickBroken = 0;
- gameState.runStatistics.levelsPlayed++;
+ gameState.levelTime = 0;
+ gameState.winAt = 0;
+ gameState.levelWallBounces = 0;
+ gameState.lastPuckMove = 0;
+ gameState.autoCleanUses = 0;
+ gameState.lastTickDown = gameState.levelTime;
+ gameState.levelStartScore = gameState.score;
+ gameState.levelSpawnedCoins = 0;
+ gameState.levelLostCoins = 0;
+ gameState.levelMisses = 0;
+ gameState.lastBrickBroken = 0;
+ gameState.runStatistics.levelsPlayed++;
- // Reset combo silently
- const finalCombo = gameState.combo;
- gameState.combo = baseCombo(gameState);
- if (gameState.perks.shunt) {
- gameState.combo += Math.round(
- Math.max(
- 0,
- (finalCombo - gameState.combo) *
- comboKeepingRate(gameState.perks.shunt),
- ),
- );
- }
+ // Reset combo silently
+ const finalCombo = gameState.combo;
+ gameState.combo = baseCombo(gameState);
+ if (gameState.perks.shunt) {
+ gameState.combo += Math.round(
+ Math.max(
+ 0,
+ (finalCombo - gameState.combo) *
+ comboKeepingRate(gameState.perks.shunt),
+ ),
+ );
+ }
- gameState.combo += gameState.perks.hot_start * 30;
+ gameState.combo += gameState.perks.hot_start * 30;
- const lvl = currentLevelInfo(gameState);
- if (lvl.size !== gameState.gridSize) {
- gameState.gridSize = lvl.size;
- fitSize(gameState);
- }
- gameState.levelLostCoins += empty(gameState.coins);
- empty(gameState.particles);
- empty(gameState.lights);
- empty(gameState.texts);
- empty(gameState.respawns);
- gameState.bricks = [];
+ const lvl = currentLevelInfo(gameState);
+ if (lvl.size !== gameState.gridSize) {
+ gameState.gridSize = lvl.size;
+ fitSize(gameState);
+ }
+ gameState.levelLostCoins += empty(gameState.coins);
+ empty(gameState.particles);
+ empty(gameState.lights);
+ empty(gameState.texts);
+ empty(gameState.respawns);
+ gameState.bricks = [];
- for (let i = 0; i < lvl.size * lvl.size; i++) {
- setBrick(gameState, i, lvl.bricks[i]);
- }
+ for (let i = 0; i < lvl.size * lvl.size; i++) {
+ setBrick(gameState, i, lvl.bricks[i]);
+ }
- // Balls color will depend on most common brick color sometimes
- resetBalls(gameState);
- gameState.needsRender = true;
- // 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;
- document.body.style.setProperty("--level-background", lvl.color || "#000000");
- document
- .getElementById("themeColor")
- ?.setAttribute("content", lvl.color || "#000000");
+ // Balls color will depend on most common brick color sometimes
+ resetBalls(gameState);
+ gameState.needsRender = true;
+ // 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;
+ document.body.style.setProperty("--level-background", lvl.color || "#000000");
+ document
+ .getElementById("themeColor")
+ ?.setAttribute("content", lvl.color || "#000000");
}
function setBrick(gameState: GameState, index: number, color: string) {
- gameState.bricks[index] = color || "";
- gameState.brickHP[index] =
- (color === "black" && 1) ||
- (color && 1 + gameState.perks.sturdy_bricks) ||
- 0;
- if (gameState.perks.minefield && color === "black") {
- increaseCombo(
- gameState,
- gameState.perks.minefield,
- brickCenterX(gameState, index),
- brickCenterY(gameState, index),
- );
- }
+ gameState.bricks[index] = color || "";
+ gameState.brickHP[index] =
+ (color === "black" && 1) ||
+ (color && 1 + gameState.perks.sturdy_bricks) ||
+ 0;
+ if (gameState.perks.minefield && color === "black") {
+ increaseCombo(
+ gameState,
+ gameState.perks.minefield,
+ brickCenterX(gameState, index),
+ brickCenterY(gameState, index),
+ );
+ }
}
const rainbow = [
- "#ff2e2e",
- "#ffe02e",
- "#70ff33",
- "#33ffa7",
- "#38acff",
- "#7038ff",
- "#ff3de5",
+ "#ff2e2e",
+ "#ffe02e",
+ "#70ff33",
+ "#33ffa7",
+ "#38acff",
+ "#7038ff",
+ "#ff3de5",
];
export function rainbowColor(): colorString {
- return rainbow[Math.floor(gameState.levelTime / 50) % rainbow.length];
+ return rainbow[Math.floor(gameState.levelTime / 50) % rainbow.length];
}
export function repulse(
- gameState: GameState,
- a: Ball,
- b: BallLike,
- power: number,
- impactsBToo: boolean,
+ gameState: GameState,
+ a: Ball,
+ b: BallLike,
+ power: number,
+ impactsBToo: boolean,
) {
- const distance = distanceBetween(a, b);
- // Ensure we don't get soft locked
- const max = gameState.gameZoneWidth / 4;
- if (distance > max) return;
- // Unit vector
- const dx = (a.x - b.x) / distance;
- const dy = (a.y - b.y) / distance;
- const fact =
- (((-power * (max - distance)) / (max * 1.2) / 3) *
- Math.min(500, gameState.levelTime)) /
- 500;
- if (
- impactsBToo &&
- typeof b.vx !== "undefined" &&
- typeof b.vy !== "undefined"
- ) {
- b.vx += dx * fact;
- b.vy += dy * fact;
- }
- a.vx -= dx * fact;
- a.vy -= dy * fact;
+ const distance = distanceBetween(a, b);
+ // Ensure we don't get soft locked
+ const max = gameState.gameZoneWidth / 4;
+ if (distance > max) return;
+ // Unit vector
+ const dx = (a.x - b.x) / distance;
+ const dy = (a.y - b.y) / distance;
+ const fact =
+ (((-power * (max - distance)) / (max * 1.2) / 3) *
+ Math.min(500, gameState.levelTime)) /
+ 500;
+ if (
+ impactsBToo &&
+ typeof b.vx !== "undefined" &&
+ typeof b.vy !== "undefined"
+ ) {
+ b.vx += dx * fact;
+ b.vy += dy * fact;
+ }
+ a.vx -= dx * fact;
+ a.vy -= dy * fact;
- const speed = 10;
- const rand = 2;
+ const speed = 10;
+ const rand = 2;
+ makeParticle(
+ gameState,
+ a.x,
+ a.y,
+ -dx * speed + a.vx + (Math.random() - 0.5) * rand,
+ -dy * speed + a.vy + (Math.random() - 0.5) * rand,
+ rainbowColor(),
+ true,
+ gameState.coinSize / 2,
+ 100,
+ );
+ if (
+ impactsBToo &&
+ typeof b.vx !== "undefined" &&
+ typeof b.vy !== "undefined"
+ ) {
makeParticle(
- gameState,
- a.x,
- a.y,
- -dx * speed + a.vx + (Math.random() - 0.5) * rand,
- -dy * speed + a.vy + (Math.random() - 0.5) * rand,
- rainbowColor(),
- true,
- gameState.coinSize / 2,
- 100,
+ gameState,
+ b.x,
+ b.y,
+ dx * speed + b.vx + (Math.random() - 0.5) * rand,
+ dy * speed + b.vy + (Math.random() - 0.5) * rand,
+ rainbowColor(),
+ true,
+ gameState.coinSize / 2,
+ 100,
);
- if (
- impactsBToo &&
- typeof b.vx !== "undefined" &&
- typeof b.vy !== "undefined"
- ) {
- makeParticle(
- gameState,
- b.x,
- b.y,
- dx * speed + b.vx + (Math.random() - 0.5) * rand,
- dy * speed + b.vy + (Math.random() - 0.5) * rand,
- rainbowColor(),
- true,
- gameState.coinSize / 2,
- 100,
- );
- }
+ }
}
export function attract(gameState: GameState, a: Ball, b: Ball, power: number) {
- const distance = distanceBetween(a, b);
- // Ensure we don't get soft locked
- const min = (gameState.gameZoneWidth * 3) / 4;
- if (distance < min) return;
- // Unit vector
- const dx = (a.x - b.x) / distance;
- const dy = (a.y - b.y) / distance;
+ const distance = distanceBetween(a, b);
+ // Ensure we don't get soft locked
+ const min = (gameState.gameZoneWidth * 3) / 4;
+ if (distance < min) return;
+ // Unit vector
+ const dx = (a.x - b.x) / distance;
+ const dy = (a.y - b.y) / distance;
- const fact =
- (((power * (distance - min)) / min) * Math.min(500, gameState.levelTime)) /
- 500;
- b.vx += dx * fact;
- b.vy += dy * fact;
- a.vx -= dx * fact;
- a.vy -= dy * fact;
+ const fact =
+ (((power * (distance - min)) / min) * Math.min(500, gameState.levelTime)) /
+ 500;
+ b.vx += dx * fact;
+ b.vy += dy * fact;
+ a.vx -= dx * fact;
+ a.vy -= dy * fact;
- const speed = 10;
- const rand = 2;
+ const speed = 10;
+ const rand = 2;
- makeParticle(
- gameState,
- a.x,
- a.y,
- dx * speed + a.vx + (Math.random() - 0.5) * rand,
- dy * speed + a.vy + (Math.random() - 0.5) * rand,
- rainbowColor(),
- true,
- gameState.coinSize / 2,
- 100,
- );
- makeParticle(
- gameState,
- b.x,
- b.y,
- -dx * speed + b.vx + (Math.random() - 0.5) * rand,
- -dy * speed + b.vy + (Math.random() - 0.5) * rand,
- rainbowColor(),
- true,
- gameState.coinSize / 2,
- 100,
- );
+ makeParticle(
+ gameState,
+ a.x,
+ a.y,
+ dx * speed + a.vx + (Math.random() - 0.5) * rand,
+ dy * speed + a.vy + (Math.random() - 0.5) * rand,
+ rainbowColor(),
+ true,
+ gameState.coinSize / 2,
+ 100,
+ );
+ makeParticle(
+ gameState,
+ b.x,
+ b.y,
+ -dx * speed + b.vx + (Math.random() - 0.5) * rand,
+ -dy * speed + b.vy + (Math.random() - 0.5) * rand,
+ rainbowColor(),
+ true,
+ gameState.coinSize / 2,
+ 100,
+ );
}
export function coinBrickHitCheck(gameState: GameState, coin: Coin) {
- // Make ball/coin bonce, and return bricks that were hit
- const radius = coin.size / 2;
- const {x, y, previousX, previousY} = coin;
+ // Make ball/coin bonce, and return bricks that were hit
+ const radius = coin.size / 2;
+ const { x, y, previousX, previousY } = coin;
- const vhit = hitsSomething(previousX, y, radius);
- const hhit = hitsSomething(x, previousY, radius);
- const chit =
- (typeof vhit == "undefined" &&
- typeof hhit == "undefined" &&
- hitsSomething(x, y, radius)) ||
- undefined;
+ const vhit = hitsSomething(previousX, y, radius);
+ const hhit = hitsSomething(x, previousY, radius);
+ const chit =
+ (typeof vhit == "undefined" &&
+ typeof hhit == "undefined" &&
+ hitsSomething(x, y, radius)) ||
+ undefined;
- if (typeof (vhit ?? hhit ?? chit) !== "undefined") {
- if (shouldCoinsStick(gameState)) {
- if(coin.collidedLastFrame) {
- coin.x = previousX
- coin.y = previousY
- }
- coin.vx = 0
- coin.vy = 0
- } else if (gameState.perks.ghost_coins) {
- // slow down
- coin.vy *= 1 - 0.2 / gameState.perks.ghost_coins;
- coin.vx *= 1 - 0.2 / gameState.perks.ghost_coins;
- } else {
- if (typeof vhit !== "undefined" || typeof chit !== "undefined") {
- coin.y = coin.previousY;
- coin.vy *= -1;
+ if (typeof (vhit ?? hhit ?? chit) !== "undefined") {
+ if (shouldCoinsStick(gameState)) {
+ if (coin.collidedLastFrame) {
+ coin.x = previousX;
+ coin.y = previousY;
+ }
+ coin.vx = 0;
+ coin.vy = 0;
+ } else if (gameState.perks.ghost_coins) {
+ // slow down
+ coin.vy *= 1 - 0.2 / gameState.perks.ghost_coins;
+ coin.vx *= 1 - 0.2 / gameState.perks.ghost_coins;
+ } else {
+ if (typeof vhit !== "undefined" || typeof chit !== "undefined") {
+ coin.y = coin.previousY;
+ coin.vy *= -1;
- // Roll on corners
- const leftHit = gameState.bricks[brickIndex(x - radius, y + radius)];
- const rightHit = gameState.bricks[brickIndex(x + radius, y + radius)];
+ // Roll on corners
+ const leftHit = gameState.bricks[brickIndex(x - radius, y + radius)];
+ const rightHit = gameState.bricks[brickIndex(x + radius, y + radius)];
- if (leftHit && !rightHit) {
- coin.vx += 1;
- coin.sa -= 1;
- }
- if (!leftHit && rightHit) {
- coin.vx -= 1;
- coin.sa += 1;
- }
- }
- if (typeof hhit !== "undefined" || typeof chit !== "undefined") {
- coin.x = coin.previousX;
- coin.vx *= -1;
- }
+ if (leftHit && !rightHit) {
+ coin.vx += 1;
+ coin.sa -= 1;
}
+ if (!leftHit && rightHit) {
+ coin.vx -= 1;
+ coin.sa += 1;
+ }
+ }
+ if (typeof hhit !== "undefined" || typeof chit !== "undefined") {
+ coin.x = coin.previousX;
+ coin.vx *= -1;
+ }
}
- return vhit ?? hhit ?? chit;
+ }
+ return vhit ?? hhit ?? chit;
}
export function bordersHitCheck(
- gameState: GameState,
- coin: Coin | Ball,
- radius: number,
- delta: number,
+ gameState: GameState,
+ coin: Coin | Ball,
+ radius: number,
+ delta: number,
) {
- if (coin.destroyed) return;
- coin.previousX = coin.x;
- coin.previousY = coin.y;
- coin.x += coin.vx * delta;
- coin.y += coin.vy * delta;
+ if (coin.destroyed) return;
+ coin.previousX = coin.x;
+ coin.previousY = coin.y;
+ coin.x += coin.vx * delta;
+ coin.y += coin.vy * delta;
- if (gameState.perks.wind) {
- coin.vx +=
- ((gameState.puckPosition -
- (gameState.offsetX + gameState.gameZoneWidth / 2)) /
- gameState.gameZoneWidth) *
- gameState.perks.wind *
- 0.5;
- }
+ 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;
+ let vhit = 0,
+ hhit = 0;
- if (coin.x < gameState.offsetXRoundedDown + radius && gameState.perks.left_is_lava < 2) {
- coin.x =
- gameState.offsetXRoundedDown +
- radius +
- (gameState.offsetXRoundedDown + radius - coin.x);
- coin.vx *= -1;
- hhit = 1;
- }
- if (coin.y < radius && gameState.perks.top_is_lava < 2) {
- coin.y = radius + (radius - coin.y);
- coin.vy *= -1;
- vhit = 1;
- }
- if (coin.x > gameState.canvasWidth - gameState.offsetXRoundedDown - radius && gameState.perks.right_is_lava < 2) {
- coin.x =
- gameState.canvasWidth -
- gameState.offsetXRoundedDown -
- radius -
- (coin.x -
- (gameState.canvasWidth - gameState.offsetXRoundedDown - radius));
- coin.vx *= -1;
- hhit = 1;
- }
+ if (
+ coin.x < gameState.offsetXRoundedDown + radius &&
+ gameState.perks.left_is_lava < 2
+ ) {
+ coin.x =
+ gameState.offsetXRoundedDown +
+ radius +
+ (gameState.offsetXRoundedDown + radius - coin.x);
+ coin.vx *= -1;
+ hhit = 1;
+ }
+ if (coin.y < radius && gameState.perks.top_is_lava < 2) {
+ coin.y = radius + (radius - coin.y);
+ coin.vy *= -1;
+ vhit = 1;
+ }
+ if (
+ coin.x > gameState.canvasWidth - gameState.offsetXRoundedDown - radius &&
+ gameState.perks.right_is_lava < 2
+ ) {
+ coin.x =
+ gameState.canvasWidth -
+ gameState.offsetXRoundedDown -
+ radius -
+ (coin.x -
+ (gameState.canvasWidth - gameState.offsetXRoundedDown - radius));
+ coin.vx *= -1;
+ hhit = 1;
+ }
-
- return hhit + vhit * 2;
+ return hhit + vhit * 2;
}
export function gameStateTick(
- gameState: GameState,
- // How many frames to compute at once, can go above 1 to compensate lag
- frames = 1,
+ gameState: GameState,
+ // How many frames to compute at once, can go above 1 to compensate lag
+ frames = 1,
) {
- // Ai movement of puck
- if (gameState.startParams.computer_controlled) computerControl(gameState);
+ // Ai movement of puck
+ if (gameState.startParams.computer_controlled) computerControl(gameState);
- gameState.runStatistics.max_combo = Math.max(
- gameState.runStatistics.max_combo,
- gameState.combo,
+ gameState.runStatistics.max_combo = Math.max(
+ gameState.runStatistics.max_combo,
+ gameState.combo,
+ );
+
+ gameState.lastCombo = gameState.combo;
+
+ if (
+ gameState.perks.addiction &&
+ gameState.lastBrickBroken &&
+ gameState.lastBrickBroken <
+ gameState.levelTime - 5000 / gameState.perks.addiction
+ ) {
+ resetCombo(
+ gameState,
+ gameState.puckPosition,
+ gameState.gameZoneHeight - gameState.puckHeight * 2,
);
+ }
- gameState.lastCombo = gameState.combo;
+ gameState.balls = gameState.balls.filter((ball) => !ball.destroyed);
+ const remainingBricks = gameState.bricks.filter(
+ (b) => b && b !== "black",
+ ).length;
- if (
- gameState.perks.addiction &&
- gameState.lastBrickBroken &&
- gameState.lastBrickBroken <
- gameState.levelTime - 5000 / gameState.perks.addiction
- ) {
- resetCombo(
- gameState,
- gameState.puckPosition,
- gameState.gameZoneHeight - gameState.puckHeight * 2,
- );
- }
+ if (!remainingBricks && gameState.lastBrickBroken) {
+ // Avoid a combo reset just because we're waiting for coins
+ gameState.lastBrickBroken = 0;
+ }
- gameState.balls = gameState.balls.filter((ball) => !ball.destroyed);
- const remainingBricks = gameState.bricks.filter(
- (b) => b && b !== "black",
- ).length;
-
- if (!remainingBricks && gameState.lastBrickBroken) {
- // Avoid a combo reset just because we're waiting for coins
- gameState.lastBrickBroken = 0;
- }
-
- if (gameState.perks.hot_start) {
- if (gameState.combo === baseCombo(gameState)) {
- // Give 1s of time between catching a coin and tick down
- gameState.lastTickDown = gameState.levelTime
- } else if (
- gameState.levelTime > gameState.lastTickDown + 1000
- ) {
- gameState.lastTickDown = gameState.levelTime;
- decreaseCombo(
- gameState,
- gameState.perks.hot_start,
- gameState.puckPosition,
- gameState.gameZoneHeight - 2 * gameState.puckHeight,
- );
- }
- }
-
-
- if (
- remainingBricks <= gameState.perks.skip_last &&
- !gameState.autoCleanUses
- ) {
- gameState.bricks.forEach((type, index) => {
- if (type) {
- explodeBrick(gameState, index, gameState.balls[0], true);
- }
- });
- gameState.autoCleanUses++;
- }
-
- const hasPendingBricks = liveCount(gameState.respawns);
-
- if (gameState.running && !remainingBricks && !hasPendingBricks) {
- if (!gameState.winAt) {
- gameState.winAt = gameState.levelTime + 5000;
- }
- } else {
- gameState.winAt = 0;
- }
-
- if (
- (gameState.running &&
- // Delayed win when coins are still flying
- gameState.winAt &&
- gameState.levelTime > gameState.winAt) ||
- // instant win condition
- (gameState.levelTime && !remainingBricks && !liveCount(gameState.coins))
- ) {
- if (gameState.startParams.computer_controlled) {
- startComputerControlledGame(gameState.startParams.stress);
- } else 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}),
- );
- }
- } else if (gameState.running || gameState.levelTime) {
- const coinRadius = Math.round(gameState.coinSize / 2);
-
- forEachLiveOne(gameState.coins, (coin, coinIndex) => {
- if (gameState.perks.coin_magnet) {
- const strength =
- (100 /
- (100 +
- Math.pow(coin.y - gameState.gameZoneHeight, 2) +
- Math.pow(coin.x - gameState.puckPosition, 2))) *
- gameState.perks.coin_magnet;
-
- const attractionX =
- frames * (gameState.puckPosition - coin.x) * strength;
-
- coin.vx += attractionX;
- coin.vy +=
- (frames * (gameState.gameZoneHeight - coin.y) * strength) / 2;
- coin.sa -= attractionX / 10;
- }
-
- if (gameState.perks.ball_attracts_coins && gameState.balls.length) {
- // Find closest ball
- let closestBall = getClosestBall(gameState, coin.x, coin.y);
- if (closestBall) {
- let dist = distance2(closestBall, coin);
-
- const minDist = gameState.brickWidth * gameState.brickWidth;
- if (
- dist > minDist &&
- dist < minDist * 4 * 4 * gameState.perks.ball_attracts_coins
- ) {
- // Slow down coins in effect radius
- const ratio =
- 1 - 0.02 * (0.5 + gameState.perks.ball_attracts_coins);
- coin.vx *= ratio;
- coin.vy *= ratio;
- coin.vy *= ratio;
- // Carry them
- const dx =
- ((closestBall.x - coin.x) / dist) *
- 50 *
- gameState.perks.ball_attracts_coins;
- const dy =
- ((closestBall.y - coin.y) / dist) *
- 50 *
- gameState.perks.ball_attracts_coins;
- coin.vx += dx;
- coin.vy += dy;
-
- if (
- !isOptionOn("basic") &&
- Math.random() * gameState.perks.ball_attracts_coins * frames > 0.9
- ) {
- makeParticle(
- gameState,
- coin.x + dx * 5,
- coin.y + dy * 5,
- dx * 2,
- dy * 2,
- rainbowColor(),
- true,
- gameState.coinSize / 2,
- 100,
- );
- }
- }
- }
- }
-
- if (gameState.perks.bricks_attract_coins) {
- goToNearestBrick(
- gameState,
- coin,
- gameState.perks.bricks_attract_coins * frames,
- 2,
- false,
- );
- }
-
- const ratio =
- 1 -
- ((gameState.perks.viscosity * 0.03 +
- 0.002 +
- (coin.y > gameState.gameZoneHeight ? 0.2 : 0)) *
- frames) /
- (1 + gameState.perks.etherealcoins);
-
- if (!gameState.perks.etherealcoins) {
- coin.vy *= ratio;
- coin.vx *= ratio;
- }
- if (coin.y > gameState.gameZoneHeight && coin.floatingTime < gameState.perks.buoy * 30) {
-
- coin.floatingTime += frames
- coin.vy -= 1.5
- }
-
- if (coin.vx > 7 * gameState.baseSpeed) coin.vx = 7 * gameState.baseSpeed;
- if (coin.vx < -7 * gameState.baseSpeed)
- coin.vx = -7 * gameState.baseSpeed;
- if (coin.vy > 7 * gameState.baseSpeed) coin.vy = 7 * gameState.baseSpeed;
- if (coin.vy < -7 * gameState.baseSpeed)
- coin.vy = -7 * gameState.baseSpeed;
- coin.a += coin.sa;
-
- // Gravity
- const flip =
- gameState.perks.helium > 0 &&
- Math.abs(coin.x - gameState.puckPosition) * 2 >
- gameState.puckWidth + coin.size;
- let dvy =
- frames * coin.weight * 0.8 * (flip ? -gameState.perks.helium : 1);
-
- if (gameState.perks.etherealcoins) {
- if (gameState.perks.helium) {
- dvy *= 0.2 / gameState.perks.etherealcoins;
- } else {
- dvy *= 0;
- }
- }
-
- coin.vy += dvy;
-
- if (
- gameState.perks.helium &&
- !isOptionOn("basic") &&
- Math.random() < 0.1 * frames
- ) {
- makeParticle(
- gameState,
- coin.x,
- coin.y,
- 0,
- dvy * 10,
- getCoinRenderColor(gameState, coin),
- true,
- 5,
- 250,
- );
- }
-
- const speed = (Math.abs(coin.vx) + Math.abs(coin.vy)) * 10;
-
- const hitBorder = bordersHitCheck(gameState, coin, coin.size / 2, frames);
-
-
- if (
- coin.previousY < gameState.gameZoneHeight &&
- coin.y > gameState.gameZoneHeight &&
- coin.vy > 0 &&
- speed > 20 &&
- !coin.floatingTime
- ) {
- schedulGameSound(
- gameState,
- "plouf",
- coin.x,
- (clamp(speed, 20, 100) / 100) * 0.2,
- );
- if (gameState.perks.compound_interest) {
- resetCombo(gameState, coin.x, gameState.gameZoneHeight - 20);
- }
- if (!isOptionOn("basic")) {
- makeParticle(
- gameState,
- coin.x,
- gameState.gameZoneHeight,
- -coin.vx / 5,
- -coin.vy / 5,
- getCoinRenderColor(gameState, coin),
- false,
- );
- }
- }
-
- 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 , negative in case it's a negative coin
- gameState.puckHeight * (coin.points ? 1 : -1)
- ) {
- addToScore(gameState, coin);
- destroy(gameState.coins, coinIndex);
- } else if (
- coin.y > gameState.canvasHeight + coinRadius * 10 ||
- coin.y < -coinRadius * 10 ||
- coin.x < -coinRadius * 10 ||
- coin.x > gameState.canvasWidth + coinRadius * 10
- ) {
- gameState.levelLostCoins += coin.points;
- destroy(gameState.coins, coinIndex);
-
- if (
- gameState.combo < gameState.perks.fountain_toss * 30 &&
- Math.random() / coin.points < (1 / gameState.combo) * gameState.perks.fountain_toss
- ) {
- increaseCombo(gameState, 1,
- clamp(coin.x, 20, gameState.canvasWidth - 20),
- clamp(coin.y, 20, gameState.gameZoneHeight - 20)
- );
- }
- }
-
- const hitBrick = coinBrickHitCheck(gameState, coin);
- if (gameState.perks.metamorphosis && typeof hitBrick !== "undefined") {
- if (
- gameState.bricks[hitBrick] &&
- coin.color !== gameState.bricks[hitBrick] &&
- gameState.bricks[hitBrick] !== "black" &&
- coin.metamorphosisPoints
- ) {
- // Not using setbrick because we don't want to reset HP
- gameState.bricks[hitBrick] = coin.color;
- coin.metamorphosisPoints--;
- schedulGameSound(gameState, "colorChange", coin.x, 0.3);
-
- if (gameState.perks.hypnosis) {
- const closestBall = getClosestBall(gameState, coin.x, coin.y);
- if (closestBall) {
- coin.x = closestBall.x;
- coin.y = closestBall.y;
- coin.vx = (Math.random() - 0.5) * gameState.baseSpeed;
- coin.vy = (Math.random() - 0.5) * gameState.baseSpeed;
- coin.metamorphosisPoints = gameState.perks.metamorphosis;
- }
- }
- }
- }
-
- // Sound and slow down
- if (
- (!gameState.perks.ghost_coins && typeof hitBrick !== "undefined") ||
- hitBorder
- ) {
- const ratio = 1 - 0.2 / (1 + gameState.perks.etherealcoins);
- coin.vx *= ratio;
- coin.vy *= ratio;
- if (Math.abs(coin.vy) < 1) {
- coin.vy = 0;
- }
- coin.sa *= 0.9;
- if (speed > 20 && !coin.collidedLastFrame) {
- schedulGameSound(gameState, "coinBounce", coin.x, 0.2);
- }
- }
- // remember collision
- coin.collidedLastFrame = !!(
- typeof hitBrick !== "undefined" ||
- hitBorder
- )
- });
-
- gameState.balls.forEach((ball) => ballTick(gameState, ball, frames));
-
- 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
- ) {
- // switch speeds
- let tempVx = a.vx;
- let tempVy = a.vy;
- a.vx = b.vx;
- a.vy = b.vy;
- b.vx = tempVx;
- b.vy = tempVy;
- // Compute center
- let x = (a.x + b.x) / 2;
- let y = (a.y + b.y) / 2;
- // space out the balls with extra speed
- if (gameState.perks.shocks > 1) {
- const limit = gameState.baseSpeed * gameState.perks.shocks / 2;
- 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);
- explosionAt(
- gameState,
- index,
- x,
- y,
- a,
- Math.max(0, gameState.perks.shocks - 1),
- );
- }
- }),
- );
- }
-
- if (gameState.perks.wind) {
- const windD =
- ((gameState.puckPosition -
- (gameState.offsetX + gameState.gameZoneWidth / 2)) /
- gameState.gameZoneWidth) *
- 2 *
- gameState.perks.wind;
- for (let i = 0; i < gameState.perks.wind; i++) {
- if (Math.random() * Math.abs(windD) > 0.5) {
- makeParticle(
- gameState,
- gameState.offsetXRoundedDown +
- Math.random() * gameState.gameZoneWidthRoundedUp,
- Math.random() * gameState.gameZoneHeight,
- windD * 8,
- 0,
- rainbowColor(),
- true,
- gameState.coinSize / 2,
- 150,
- );
- }
- }
- }
- forEachLiveOne(gameState.particles, (flash, index) => {
- flash.x += flash.vx * frames;
- flash.y += flash.vy * frames;
- if (!flash.ethereal) {
- flash.vy += 0.5 * frames;
- if (hasBrick(brickIndex(flash.x, flash.y))) {
- destroy(gameState.particles, index);
- }
- }
- });
- }
-
- if (
- gameState.combo > baseCombo(gameState) &&
- !isOptionOn("basic") &&
- (gameState.combo - baseCombo(gameState)) * Math.random() > 5
- ) {
- // The red should still be visible on a white bg
-
- if (gameState.perks.top_is_lava == 1) {
- makeParticle(
- gameState,
- gameState.offsetXRoundedDown +
- Math.random() * gameState.gameZoneWidthRoundedUp,
- 0,
- (Math.random() - 0.5) * 10,
- 5,
- "#FF0000",
- true,
- gameState.coinSize / 2,
- 100 * (Math.random() + 1),
- );
- }
-
- if (gameState.perks.left_is_lava == 1) {
- makeParticle(
- gameState,
- gameState.offsetXRoundedDown,
- Math.random() * gameState.gameZoneHeight,
- 5,
- (Math.random() - 0.5) * 10,
- "#FF0000",
- true,
- gameState.coinSize / 2,
- 100 * (Math.random() + 1),
- );
- }
-
- if (gameState.perks.right_is_lava == 1) {
- makeParticle(
- gameState,
- gameState.offsetXRoundedDown + gameState.gameZoneWidthRoundedUp,
- Math.random() * gameState.gameZoneHeight,
- -5,
- (Math.random() - 0.5) * 10,
- "#FF0000",
- true,
- gameState.coinSize / 2,
- 100 * (Math.random() + 1),
- );
- }
-
- if (gameState.perks.compound_interest) {
- let x = gameState.puckPosition,
- attemps = 0;
- do {
- x =
- gameState.offsetXRoundedDown +
- gameState.gameZoneWidthRoundedUp * Math.random();
- attemps++;
- } while (
- Math.abs(x - gameState.puckPosition) < gameState.puckWidth / 2 &&
- attemps < 10
- );
-
- makeParticle(
- gameState,
- x,
- gameState.gameZoneHeight,
- (Math.random() - 0.5) * 10,
- -5,
- "#FF0000",
- true,
- gameState.coinSize / 2,
- 100 * (Math.random() + 1),
- );
- }
- if (gameState.perks.streak_shots) {
- const pos = 0.5 - Math.random();
- makeParticle(
- gameState,
- gameState.puckPosition + gameState.puckWidth * pos,
- gameState.gameZoneHeight - gameState.puckHeight,
- pos * 10,
- -5,
- "#FF0000",
- true,
- gameState.coinSize / 2,
- 100 * (Math.random() + 1),
- );
- }
- }
-
- // Respawn what's needed, show particles
- forEachLiveOne(gameState.respawns, (r, ri) => {
- if (gameState.bricks[r.index]) {
- destroy(gameState.respawns, ri);
- } else if (gameState.levelTime > r.time) {
- setBrick(gameState, r.index, r.color);
- destroy(gameState.respawns, ri);
- } else {
- const {index, color} = r;
- const vertical = Math.random() > 0.5;
- const dx = Math.random() > 0.5 ? 1 : -1;
- const dy = Math.random() > 0.5 ? 1 : -1;
-
- makeParticle(
- gameState,
- brickCenterX(gameState, index) + (dx * gameState.brickWidth) / 2,
- brickCenterY(gameState, index) + (dy * gameState.brickWidth) / 2,
- vertical ? 0 : -dx * gameState.baseSpeed,
- vertical ? -dy * gameState.baseSpeed : 0,
- color,
- true,
- gameState.coinSize / 2,
- 250,
- );
- }
- });
-
- forEachLiveOne(gameState.particles, (p, pi) => {
- if (gameState.levelTime > p.time + p.duration) {
- destroy(gameState.particles, pi);
- }
- });
- forEachLiveOne(gameState.texts, (p, pi) => {
- if (gameState.levelTime > p.time + p.duration) {
- destroy(gameState.texts, pi);
- }
- });
- forEachLiveOne(gameState.lights, (p, pi) => {
- if (gameState.levelTime > p.time + p.duration) {
- destroy(gameState.lights, pi);
- }
- });
-}
-
-export function ballTick(gameState: GameState, ball: Ball, frames: number) {
- ball.previousVX = ball.vx;
- ball.previousVY = ball.vy;
-
- let speedLimitDampener =
- 1 +
- gameState.perks.telekinesis +
- gameState.perks.ball_repulse_ball +
- gameState.perks.puck_repulse_ball +
- gameState.perks.ball_attract_ball;
-
- if (telekinesisEffectRate(gameState, ball) > 0) {
- speedLimitDampener += 3;
- ball.vx +=
- ((gameState.puckPosition - ball.x) / 1000) *
- frames *
- gameState.perks.telekinesis *
- telekinesisEffectRate(gameState, ball);
- }
- if (yoyoEffectRate(gameState, ball) > 0) {
- speedLimitDampener += 3;
-
- ball.vx +=
- ((gameState.puckPosition - ball.x) / 1000) *
- frames *
- gameState.perks.yoyo *
- yoyoEffectRate(gameState, ball);
- }
-
- if (ball.hitSinceBounce < gameState.perks.bricks_attract_ball * 3) {
- goToNearestBrick(
- gameState,
- ball,
- gameState.perks.bricks_attract_ball * frames * 0.2,
- 2 + gameState.perks.bricks_attract_ball,
- Math.random() < 0.5 * frames,
- );
- }
-
- if (
- ball.vx * ball.vx + ball.vy * ball.vy <
- gameState.baseSpeed * gameState.baseSpeed * 2
- ) {
- ball.vx *= 1 + 0.02 / speedLimitDampener;
- ball.vy *= 1 + 0.02 / speedLimitDampener;
- } else {
- ball.vx *= 1 - 0.02 / speedLimitDampener;
- ball.vy *= 1 - 0.02 / speedLimitDampener;
- }
- // Ball could get stuck horizontally because of ball-ball interactions in repulse/attract
- if (Math.abs(ball.vy) < 0.2 * gameState.baseSpeed) {
- ball.vy += ((ball.vy > 0 ? 1 : -1) * 0.02) / speedLimitDampener;
- }
-
- if (gameState.perks.ball_repulse_ball) {
- for (let b2 of gameState.balls) {
- // avoid computing this twice, and repulsing itself
- if (b2.x >= ball.x) continue;
- repulse(gameState, ball, b2, gameState.perks.ball_repulse_ball, true);
- }
- }
- if (gameState.perks.ball_attract_ball) {
- for (let b2 of gameState.balls) {
- // avoid computing this twice, and repulsing itself
- if (b2.x >= ball.x) continue;
- attract(gameState, ball, b2, gameState.perks.ball_attract_ball);
- }
- }
- if (
- gameState.perks.puck_repulse_ball &&
- Math.abs(ball.x - gameState.puckPosition) <
- gameState.puckWidth / 2 +
- (gameState.ballSize * (9 + gameState.perks.puck_repulse_ball)) / 10
- ) {
- repulse(
- gameState,
- ball,
- {
- x: gameState.puckPosition,
- y: gameState.gameZoneHeight,
- },
- gameState.perks.puck_repulse_ball + 1,
- false,
- );
- }
-
- const borderHitCode = bordersHitCheck(
+ if (gameState.perks.hot_start) {
+ if (gameState.combo === baseCombo(gameState)) {
+ // Give 1s of time between catching a coin and tick down
+ gameState.lastTickDown = gameState.levelTime;
+ } else if (gameState.levelTime > gameState.lastTickDown + 1000) {
+ gameState.lastTickDown = gameState.levelTime;
+ decreaseCombo(
gameState,
- ball,
- gameState.ballSize / 2,
- frames,
- );
- if (borderHitCode) {
-
- ball.sidesHitsSinceBounce++
- if (ball.sidesHitsSinceBounce <= gameState.perks.three_cushion * 3) {
- increaseCombo(gameState, 1, ball.x, ball.y);
- }
-
- if (
- gameState.perks.left_is_lava &&
- borderHitCode % 2 &&
- ball.x < gameState.offsetX + gameState.gameZoneWidth / 2
- ) {
- resetCombo(gameState, ball.x, ball.y);
- }
-
- if (
- gameState.perks.right_is_lava &&
- borderHitCode % 2 &&
- ball.x > gameState.offsetX + gameState.gameZoneWidth / 2
- ) {
- resetCombo(gameState, ball.x, ball.y);
- }
-
- if (gameState.perks.top_is_lava && borderHitCode >= 2) {
- resetCombo(gameState, ball.x, ball.y + gameState.ballSize * 3);
- }
- if (gameState.perks.trampoline) {
- decreaseCombo(
- gameState,
- gameState.perks.trampoline,
- ball.x,
- ball.y + gameState.ballSize,
- );
- }
-
- schedulGameSound(gameState, "wallBeep", ball.x, 1);
- gameState.levelWallBounces++;
- gameState.runStatistics.wall_bounces++;
+ gameState.perks.hot_start,
+ gameState.puckPosition,
+ gameState.gameZoneHeight - 2 * gameState.puckHeight,
+ );
}
+ }
- // Puck collision
- const ylimit =
- gameState.gameZoneHeight - gameState.puckHeight - gameState.ballSize / 2;
- const ballIsUnderPuck =
- Math.abs(ball.x - gameState.puckPosition) <
- gameState.ballSize / 2 + gameState.puckWidth / 2;
- if (
- ball.y > ylimit &&
- ball.vy > 0 &&
- (ballIsUnderPuck ||
- (gameState.balls.length < 2 &&
- gameState.perks.extra_life &&
- ball.y > ylimit + gameState.puckHeight / 2))
- ) {
- if (ballIsUnderPuck) {
- const speed = Math.sqrt(ball.vx * ball.vx + ball.vy * ball.vy);
- const angle = Math.atan2(
- -gameState.puckWidth / 2,
- (ball.x - gameState.puckPosition) *
- (gameState.perks.concave_puck
- ? -1 / (1 + gameState.perks.concave_puck)
- : 1),
- );
- ball.vx = speed * Math.cos(angle);
- ball.vy = speed * Math.sin(angle);
- schedulGameSound(gameState, "wallBeep", ball.x, 1);
- } else {
- ball.vy *= -1;
- justLostALife(gameState, ball, ball.x, ball.y);
- }
- if (gameState.perks.streak_shots) {
- resetCombo(gameState, ball.x, ball.y);
- }
- if (gameState.perks.trampoline) {
- increaseCombo(gameState, gameState.perks.trampoline, ball.x, ball.y);
- }
- if (
- gameState.perks.nbricks &&
- ball.hitSinceBounce < gameState.perks.nbricks
- ) {
- resetCombo(gameState, ball.x, ball.y);
- }
+ if (
+ remainingBricks <= gameState.perks.skip_last &&
+ !gameState.autoCleanUses
+ ) {
+ gameState.bricks.forEach((type, index) => {
+ if (type) {
+ explodeBrick(gameState, index, gameState.balls[0], true);
+ }
+ });
+ gameState.autoCleanUses++;
+ }
- if (!ball.hitSinceBounce && gameState.bricks.find((i) => i)) {
- gameState.runStatistics.misses++;
- if (gameState.perks.forgiving) {
- const loss = Math.floor(
- (gameState.levelMisses / 10 / gameState.perks.forgiving) *
- (gameState.combo - baseCombo(gameState)),
- );
- decreaseCombo(gameState, loss, ball.x, ball.y - gameState.ballSize);
- } else {
- resetCombo(gameState, ball.x, ball.y);
- }
- gameState.levelMisses++;
- makeText(
- gameState,
- gameState.puckPosition,
- gameState.gameZoneHeight - gameState.puckHeight * 2,
- "#FF0000",
- t("play.missed_ball"),
- gameState.puckHeight,
- 500,
- );
- }
- gameState.runStatistics.puck_bounces++;
- ball.hitSinceBounce = 0;
- ball.brokenSinceBounce = 0;
- ball.sidesHitsSinceBounce = 0;
- ball.sapperUses = 0;
- ball.piercePoints = gameState.perks.pierce * 3;
+ const hasPendingBricks = liveCount(gameState.respawns);
+
+ if (gameState.running && !remainingBricks && !hasPendingBricks) {
+ if (!gameState.winAt) {
+ gameState.winAt = gameState.levelTime + 5000;
}
+ } else {
+ gameState.winAt = 0;
+ }
- if (
- gameState.running &&
- (
- ball.y > gameState.gameZoneHeight + gameState.ballSize / 2 ||
- ball.y < -gameState.gameZoneHeight ||
- ball.x < -gameState.gameZoneHeight ||
- ball.x > gameState.canvasWidth + gameState.gameZoneHeight
- )
-
- ) {
- ball.destroyed = true;
- gameState.runStatistics.balls_lost++;
- if (!gameState.balls.find((b) => !b.destroyed)) {
- if (gameState.startParams.computer_controlled) {
- startComputerControlledGame(gameState.startParams.stress);
- } else {
- gameOver(
- t("gameOver.lost.title"),
- t("gameOver.lost.summary", {score: gameState.score}),
- );
- }
- }
+ if (
+ (gameState.running &&
+ // Delayed win when coins are still flying
+ gameState.winAt &&
+ gameState.levelTime > gameState.winAt) ||
+ // instant win condition
+ (gameState.levelTime && !remainingBricks && !liveCount(gameState.coins))
+ ) {
+ if (gameState.startParams.computer_controlled) {
+ startComputerControlledGame(gameState.startParams.stress);
+ } else 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 }),
+ );
}
- const radius = gameState.ballSize / 2;
- // Make ball/coin bonce, and return bricks that were hit
- const {x, y, previousX, previousY} = ball;
+ } else if (gameState.running || gameState.levelTime) {
+ const coinRadius = Math.round(gameState.coinSize / 2);
- const vhit = hitsSomething(previousX, y, radius);
- const hhit = hitsSomething(x, previousY, radius);
- const chit =
- (typeof vhit == "undefined" &&
- typeof hhit == "undefined" &&
- hitsSomething(x, y, radius)) ||
- undefined;
+ forEachLiveOne(gameState.coins, (coin, coinIndex) => {
+ if (gameState.perks.coin_magnet) {
+ const strength =
+ (100 /
+ (100 +
+ Math.pow(coin.y - gameState.gameZoneHeight, 2) +
+ Math.pow(coin.x - gameState.puckPosition, 2))) *
+ gameState.perks.coin_magnet;
- const hitBrick = vhit ?? hhit ?? chit;
+ const attractionX =
+ frames * (gameState.puckPosition - coin.x) * strength;
- if (typeof hitBrick !== "undefined") {
- const initialBrickColor = gameState.bricks[hitBrick];
- ball.hitSinceBounce++;
+ coin.vx += attractionX;
+ coin.vy +=
+ (frames * (gameState.gameZoneHeight - coin.y) * strength) / 2;
+ coin.sa -= attractionX / 10;
+ }
- if (!ball.sidesHitsSinceBounce && gameState.perks.three_cushion) {
- resetCombo(gameState, ball.x, ball.y);
- }
- if (gameState.perks.nbricks) {
- if (ball.hitSinceBounce > gameState.perks.nbricks) {
- resetCombo(gameState, ball.x, ball.y);
- } else {
- increaseCombo(gameState, gameState.perks.nbricks, ball.x, ball.y);
- }
- // We need to reset at each hit, otherwise it's just an OP version of single puck hit streak
- }
+ if (gameState.perks.ball_attracts_coins && gameState.balls.length) {
+ // Find closest ball
+ let closestBall = getClosestBall(gameState, coin.x, coin.y);
+ if (closestBall) {
+ let dist = distance2(closestBall, coin);
- let pierce = false;
- let damage =
- 1 +
- (shouldPierceByColor(gameState, vhit, hhit, chit)
- ? gameState.perks.pierce_color
- : 0);
+ const minDist = gameState.brickWidth * gameState.brickWidth;
+ if (
+ dist > minDist &&
+ dist < minDist * 4 * 4 * gameState.perks.ball_attracts_coins
+ ) {
+ // Slow down coins in effect radius
+ const ratio =
+ 1 - 0.02 * (0.5 + gameState.perks.ball_attracts_coins);
+ coin.vx *= ratio;
+ coin.vy *= ratio;
+ coin.vy *= ratio;
+ // Carry them
+ const dx =
+ ((closestBall.x - coin.x) / dist) *
+ 50 *
+ gameState.perks.ball_attracts_coins;
+ const dy =
+ ((closestBall.y - coin.y) / dist) *
+ 50 *
+ gameState.perks.ball_attracts_coins;
+ coin.vx += dx;
+ coin.vy += dy;
- gameState.brickHP[hitBrick] -= damage;
-
- const used = Math.min(
- ball.piercePoints,
- Math.max(1, gameState.brickHP[hitBrick] + 1),
- );
- gameState.brickHP[hitBrick] -= used;
- ball.piercePoints -= used;
-
- if (gameState.brickHP[hitBrick] < 0) {
- gameState.brickHP[hitBrick] = 0;
- pierce = true;
- }
- if (typeof vhit !== "undefined" || typeof chit !== "undefined") {
- if (!pierce) {
- ball.y = ball.previousY;
- ball.vy *= -1;
- }
- }
- if (typeof hhit !== "undefined" || typeof chit !== "undefined") {
- if (!pierce) {
- ball.x = ball.previousX;
- ball.vx *= -1;
- }
- }
-
- if (!gameState.brickHP[hitBrick]) {
- ball.brokenSinceBounce++;
- applyOttawaTreatyPerk(gameState, hitBrick, ball)
- explodeBrick(gameState, hitBrick, ball, false);
if (
- ball.sapperUses < gameState.perks.sapper &&
- initialBrickColor !== "black" && // don't replace a brick that bounced with sturdy_bricks
- !gameState.bricks[hitBrick]
+ !isOptionOn("basic") &&
+ Math.random() * gameState.perks.ball_attracts_coins * frames > 0.9
) {
- setBrick(gameState, hitBrick, "black");
- ball.sapperUses++;
- }
-
-
- } else {
- schedulGameSound(gameState, "wallBeep", x, 1);
- makeLight(
+ makeParticle(
gameState,
- brickCenterX(gameState, hitBrick),
- brickCenterY(gameState, hitBrick),
- "#FFFFFF",
- gameState.brickWidth + 2,
- 50 * gameState.brickHP[hitBrick],
- );
- }
- }
-
- if (
- !isOptionOn("basic") &&
- ballTransparency(ball, gameState) < Math.random()
- ) {
- const remainingPierce = ball.piercePoints;
- const remainingSapper = ball.sapperUses < gameState.perks.sapper;
- const willMiss =
- isOptionOn("red_miss") && ball.vy > 0 && !ball.hitSinceBounce;
- const extraCombo = gameState.combo - 1;
-
- if (
- willMiss ||
- (extraCombo && Math.random() > 0.1 / (1 + extraCombo)) ||
- (remainingSapper && Math.random() > 0.1 / (1 + remainingSapper)) ||
- (extraCombo && Math.random() > 0.1 / (1 + extraCombo))
- ) {
- const color =
- (remainingSapper && (Math.random() > 0.5 ? "#ffb92a" : "#FF0000")) ||
- (willMiss && "#FF0000") ||
- gameState.ballsColor;
-
- makeParticle(
- gameState,
- ball.x,
- ball.y,
- gameState.perks.pierce_color || remainingPierce
- ? -ball.vx + ((Math.random() - 0.5) * gameState.baseSpeed) / 3
- : (Math.random() - 0.5) * gameState.baseSpeed,
- gameState.perks.pierce_color || remainingPierce
- ? -ball.vy + ((Math.random() - 0.5) * gameState.baseSpeed) / 3
- : (Math.random() - 0.5) * gameState.baseSpeed,
- color,
+ coin.x + dx * 5,
+ coin.y + dy * 5,
+ dx * 2,
+ dy * 2,
+ rainbowColor(),
true,
gameState.coinSize / 2,
100,
- );
+ );
+ }
+ }
}
+ }
+
+ if (gameState.perks.bricks_attract_coins) {
+ goToNearestBrick(
+ gameState,
+ coin,
+ gameState.perks.bricks_attract_coins * frames,
+ 2,
+ false,
+ );
+ }
+
+ const ratio =
+ 1 -
+ ((gameState.perks.viscosity * 0.03 +
+ 0.002 +
+ (coin.y > gameState.gameZoneHeight ? 0.2 : 0)) *
+ frames) /
+ (1 + gameState.perks.etherealcoins);
+
+ if (!gameState.perks.etherealcoins) {
+ coin.vy *= ratio;
+ coin.vx *= ratio;
+ }
+ if (
+ coin.y > gameState.gameZoneHeight &&
+ coin.floatingTime < gameState.perks.buoy * 30
+ ) {
+ coin.floatingTime += frames;
+ coin.vy -= 1.5;
+ }
+
+ if (coin.vx > 7 * gameState.baseSpeed) coin.vx = 7 * gameState.baseSpeed;
+ if (coin.vx < -7 * gameState.baseSpeed)
+ coin.vx = -7 * gameState.baseSpeed;
+ if (coin.vy > 7 * gameState.baseSpeed) coin.vy = 7 * gameState.baseSpeed;
+ if (coin.vy < -7 * gameState.baseSpeed)
+ coin.vy = -7 * gameState.baseSpeed;
+ coin.a += coin.sa;
+
+ // Gravity
+ const flip =
+ gameState.perks.helium > 0 &&
+ Math.abs(coin.x - gameState.puckPosition) * 2 >
+ gameState.puckWidth + coin.size;
+ let dvy =
+ frames * coin.weight * 0.8 * (flip ? -gameState.perks.helium : 1);
+
+ if (gameState.perks.etherealcoins) {
+ if (gameState.perks.helium) {
+ dvy *= 0.2 / gameState.perks.etherealcoins;
+ } else {
+ dvy *= 0;
+ }
+ }
+
+ coin.vy += dvy;
+
+ if (
+ gameState.perks.helium &&
+ !isOptionOn("basic") &&
+ Math.random() < 0.1 * frames
+ ) {
+ makeParticle(
+ gameState,
+ coin.x,
+ coin.y,
+ 0,
+ dvy * 10,
+ getCoinRenderColor(gameState, coin),
+ true,
+ 5,
+ 250,
+ );
+ }
+
+ const speed = (Math.abs(coin.vx) + Math.abs(coin.vy)) * 10;
+
+ const hitBorder = bordersHitCheck(gameState, coin, coin.size / 2, frames);
+
+ if (
+ coin.previousY < gameState.gameZoneHeight &&
+ coin.y > gameState.gameZoneHeight &&
+ coin.vy > 0 &&
+ speed > 20 &&
+ !coin.floatingTime
+ ) {
+ schedulGameSound(
+ gameState,
+ "plouf",
+ coin.x,
+ (clamp(speed, 20, 100) / 100) * 0.2,
+ );
+ if (gameState.perks.compound_interest) {
+ resetCombo(gameState, coin.x, gameState.gameZoneHeight - 20);
+ }
+ if (!isOptionOn("basic")) {
+ makeParticle(
+ gameState,
+ coin.x,
+ gameState.gameZoneHeight,
+ -coin.vx / 5,
+ -coin.vy / 5,
+ getCoinRenderColor(gameState, coin),
+ false,
+ );
+ }
+ }
+
+ 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 , negative in case it's a negative coin
+ gameState.puckHeight * (coin.points ? 1 : -1)
+ ) {
+ addToScore(gameState, coin);
+ destroy(gameState.coins, coinIndex);
+ } else if (
+ coin.y > gameState.canvasHeight + coinRadius * 10 ||
+ coin.y < -coinRadius * 10 ||
+ coin.x < -coinRadius * 10 ||
+ coin.x > gameState.canvasWidth + coinRadius * 10
+ ) {
+ gameState.levelLostCoins += coin.points;
+ destroy(gameState.coins, coinIndex);
+
+ if (
+ gameState.combo < gameState.perks.fountain_toss * 30 &&
+ Math.random() / coin.points <
+ (1 / gameState.combo) * gameState.perks.fountain_toss
+ ) {
+ increaseCombo(
+ gameState,
+ 1,
+ clamp(coin.x, 20, gameState.canvasWidth - 20),
+ clamp(coin.y, 20, gameState.gameZoneHeight - 20),
+ );
+ }
+ }
+
+ const hitBrick = coinBrickHitCheck(gameState, coin);
+ if (gameState.perks.metamorphosis && typeof hitBrick !== "undefined") {
+ if (
+ gameState.bricks[hitBrick] &&
+ coin.color !== gameState.bricks[hitBrick] &&
+ gameState.bricks[hitBrick] !== "black" &&
+ coin.metamorphosisPoints
+ ) {
+ // Not using setbrick because we don't want to reset HP
+ gameState.bricks[hitBrick] = coin.color;
+ coin.metamorphosisPoints--;
+ schedulGameSound(gameState, "colorChange", coin.x, 0.3);
+
+ if (gameState.perks.hypnosis) {
+ const closestBall = getClosestBall(gameState, coin.x, coin.y);
+ if (closestBall) {
+ coin.x = closestBall.x;
+ coin.y = closestBall.y;
+ coin.vx = (Math.random() - 0.5) * gameState.baseSpeed;
+ coin.vy = (Math.random() - 0.5) * gameState.baseSpeed;
+ coin.metamorphosisPoints = gameState.perks.metamorphosis;
+ }
+ }
+ }
+ }
+
+ // Sound and slow down
+ if (
+ (!gameState.perks.ghost_coins && typeof hitBrick !== "undefined") ||
+ hitBorder
+ ) {
+ const ratio = 1 - 0.2 / (1 + gameState.perks.etherealcoins);
+ coin.vx *= ratio;
+ coin.vy *= ratio;
+ if (Math.abs(coin.vy) < 1) {
+ coin.vy = 0;
+ }
+ coin.sa *= 0.9;
+ if (speed > 20 && !coin.collidedLastFrame) {
+ schedulGameSound(gameState, "coinBounce", coin.x, 0.2);
+ }
+ }
+ // remember collision
+ coin.collidedLastFrame = !!(typeof hitBrick !== "undefined" || hitBorder);
+ });
+
+ gameState.balls.forEach((ball) => ballTick(gameState, ball, frames));
+
+ 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
+ ) {
+ // switch speeds
+ let tempVx = a.vx;
+ let tempVy = a.vy;
+ a.vx = b.vx;
+ a.vy = b.vy;
+ b.vx = tempVx;
+ b.vy = tempVy;
+ // Compute center
+ let x = (a.x + b.x) / 2;
+ let y = (a.y + b.y) / 2;
+ // space out the balls with extra speed
+ if (gameState.perks.shocks > 1) {
+ const limit = (gameState.baseSpeed * gameState.perks.shocks) / 2;
+ 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);
+ explosionAt(
+ gameState,
+ index,
+ x,
+ y,
+ a,
+ Math.max(0, gameState.perks.shocks - 1),
+ );
+ }
+ }),
+ );
}
+
+ if (gameState.perks.wind) {
+ const windD =
+ ((gameState.puckPosition -
+ (gameState.offsetX + gameState.gameZoneWidth / 2)) /
+ gameState.gameZoneWidth) *
+ 2 *
+ gameState.perks.wind;
+ for (let i = 0; i < gameState.perks.wind; i++) {
+ if (Math.random() * Math.abs(windD) > 0.5) {
+ makeParticle(
+ gameState,
+ gameState.offsetXRoundedDown +
+ Math.random() * gameState.gameZoneWidthRoundedUp,
+ Math.random() * gameState.gameZoneHeight,
+ windD * 8,
+ 0,
+ rainbowColor(),
+ true,
+ gameState.coinSize / 2,
+ 150,
+ );
+ }
+ }
+ }
+ forEachLiveOne(gameState.particles, (flash, index) => {
+ flash.x += flash.vx * frames;
+ flash.y += flash.vy * frames;
+ if (!flash.ethereal) {
+ flash.vy += 0.5 * frames;
+ if (hasBrick(brickIndex(flash.x, flash.y))) {
+ destroy(gameState.particles, index);
+ }
+ }
+ });
+ }
+
+ if (
+ gameState.combo > baseCombo(gameState) &&
+ !isOptionOn("basic") &&
+ (gameState.combo - baseCombo(gameState)) * Math.random() > 5
+ ) {
+ // The red should still be visible on a white bg
+
+ if (gameState.perks.top_is_lava == 1) {
+ makeParticle(
+ gameState,
+ gameState.offsetXRoundedDown +
+ Math.random() * gameState.gameZoneWidthRoundedUp,
+ 0,
+ (Math.random() - 0.5) * 10,
+ 5,
+ "#FF0000",
+ true,
+ gameState.coinSize / 2,
+ 100 * (Math.random() + 1),
+ );
+ }
+
+ if (gameState.perks.left_is_lava == 1) {
+ makeParticle(
+ gameState,
+ gameState.offsetXRoundedDown,
+ Math.random() * gameState.gameZoneHeight,
+ 5,
+ (Math.random() - 0.5) * 10,
+ "#FF0000",
+ true,
+ gameState.coinSize / 2,
+ 100 * (Math.random() + 1),
+ );
+ }
+
+ if (gameState.perks.right_is_lava == 1) {
+ makeParticle(
+ gameState,
+ gameState.offsetXRoundedDown + gameState.gameZoneWidthRoundedUp,
+ Math.random() * gameState.gameZoneHeight,
+ -5,
+ (Math.random() - 0.5) * 10,
+ "#FF0000",
+ true,
+ gameState.coinSize / 2,
+ 100 * (Math.random() + 1),
+ );
+ }
+
+ if (gameState.perks.compound_interest) {
+ let x = gameState.puckPosition,
+ attemps = 0;
+ do {
+ x =
+ gameState.offsetXRoundedDown +
+ gameState.gameZoneWidthRoundedUp * Math.random();
+ attemps++;
+ } while (
+ Math.abs(x - gameState.puckPosition) < gameState.puckWidth / 2 &&
+ attemps < 10
+ );
+
+ makeParticle(
+ gameState,
+ x,
+ gameState.gameZoneHeight,
+ (Math.random() - 0.5) * 10,
+ -5,
+ "#FF0000",
+ true,
+ gameState.coinSize / 2,
+ 100 * (Math.random() + 1),
+ );
+ }
+ if (gameState.perks.streak_shots) {
+ const pos = 0.5 - Math.random();
+ makeParticle(
+ gameState,
+ gameState.puckPosition + gameState.puckWidth * pos,
+ gameState.gameZoneHeight - gameState.puckHeight,
+ pos * 10,
+ -5,
+ "#FF0000",
+ true,
+ gameState.coinSize / 2,
+ 100 * (Math.random() + 1),
+ );
+ }
+ }
+
+ // Respawn what's needed, show particles
+ forEachLiveOne(gameState.respawns, (r, ri) => {
+ if (gameState.bricks[r.index]) {
+ destroy(gameState.respawns, ri);
+ } else if (gameState.levelTime > r.time) {
+ setBrick(gameState, r.index, r.color);
+ destroy(gameState.respawns, ri);
+ } else {
+ const { index, color } = r;
+ const vertical = Math.random() > 0.5;
+ const dx = Math.random() > 0.5 ? 1 : -1;
+ const dy = Math.random() > 0.5 ? 1 : -1;
+
+ makeParticle(
+ gameState,
+ brickCenterX(gameState, index) + (dx * gameState.brickWidth) / 2,
+ brickCenterY(gameState, index) + (dy * gameState.brickWidth) / 2,
+ vertical ? 0 : -dx * gameState.baseSpeed,
+ vertical ? -dy * gameState.baseSpeed : 0,
+ color,
+ true,
+ gameState.coinSize / 2,
+ 250,
+ );
+ }
+ });
+
+ forEachLiveOne(gameState.particles, (p, pi) => {
+ if (gameState.levelTime > p.time + p.duration) {
+ destroy(gameState.particles, pi);
+ }
+ });
+ forEachLiveOne(gameState.texts, (p, pi) => {
+ if (gameState.levelTime > p.time + p.duration) {
+ destroy(gameState.texts, pi);
+ }
+ });
+ forEachLiveOne(gameState.lights, (p, pi) => {
+ if (gameState.levelTime > p.time + p.duration) {
+ destroy(gameState.lights, pi);
+ }
+ });
+}
+
+export function ballTick(gameState: GameState, ball: Ball, frames: number) {
+ ball.previousVX = ball.vx;
+ ball.previousVY = ball.vy;
+
+ let speedLimitDampener =
+ 1 +
+ gameState.perks.telekinesis +
+ gameState.perks.ball_repulse_ball +
+ gameState.perks.puck_repulse_ball +
+ gameState.perks.ball_attract_ball;
+
+ if (telekinesisEffectRate(gameState, ball) > 0) {
+ speedLimitDampener += 3;
+ ball.vx +=
+ ((gameState.puckPosition - ball.x) / 1000) *
+ frames *
+ gameState.perks.telekinesis *
+ telekinesisEffectRate(gameState, ball);
+ }
+ if (yoyoEffectRate(gameState, ball) > 0) {
+ speedLimitDampener += 3;
+
+ ball.vx +=
+ ((gameState.puckPosition - ball.x) / 1000) *
+ frames *
+ gameState.perks.yoyo *
+ yoyoEffectRate(gameState, ball);
+ }
+
+ if (ball.hitSinceBounce < gameState.perks.bricks_attract_ball * 3) {
+ goToNearestBrick(
+ gameState,
+ ball,
+ gameState.perks.bricks_attract_ball * frames * 0.2,
+ 2 + gameState.perks.bricks_attract_ball,
+ Math.random() < 0.5 * frames,
+ );
+ }
+
+ if (
+ ball.vx * ball.vx + ball.vy * ball.vy <
+ gameState.baseSpeed * gameState.baseSpeed * 2
+ ) {
+ ball.vx *= 1 + 0.02 / speedLimitDampener;
+ ball.vy *= 1 + 0.02 / speedLimitDampener;
+ } else {
+ ball.vx *= 1 - 0.02 / speedLimitDampener;
+ ball.vy *= 1 - 0.02 / speedLimitDampener;
+ }
+ // Ball could get stuck horizontally because of ball-ball interactions in repulse/attract
+ if (Math.abs(ball.vy) < 0.2 * gameState.baseSpeed) {
+ ball.vy += ((ball.vy > 0 ? 1 : -1) * 0.02) / speedLimitDampener;
+ }
+
+ if (gameState.perks.ball_repulse_ball) {
+ for (let b2 of gameState.balls) {
+ // avoid computing this twice, and repulsing itself
+ if (b2.x >= ball.x) continue;
+ repulse(gameState, ball, b2, gameState.perks.ball_repulse_ball, true);
+ }
+ }
+ if (gameState.perks.ball_attract_ball) {
+ for (let b2 of gameState.balls) {
+ // avoid computing this twice, and repulsing itself
+ if (b2.x >= ball.x) continue;
+ attract(gameState, ball, b2, gameState.perks.ball_attract_ball);
+ }
+ }
+ if (
+ gameState.perks.puck_repulse_ball &&
+ Math.abs(ball.x - gameState.puckPosition) <
+ gameState.puckWidth / 2 +
+ (gameState.ballSize * (9 + gameState.perks.puck_repulse_ball)) / 10
+ ) {
+ repulse(
+ gameState,
+ ball,
+ {
+ x: gameState.puckPosition,
+ y: gameState.gameZoneHeight,
+ },
+ gameState.perks.puck_repulse_ball + 1,
+ false,
+ );
+ }
+
+ const borderHitCode = bordersHitCheck(
+ gameState,
+ ball,
+ gameState.ballSize / 2,
+ frames,
+ );
+ if (borderHitCode) {
+ ball.sidesHitsSinceBounce++;
+ if (ball.sidesHitsSinceBounce <= gameState.perks.three_cushion * 3) {
+ increaseCombo(gameState, 1, ball.x, ball.y);
+ }
+
+ if (
+ gameState.perks.left_is_lava &&
+ borderHitCode % 2 &&
+ ball.x < gameState.offsetX + gameState.gameZoneWidth / 2
+ ) {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+
+ if (
+ gameState.perks.right_is_lava &&
+ borderHitCode % 2 &&
+ ball.x > gameState.offsetX + gameState.gameZoneWidth / 2
+ ) {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+
+ if (gameState.perks.top_is_lava && borderHitCode >= 2) {
+ resetCombo(gameState, ball.x, ball.y + gameState.ballSize * 3);
+ }
+ if (gameState.perks.trampoline) {
+ decreaseCombo(
+ gameState,
+ gameState.perks.trampoline,
+ ball.x,
+ ball.y + gameState.ballSize,
+ );
+ }
+
+ schedulGameSound(gameState, "wallBeep", ball.x, 1);
+ gameState.levelWallBounces++;
+ gameState.runStatistics.wall_bounces++;
+ }
+
+ // Puck collision
+ const ylimit =
+ gameState.gameZoneHeight - gameState.puckHeight - gameState.ballSize / 2;
+ const ballIsUnderPuck =
+ Math.abs(ball.x - gameState.puckPosition) <
+ gameState.ballSize / 2 + gameState.puckWidth / 2;
+ if (
+ ball.y > ylimit &&
+ ball.vy > 0 &&
+ (ballIsUnderPuck ||
+ (gameState.balls.length < 2 &&
+ gameState.perks.extra_life &&
+ ball.y > ylimit + gameState.puckHeight / 2))
+ ) {
+ if (ballIsUnderPuck) {
+ const speed = Math.sqrt(ball.vx * ball.vx + ball.vy * ball.vy);
+ const angle = Math.atan2(
+ -gameState.puckWidth / 2,
+ (ball.x - gameState.puckPosition) *
+ (gameState.perks.concave_puck
+ ? -1 / (1 + gameState.perks.concave_puck)
+ : 1),
+ );
+ ball.vx = speed * Math.cos(angle);
+ ball.vy = speed * Math.sin(angle);
+ schedulGameSound(gameState, "wallBeep", ball.x, 1);
+ } else {
+ ball.vy *= -1;
+ justLostALife(gameState, ball, ball.x, ball.y);
+ }
+ if (gameState.perks.streak_shots) {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+ if (gameState.perks.trampoline) {
+ increaseCombo(gameState, gameState.perks.trampoline, ball.x, ball.y);
+ }
+ if (
+ gameState.perks.nbricks &&
+ ball.hitSinceBounce < gameState.perks.nbricks
+ ) {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+
+ if (!ball.hitSinceBounce && gameState.bricks.find((i) => i)) {
+ gameState.runStatistics.misses++;
+ if (gameState.perks.forgiving) {
+ const loss = Math.floor(
+ (gameState.levelMisses / 10 / gameState.perks.forgiving) *
+ (gameState.combo - baseCombo(gameState)),
+ );
+ decreaseCombo(gameState, loss, ball.x, ball.y - gameState.ballSize);
+ } else {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+ gameState.levelMisses++;
+ makeText(
+ gameState,
+ gameState.puckPosition,
+ gameState.gameZoneHeight - gameState.puckHeight * 2,
+ "#FF0000",
+ t("play.missed_ball"),
+ gameState.puckHeight,
+ 500,
+ );
+ }
+ gameState.runStatistics.puck_bounces++;
+ ball.hitSinceBounce = 0;
+ ball.brokenSinceBounce = 0;
+ ball.sidesHitsSinceBounce = 0;
+ ball.sapperUses = 0;
+ ball.piercePoints = gameState.perks.pierce * 3;
+ }
+
+ if (
+ gameState.running &&
+ (ball.y > gameState.gameZoneHeight + gameState.ballSize / 2 ||
+ ball.y < -gameState.gameZoneHeight ||
+ ball.x < -gameState.gameZoneHeight ||
+ ball.x > gameState.canvasWidth + gameState.gameZoneHeight)
+ ) {
+ ball.destroyed = true;
+ gameState.runStatistics.balls_lost++;
+ if (!gameState.balls.find((b) => !b.destroyed)) {
+ if (gameState.startParams.computer_controlled) {
+ startComputerControlledGame(gameState.startParams.stress);
+ } else {
+ gameOver(
+ t("gameOver.lost.title"),
+ 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 vhit = hitsSomething(previousX, y, radius);
+ const hhit = hitsSomething(x, previousY, radius);
+ const chit =
+ (typeof vhit == "undefined" &&
+ typeof hhit == "undefined" &&
+ hitsSomething(x, y, radius)) ||
+ undefined;
+
+ const hitBrick = vhit ?? hhit ?? chit;
+
+ if (typeof hitBrick !== "undefined") {
+ const initialBrickColor = gameState.bricks[hitBrick];
+ ball.hitSinceBounce++;
+
+ if (!ball.sidesHitsSinceBounce && gameState.perks.three_cushion) {
+ resetCombo(gameState, ball.x, ball.y);
+ }
+ if (gameState.perks.nbricks) {
+ if (ball.hitSinceBounce > gameState.perks.nbricks) {
+ resetCombo(gameState, ball.x, ball.y);
+ } else {
+ increaseCombo(gameState, gameState.perks.nbricks, ball.x, ball.y);
+ }
+ // We need to reset at each hit, otherwise it's just an OP version of single puck hit streak
+ }
+
+ let pierce = false;
+ let damage =
+ 1 +
+ (shouldPierceByColor(gameState, vhit, hhit, chit)
+ ? gameState.perks.pierce_color
+ : 0);
+
+ gameState.brickHP[hitBrick] -= damage;
+
+ const used = Math.min(
+ ball.piercePoints,
+ Math.max(1, gameState.brickHP[hitBrick] + 1),
+ );
+ gameState.brickHP[hitBrick] -= used;
+ ball.piercePoints -= used;
+
+ if (gameState.brickHP[hitBrick] < 0) {
+ gameState.brickHP[hitBrick] = 0;
+ pierce = true;
+ }
+ if (typeof vhit !== "undefined" || typeof chit !== "undefined") {
+ if (!pierce) {
+ ball.y = ball.previousY;
+ ball.vy *= -1;
+ }
+ }
+ if (typeof hhit !== "undefined" || typeof chit !== "undefined") {
+ if (!pierce) {
+ ball.x = ball.previousX;
+ ball.vx *= -1;
+ }
+ }
+
+ if (!gameState.brickHP[hitBrick]) {
+ ball.brokenSinceBounce++;
+ applyOttawaTreatyPerk(gameState, hitBrick, ball);
+ explodeBrick(gameState, hitBrick, ball, false);
+ if (
+ ball.sapperUses < gameState.perks.sapper &&
+ initialBrickColor !== "black" && // don't replace a brick that bounced with sturdy_bricks
+ !gameState.bricks[hitBrick]
+ ) {
+ setBrick(gameState, hitBrick, "black");
+ ball.sapperUses++;
+ }
+ } else {
+ schedulGameSound(gameState, "wallBeep", x, 1);
+ makeLight(
+ gameState,
+ brickCenterX(gameState, hitBrick),
+ brickCenterY(gameState, hitBrick),
+ "#FFFFFF",
+ gameState.brickWidth + 2,
+ 50 * gameState.brickHP[hitBrick],
+ );
+ }
+ }
+
+ if (
+ !isOptionOn("basic") &&
+ ballTransparency(ball, gameState) < Math.random()
+ ) {
+ const remainingPierce = ball.piercePoints;
+ const remainingSapper = ball.sapperUses < gameState.perks.sapper;
+ const willMiss =
+ isOptionOn("red_miss") && ball.vy > 0 && !ball.hitSinceBounce;
+ const extraCombo = gameState.combo - 1;
+
+ if (
+ willMiss ||
+ (extraCombo && Math.random() > 0.1 / (1 + extraCombo)) ||
+ (remainingSapper && Math.random() > 0.1 / (1 + remainingSapper)) ||
+ (extraCombo && Math.random() > 0.1 / (1 + extraCombo))
+ ) {
+ const color =
+ (remainingSapper && (Math.random() > 0.5 ? "#ffb92a" : "#FF0000")) ||
+ (willMiss && "#FF0000") ||
+ gameState.ballsColor;
+
+ makeParticle(
+ gameState,
+ ball.x,
+ ball.y,
+ gameState.perks.pierce_color || remainingPierce
+ ? -ball.vx + ((Math.random() - 0.5) * gameState.baseSpeed) / 3
+ : (Math.random() - 0.5) * gameState.baseSpeed,
+ gameState.perks.pierce_color || remainingPierce
+ ? -ball.vy + ((Math.random() - 0.5) * gameState.baseSpeed) / 3
+ : (Math.random() - 0.5) * gameState.baseSpeed,
+ color,
+ true,
+ gameState.coinSize / 2,
+ 100,
+ );
+ }
+ }
}
function justLostALife(gameState: GameState, ball: Ball, x: number, y: number) {
- gameState.perks.extra_life -= 1;
- if (gameState.perks.extra_life < 0) {
- gameState.perks.extra_life = 0;
- } else if (gameState.perks.sacrifice) {
- gameState.combo *= gameState.perks.sacrifice;
- gameState.bricks.forEach(
- (color, index) => color && explodeBrick(gameState, index, ball, true),
- );
- }
+ gameState.perks.extra_life -= 1;
+ if (gameState.perks.extra_life < 0) {
+ gameState.perks.extra_life = 0;
+ } else if (gameState.perks.sacrifice) {
+ gameState.combo *= gameState.perks.sacrifice;
+ gameState.bricks.forEach(
+ (color, index) => color && explodeBrick(gameState, index, ball, true),
+ );
+ }
- schedulGameSound(gameState, "lifeLost", ball.x, 1);
+ schedulGameSound(gameState, "lifeLost", ball.x, 1);
- if (!isOptionOn("basic")) {
- for (let i = 0; i < 10; i++)
- makeParticle(
- gameState,
- x,
- y,
- Math.random() * gameState.baseSpeed * 3,
- gameState.baseSpeed * 3,
- "#FF0000",
- false,
- gameState.coinSize / 2,
- 150,
- );
- }
+ if (!isOptionOn("basic")) {
+ for (let i = 0; i < 10; i++)
+ makeParticle(
+ gameState,
+ x,
+ y,
+ Math.random() * gameState.baseSpeed * 3,
+ gameState.baseSpeed * 3,
+ "#FF0000",
+ false,
+ gameState.coinSize / 2,
+ 150,
+ );
+ }
}
function makeCoin(
- gameState: GameState,
- x: number,
- y: number,
- vx: number,
- vy: number,
- color = "#ffd300",
- points = 1,
+ gameState: GameState,
+ x: number,
+ y: number,
+ vx: number,
+ vy: number,
+ color = "#ffd300",
+ points = 1,
) {
- let weight = 0.8 + Math.random() * 0.2 + Math.min(2, points * 0.01);
- weight *= 5 / (5 + gameState.perks.etherealcoins);
+ let weight = 0.8 + Math.random() * 0.2 + Math.min(2, points * 0.01);
+ weight *= 5 / (5 + gameState.perks.etherealcoins);
- if (gameState.perks.trickledown) y = -20;
- if (
- gameState.perks.rainbow &&
- Math.random() > 1 / (1 + gameState.perks.rainbow)
- )
- color = rainbowColor();
+ if (gameState.perks.trickledown) y = -20;
+ if (
+ gameState.perks.rainbow &&
+ Math.random() > 1 / (1 + gameState.perks.rainbow)
+ )
+ color = rainbowColor();
- append(gameState.coins, (p: Partial) => {
- p.x = x;
- p.y = y;
- p.collidedLastFrame = true;
- p.size = gameState.coinSize;
- p.previousX = x;
- p.previousY = y;
- p.vx = vx;
- p.vy = vy;
- // p.sx = 0;
- // p.sy = 0;
- p.color = color;
- p.a = Math.random() * Math.PI * 2;
- p.sa = Math.random() - 0.5;
- p.points = points;
- p.weight = weight;
- p.metamorphosisPoints = gameState.perks.metamorphosis;
- p.floatingTime = 0
- });
+ append(gameState.coins, (p: Partial) => {
+ p.x = x;
+ p.y = y;
+ p.collidedLastFrame = true;
+ p.size = gameState.coinSize;
+ p.previousX = x;
+ p.previousY = y;
+ p.vx = vx;
+ p.vy = vy;
+ // p.sx = 0;
+ // p.sy = 0;
+ p.color = color;
+ p.a = Math.random() * Math.PI * 2;
+ p.sa = Math.random() - 0.5;
+ p.points = points;
+ p.weight = weight;
+ p.metamorphosisPoints = gameState.perks.metamorphosis;
+ p.floatingTime = 0;
+ });
}
function makeParticle(
- gameState: GameState,
- x: number,
- y: number,
- vx: number,
- vy: number,
- color: colorString,
- ethereal = false,
- size = 8,
- duration = 150,
+ gameState: GameState,
+ x: number,
+ y: number,
+ vx: number,
+ vy: number,
+ color: colorString,
+ ethereal = false,
+ size = 8,
+ duration = 150,
) {
- append(gameState.particles, (p: Partial) => {
- p.time = gameState.levelTime;
- p.x = x;
- p.y = y;
- p.vx = vx;
- p.vy = vy;
- p.color = color;
- p.size = size;
- p.duration = duration;
- p.ethereal = ethereal;
- });
+ append(gameState.particles, (p: Partial) => {
+ p.time = gameState.levelTime;
+ p.x = x;
+ p.y = y;
+ p.vx = vx;
+ p.vy = vy;
+ p.color = color;
+ p.size = size;
+ p.duration = duration;
+ p.ethereal = ethereal;
+ });
}
function makeText(
- gameState: GameState,
- x: number,
- y: number,
- color: colorString,
- text: string,
- size = 20,
- duration = 500,
+ gameState: GameState,
+ x: number,
+ y: number,
+ color: colorString,
+ text: string,
+ size = 20,
+ duration = 500,
) {
- append(gameState.texts, (p: Partial) => {
- p.time = gameState.levelTime;
- p.x = x;
- p.y = y;
- p.color = color;
- p.size = size;
- p.duration = clamp(duration, 400, 2000);
- p.text = text;
- });
+ append(gameState.texts, (p: Partial) => {
+ p.time = gameState.levelTime;
+ p.x = x;
+ p.y = y;
+ p.color = color;
+ p.size = size;
+ p.duration = clamp(duration, 400, 2000);
+ p.text = text;
+ });
}
function makeLight(
- gameState: GameState,
- x: number,
- y: number,
- color: colorString,
- size = 8,
- duration = 150,
+ gameState: GameState,
+ x: number,
+ y: number,
+ color: colorString,
+ size = 8,
+ duration = 150,
) {
- append(gameState.lights, (p: Partial) => {
- p.time = gameState.levelTime;
- p.x = x;
- p.y = y;
- p.color = color;
- p.size = size;
- p.duration = duration;
- });
+ append(gameState.lights, (p: Partial) => {
+ p.time = gameState.levelTime;
+ p.x = x;
+ p.y = y;
+ p.color = color;
+ p.size = size;
+ p.duration = duration;
+ });
}
export function append(
- where: ReusableArray,
- makeItem: (match: Partial) => void,
+ where: ReusableArray,
+ makeItem: (match: Partial) => void,
) {
- while (
- where.list[where.indexMin] &&
- !where.list[where.indexMin].destroyed &&
- where.indexMin < where.list.length
- ) {
- where.indexMin++;
- }
- if (where.indexMin < where.list.length) {
- where.list[where.indexMin].destroyed = false;
- makeItem(where.list[where.indexMin]);
- where.indexMin++;
- } else {
- const p = {destroyed: false};
- makeItem(p);
- where.list.push(p);
- }
- where.total++;
+ while (
+ where.list[where.indexMin] &&
+ !where.list[where.indexMin].destroyed &&
+ where.indexMin < where.list.length
+ ) {
+ where.indexMin++;
+ }
+ if (where.indexMin < where.list.length) {
+ where.list[where.indexMin].destroyed = false;
+ makeItem(where.list[where.indexMin]);
+ where.indexMin++;
+ } else {
+ const p = { destroyed: false };
+ makeItem(p);
+ where.list.push(p);
+ }
+ where.total++;
}
export function destroy(where: ReusableArray, index: number) {
- if (where.list[index].destroyed) return;
- where.list[index].destroyed = true;
- where.indexMin = Math.min(where.indexMin, index);
- where.total--;
+ if (where.list[index].destroyed) return;
+ where.list[index].destroyed = true;
+ where.indexMin = Math.min(where.indexMin, index);
+ where.total--;
}
export function liveCount(where: ReusableArray) {
- return where.total;
+ return where.total;
}
export function empty(where: ReusableArray) {
- let destroyed = 0;
- where.total = 0;
- where.indexMin = 0;
- where.list.forEach((i) => {
- if (!i.destroyed) {
- i.destroyed = true;
- destroyed++;
- }
- });
- return destroyed;
+ let destroyed = 0;
+ where.total = 0;
+ where.indexMin = 0;
+ where.list.forEach((i) => {
+ if (!i.destroyed) {
+ i.destroyed = true;
+ destroyed++;
+ }
+ });
+ return destroyed;
}
export function forEachLiveOne(
- where: ReusableArray,
- cb: (t: T, index: number) => void,
+ where: ReusableArray,
+ cb: (t: T, index: number) => void,
) {
- where.list.forEach((item: T, index: number) => {
- if (item && !item.destroyed) {
- cb(item, index);
- }
- });
+ where.list.forEach((item: T, index: number) => {
+ if (item && !item.destroyed) {
+ cb(item, index);
+ }
+ });
}
function goToNearestBrick(
- gameState: GameState,
- coin: Ball | Coin,
- strength,
- size = 2,
- particle = false,
+ gameState: GameState,
+ coin: Ball | Coin,
+ strength,
+ size = 2,
+ particle = false,
) {
- const row = Math.floor(coin.y / gameState.brickWidth);
- const col = Math.floor((coin.x - gameState.offsetX) / gameState.brickWidth);
- let vx = 0,
- vy = 0;
- for (let dcol = -size; dcol < size; dcol++) {
- for (let drow = -size; drow < size; drow++) {
- const index = getRowColIndex(gameState, row + drow, col + dcol);
- if (gameState.bricks[index]) {
- const dx =
- brickCenterX(gameState, index) +
- (clamp(-dcol, -1, 1) * gameState.brickWidth) / 2 -
- coin.x;
- const dy =
- brickCenterY(gameState, index) +
- (clamp(-drow, -1, 1) * gameState.brickWidth) / 2 -
- coin.y;
- const d2 = dx * dx + dy * dy;
- vx += (dx / d2) * 20;
- vy += (dy / d2) * 20;
- }
- }
+ const row = Math.floor(coin.y / gameState.brickWidth);
+ const col = Math.floor((coin.x - gameState.offsetX) / gameState.brickWidth);
+ let vx = 0,
+ vy = 0;
+ for (let dcol = -size; dcol < size; dcol++) {
+ for (let drow = -size; drow < size; drow++) {
+ const index = getRowColIndex(gameState, row + drow, col + dcol);
+ if (gameState.bricks[index]) {
+ const dx =
+ brickCenterX(gameState, index) +
+ (clamp(-dcol, -1, 1) * gameState.brickWidth) / 2 -
+ coin.x;
+ const dy =
+ brickCenterY(gameState, index) +
+ (clamp(-drow, -1, 1) * gameState.brickWidth) / 2 -
+ coin.y;
+ const d2 = dx * dx + dy * dy;
+ vx += (dx / d2) * 20;
+ vy += (dy / d2) * 20;
+ }
}
+ }
- coin.vx += vx * strength;
- coin.vy += vy * strength;
- const s2 = coin.vx * coin.vx + coin.vy * coin.vy;
- if (s2 > gameState.baseSpeed * gameState.baseSpeed * 2) {
- coin.vx *= 0.95;
- coin.vy *= 0.95;
- }
+ coin.vx += vx * strength;
+ coin.vy += vy * strength;
+ const s2 = coin.vx * coin.vx + coin.vy * coin.vy;
+ if (s2 > gameState.baseSpeed * gameState.baseSpeed * 2) {
+ coin.vx *= 0.95;
+ coin.vy *= 0.95;
+ }
- if ((vx || vy) && particle) {
- makeParticle(
+ if ((vx || vy) && particle) {
+ makeParticle(
+ gameState,
+ coin.x,
+ coin.y,
+ -vx * 2,
+ -vy * 2,
+ rainbowColor(),
+ true,
+ );
+ }
+}
+
+function applyOttawaTreatyPerk(
+ gameState: GameState,
+ index: number,
+ ball: Ball,
+) {
+ if (!gameState.perks.ottawa_treaty) return;
+ if (ball.sapperUses) return;
+
+ const originalColor = gameState.bricks[index];
+ if (originalColor == "black") return;
+ const x = index % gameState.gridSize;
+ const y = Math.floor(index / gameState.gridSize);
+ let converted = 0;
+ for (let dx = -1; dx <= 1; dx++)
+ for (let dy = -1; dy <= 1; dy++)
+ if (dx || dy) {
+ const nIndex = getRowColIndex(gameState, y + dy, x + dx);
+ if (gameState.bricks[nIndex] && gameState.bricks[nIndex] === "black") {
+ setBrick(gameState, nIndex, originalColor);
+ schedulGameSound(
gameState,
- coin.x,
- coin.y,
- -vx * 2,
- -vy * 2,
- rainbowColor(),
- true,
- );
- }
+ "colorChange",
+ brickCenterX(gameState, index),
+ 1,
+ );
+ // Avoid infinite bricks generation hack
+ ball.sapperUses = Infinity;
+ converted++;
+ // Don't convert more than one brick per hit normally
+ if (converted >= gameState.perks.ottawa_treaty) return;
+ }
+ }
+ return;
}
-
-
-function applyOttawaTreatyPerk(gameState: GameState, index: number, ball: Ball) {
- if (!gameState.perks.ottawa_treaty) return
- if (ball.sapperUses) return
-
- const originalColor = gameState.bricks[index]
- if (originalColor == 'black') return
- const x = index % gameState.gridSize
- const y = Math.floor(index / gameState.gridSize)
- let converted = 0
- for (let dx = -1; dx <= 1; dx++)
- for (let dy = -1; dy <= 1; dy++)
- if (dx || dy) {
- const nIndex = getRowColIndex(gameState, y + dy, x + dx)
- if (gameState.bricks[nIndex] && gameState.bricks[nIndex] === 'black') {
-
- setBrick(gameState, nIndex, originalColor)
- schedulGameSound(gameState, "colorChange", brickCenterX(gameState, index), 1)
- // Avoid infinite bricks generation hack
- ball.sapperUses = Infinity
- converted++
- // Don't convert more than one brick per hit normally
- if (converted >= gameState.perks.ottawa_treaty) return
-
- }
- }
- return
-}
-
diff --git a/src/game_utils.ts b/src/game_utils.ts
index 7fd5bc4..3bd4859 100644
--- a/src/game_utils.ts
+++ b/src/game_utils.ts
@@ -13,7 +13,7 @@ import { t } from "./i18n/i18n";
import { clamp } from "./pure_functions";
import { rawUpgrades } from "./upgrades";
import { hashCode } from "./getLevelBackground";
-import { getTotalScore } from "./settings";
+import { getSettingValue, getTotalScore } from "./settings";
import { isOptionOn } from "./options";
export function describeLevel(level: Level) {
@@ -392,16 +392,6 @@ export function reasonLevelIsLocked(
}
}
-export function ballTransparency(ball: Ball, gameState: GameState) {
- if (!gameState.perks.transparency) return 0;
- return clamp(
- gameState.perks.transparency *
- (1 - (ball.y / gameState.gameZoneHeight) * 1.2),
- 0,
- 1,
- );
-}
-
export function getCoinRenderColor(gameState: GameState, coin: Coin) {
if (
gameState.perks.metamorphosis ||
@@ -423,3 +413,12 @@ export function getCornerOffset(gameState: GameState) {
}
export const isInWebView = !!window.location.href.includes("isInWebView=true");
+
+export function hoursSpentPlaying() {
+ try {
+ const timePlayed = getSettingValue("breakout_71_total_play_time", 0);
+ return Math.floor(timePlayed / 1000 / 60 / 60);
+ } catch (e) {
+ return 0;
+ }
+}
diff --git a/src/levelEditor.ts b/src/levelEditor.ts
index d528d60..f7f6ada 100644
--- a/src/levelEditor.ts
+++ b/src/levelEditor.ts
@@ -1,10 +1,6 @@
import { icons, transformRawLevel } from "./loadGameData";
import { t } from "./i18n/i18n";
-import {
- getSettingValue,
- getTotalScore,
- setSettingValue,
-} from "./settings";
+import { getSettingValue, getTotalScore, setSettingValue } from "./settings";
import { asyncAlert } from "./asyncAlert";
import { Palette, RawLevel } from "./types";
import { levelIconHTML } from "./levelIcon";
@@ -165,7 +161,6 @@ export async function editRawLevelList(nth: number, color = "W") {
text: t("editor.editing.copy"),
value: "copy",
help: t("editor.editing.copy_help"),
-
},
{
text: t("editor.editing.bigger"),
@@ -250,7 +245,10 @@ export async function editRawLevelList(nth: number, color = "W") {
return;
}
if (action === "copy") {
- let text = "```\n[" + (level.name||'unnamed level')?.replace(/\[|\]/gi, " ") + "]";
+ let text =
+ "```\n[" +
+ (level.name || "unnamed level")?.replace(/\[|\]/gi, " ") +
+ "]";
bricks.forEach((b, bi) => {
if (!(bi % level.size)) text += "\n";
text += b;
diff --git a/src/loadGameData.test.ts b/src/loadGameData.test.ts
index 2542223..ba3887f 100644
--- a/src/loadGameData.test.ts
+++ b/src/loadGameData.test.ts
@@ -1,7 +1,6 @@
import _palette from "./data/palette.json";
import _rawLevelsList from "./data/levels.json";
import _appVersion from "./data/version.json";
-import { rawUpgrades } from "./upgrades";
describe("json data checks", () => {
it("_rawLevelsList has icon levels", () => {
@@ -10,13 +9,6 @@ describe("json data checks", () => {
).toBeGreaterThan(10);
});
- it("all upgrades have icons", () => {
- const missingIcon = rawUpgrades.filter(
- (u) => !_rawLevelsList.find((l) => l.name == "icon:" + u.id),
- );
- expect(missingIcon).toEqual([]);
- });
-
it("_rawLevelsList has non-icon few levels", () => {
expect(
_rawLevelsList.filter((l) => !l.name.startsWith("icon:")).length,
diff --git a/src/migrations.ts b/src/migrations.ts
index ad2474f..f75b53d 100644
--- a/src/migrations.ts
+++ b/src/migrations.ts
@@ -140,16 +140,15 @@ migrate("set_breakout_71_unlocked_levels" + _appVersion, () => {
);
});
-migrate('clean_ls', ()=>{
- for (let key in localStorage) {
+migrate("clean_ls", () => {
+ for (let key in localStorage) {
try {
- JSON.parse(localStorage.getItem(key) || "null");
+ JSON.parse(localStorage.getItem(key) || "null");
} catch (e) {
- localStorage.removeItem(key)
- console.warn('Removed invalid key '+key,e);
+ localStorage.removeItem(key);
+ console.warn("Removed invalid key " + key, e);
}
}
-
-})
+});
afterMigration();
diff --git a/src/options.ts b/src/options.ts
index 051c45a..6c05277 100644
--- a/src/options.ts
+++ b/src/options.ts
@@ -2,7 +2,8 @@ import { t } from "./i18n/i18n";
import { OptionDef, OptionId } from "./types";
import { getSettingValue, setSettingValue } from "./settings";
-import { hoursSpentPlaying } from "./pure_functions";
+
+import { hoursSpentPlaying } from "./game_utils";
export const options = {
sound: {
diff --git a/src/pure_functions.ts b/src/pure_functions.ts
index 4e557dd..48af796 100644
--- a/src/pure_functions.ts
+++ b/src/pure_functions.ts
@@ -1,6 +1,4 @@
-import { getSettingValue } from "./settings";
-import {GameState} from "./types";
-import {ballTransparency} from "./game_utils";
+import { Ball, GameState } from "./types";
export function clamp(value: number, min: number, max: number) {
return Math.max(min, Math.min(value, max));
@@ -10,33 +8,39 @@ export function comboKeepingRate(level: number) {
return clamp(1 - (1 / (1 + level)) * 1.5, 0, 1);
}
-export function hoursSpentPlaying() {
- try {
- const timePlayed = getSettingValue("breakout_71_total_play_time", 0);
- return Math.floor(timePlayed / 1000 / 60 / 60);
- } catch (e) {
- return 0;
- }
+export function shouldCoinsStick(gameState: GameState) {
+ return (
+ gameState.perks.sticky_coins &&
+ (!gameState.lastExplosion ||
+ gameState.lastExplosion <
+ gameState.levelTime - 300 * gameState.perks.sticky_coins)
+ );
}
-export function shouldCoinsStick(gameState:GameState){
- return gameState.perks.sticky_coins && (!gameState.lastExplosion || gameState.lastExplosion < gameState.levelTime - 300 * gameState.perks.sticky_coins)
+export function ballTransparency(ball: Ball, gameState: GameState) {
+ if (!gameState.perks.transparency) return 0;
+ return clamp(
+ gameState.perks.transparency *
+ (1 - (ball.y / gameState.gameZoneHeight) * 1.2),
+ 0,
+ 1,
+ );
}
-export function coinsBoostedCombo(gameState:GameState){
- let boost = 1+gameState.perks.sturdy_bricks / 2 + gameState.perks.smaller_puck/2
- if(gameState.perks.transparency){
- let min=1;
- gameState.balls.forEach(ball=>{
- const bt=ballTransparency(ball, gameState)
- if(bt {
+ const bt = ballTransparency(ball, gameState);
+ if (bt < min) {
+ min = bt;
}
- })
- boost+=min*gameState.perks.transparency / 2
+ });
+ boost += (min * gameState.perks.transparency) / 2;
}
- return Math.ceil(Math.max(gameState.combo,gameState.lastCombo) * boost)
-
+ return Math.ceil(Math.max(gameState.combo, gameState.lastCombo) * boost);
}
export function miniMarkDown(md: string) {
diff --git a/src/render.ts b/src/render.ts
index 10c879d..d3f8429 100644
--- a/src/render.ts
+++ b/src/render.ts
@@ -1,6 +1,5 @@
import { baseCombo, forEachLiveOne, liveCount } from "./gameStateMutators";
import {
- ballTransparency,
brickCenterX,
brickCenterY,
currentLevelInfo,
@@ -18,8 +17,10 @@ import { t } from "./i18n/i18n";
import { gameState, lastMeasuredFPS, startWork } from "./game";
import { isOptionOn } from "./options";
import {
+ ballTransparency,
catchRateBest,
- catchRateGood, coinsBoostedCombo,
+ catchRateGood,
+ coinsBoostedCombo,
levelTimeBest,
levelTimeGood,
missesBest,
@@ -75,12 +76,11 @@ export function render(gameState: GameState) {
}
const catchRate = gameState.levelSpawnedCoins
- ?
- (gameState.score - gameState.levelStartScore) /
- (gameState.levelSpawnedCoins || 1)
- // (gameState.levelSpawnedCoins - gameState.levelLostCoins) /
+ ? (gameState.score - gameState.levelStartScore) /
+ (gameState.levelSpawnedCoins || 1)
+ : // (gameState.levelSpawnedCoins - gameState.levelLostCoins) /
// gameState.levelSpawnedCoins
- : 1;
+ 1;
startWork("render:scoreDisplay");
scoreDisplay.innerHTML =
(isOptionOn("show_fps") || gameState.startParams.computer_controlled
@@ -440,12 +440,12 @@ export function render(gameState: GameState) {
);
startWork("render:combotext");
- const spawns=coinsBoostedCombo(gameState)
- if (spawns > 1) {
+ const spawns = coinsBoostedCombo(gameState);
+ if (spawns > 1) {
ctx.globalCompositeOperation = "source-over";
ctx.globalAlpha = 1;
- const comboText = spawns.toString();
+ const comboText = spawns.toString();
const comboTextWidth = (comboText.length * gameState.puckHeight) / 1.8;
const totalWidth = comboTextWidth + gameState.coinSize * 2;
const left = gameState.puckPosition - totalWidth / 2;
@@ -500,56 +500,55 @@ export function render(gameState: GameState) {
if (gameState.offsetXRoundedDown) {
// draw outside of gaming area to avoid capturing borders in recordings
- if(gameState.perks.left_is_lava<2)
- drawStraightLine(
- ctx,
- gameState,
- (redLeftSide && "#FF0000") || "#FFFFFF",
- gameState.offsetXRoundedDown - 1,
- 0,
- gameState.offsetXRoundedDown - 1,
- height,
- 1,
- );
- if(gameState.perks.right_is_lava<2)
- drawStraightLine(
- ctx,
- gameState,
- (redRightSide && "#FF0000") || "#FFFFFF",
- width - gameState.offsetXRoundedDown + 1,
- 0,
- width - gameState.offsetXRoundedDown + 1,
- height,
- 1,
- );
+ if (gameState.perks.left_is_lava < 2)
+ drawStraightLine(
+ ctx,
+ gameState,
+ (redLeftSide && "#FF0000") || "#FFFFFF",
+ gameState.offsetXRoundedDown - 1,
+ 0,
+ gameState.offsetXRoundedDown - 1,
+ height,
+ 1,
+ );
+ if (gameState.perks.right_is_lava < 2)
+ drawStraightLine(
+ ctx,
+ gameState,
+ (redRightSide && "#FF0000") || "#FFFFFF",
+ width - gameState.offsetXRoundedDown + 1,
+ 0,
+ width - gameState.offsetXRoundedDown + 1,
+ height,
+ 1,
+ );
} else {
+ if (gameState.perks.left_is_lava < 2)
+ drawStraightLine(
+ ctx,
+ gameState,
+ (redLeftSide && "#FF0000") || "",
+ 0,
+ 0,
+ 0,
+ height,
+ 1,
+ );
- if(gameState.perks.left_is_lava<2)
- drawStraightLine(
- ctx,
- gameState,
- (redLeftSide && "#FF0000") || "",
- 0,
- 0,
- 0,
- height,
- 1,
- );
-
- if(gameState.perks.right_is_lava<2)
- drawStraightLine(
- ctx,
- gameState,
- (redRightSide && "#FF0000") || "",
- width - 1,
- 0,
- width - 1,
- height,
- 1,
- );
+ if (gameState.perks.right_is_lava < 2)
+ drawStraightLine(
+ ctx,
+ gameState,
+ (redRightSide && "#FF0000") || "",
+ width - 1,
+ 0,
+ width - 1,
+ height,
+ 1,
+ );
}
- if (redTop && gameState.perks.top_is_lava<2)
+ if (redTop && gameState.perks.top_is_lava < 2)
drawStraightLine(
ctx,
gameState,
diff --git a/src/settings.ts b/src/settings.ts
index d302179..27e92d6 100644
--- a/src/settings.ts
+++ b/src/settings.ts
@@ -14,7 +14,7 @@ try {
warnedUserAboutLSIssue = true;
toast(`Storage issue : ${(e as Error)?.message}`);
}
- console.warn('Reading '+key,e);
+ console.warn("Reading " + key, e);
}
}
} catch (e) {
diff --git a/src/types.d.ts b/src/types.d.ts
index 4c5b4f1..67e906f 100644
--- a/src/types.d.ts
+++ b/src/types.d.ts
@@ -84,7 +84,7 @@ export type Coin = {
destroyed?: boolean;
collidedLastFrame?: boolean;
metamorphosisPoints: number;
- floatingTime:number;
+ floatingTime: number;
};
export type Ball = {
x: number;
diff --git a/src/upgrades.ts b/src/upgrades.ts
index a807618..bf646fb 100644
--- a/src/upgrades.ts
+++ b/src/upgrades.ts
@@ -189,7 +189,8 @@ export const rawUpgrades = [
id: "smaller_puck",
max: 2,
name: t("upgrades.smaller_puck.name"),
- help: (lvl: number) => t("upgrades.smaller_puck.tooltip", {percent:50*lvl}),
+ help: (lvl: number) =>
+ t("upgrades.smaller_puck.tooltip", { percent: 50 * lvl }),
fullHelp: t("upgrades.smaller_puck.verbose_description"),
},
{
@@ -718,14 +719,13 @@ export const rawUpgrades = [
id: "fountain_toss",
max: 7,
name: t("upgrades.fountain_toss.name"),
- help: () => t("upgrades.fountain_toss.tooltip"),
+ help: () => t("upgrades.fountain_toss.tooltip"),
fullHelp: t("upgrades.fountain_toss.verbose_description"),
},
{
requires: "",
threshold: 175000,
gift: false,
-
id: "limitless",
max: 1,
name: t("upgrades.limitless.name"),
@@ -828,8 +828,7 @@ export const rawUpgrades = [
id: "buoy",
max: 3,
name: t("upgrades.buoy.name"),
- help: (lvl: number) =>
- t("upgrades.buoy.tooltip", { duration: lvl * 0.5 }),
+ help: (lvl: number) => t("upgrades.buoy.tooltip", { duration: lvl * 0.5 }),
fullHelp: t("upgrades.buoy.verbose_description"),
},
{
@@ -839,7 +838,7 @@ export const rawUpgrades = [
id: "ottawa_treaty",
max: 1,
name: t("upgrades.ottawa_treaty.name"),
- help: () =>t("upgrades.ottawa_treaty.tooltip"),
+ help: () => t("upgrades.ottawa_treaty.tooltip"),
fullHelp: t("upgrades.ottawa_treaty.verbose_description"),
},
{
@@ -849,18 +848,18 @@ export const rawUpgrades = [
id: "three_cushion",
max: 1,
name: t("upgrades.three_cushion.name"),
- help: (lvl:number) =>t("upgrades.three_cushion.tooltip",{max:lvl*3}),
+ help: (lvl: number) =>
+ t("upgrades.three_cushion.tooltip", { max: lvl * 3 }),
fullHelp: t("upgrades.three_cushion.verbose_description"),
},
- {
+ {
requires: "",
threshold: 235000,
gift: false,
id: "sticky_coins",
max: 1,
name: t("upgrades.sticky_coins.name"),
- help: (lvl:number) =>t("upgrades.sticky_coins.tooltip"),
+ help: (lvl: number) => t("upgrades.sticky_coins.tooltip"),
fullHelp: t("upgrades.sticky_coins.verbose_description"),
},
-
] as const;