diff --git a/games/Monster-Mayhem1.js b/games/Monster-Mayhem1.js new file mode 100644 index 0000000000..bc8d7838b2 --- /dev/null +++ b/games/Monster-Mayhem1.js @@ -0,0 +1,900 @@ +/* +@title: Monster Mayhem +@author: Gus Ruben +@tags: ['retro', 'timed'] +@addedOn: 2024-10-31 +*/ + + +const EMPTY = "_"; +const GROUND1="1"; +const GROUND2="2"; +const GROUND3="3"; +const GROUND4="4"; +const GROUND5="5"; +const GROUND6="6"; +const GROUND7="7"; +const GROUND8="8"; +const GROUND9="9"; +const HOLE_RED = "R"; +const HOLE_BLUE = "B"; +const ZOMBIE = "Z"; + +const EMPTY_BITMAP = bitmap` +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................` + +const CORE_LEGEND = [ + [ EMPTY, EMPTY_BITMAP ], + [ GROUND1, bitmap` +CCCCCCCCCCCCCCCC +CCCC6CCCCCCCCCCC +CCCCCFCCCCCCCCCC +CCCCCFCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CC6CCCCCCCCCCCCC +CCC6CC6CCCCCCCCC +CCC6CFCCCCCCCCCC +CCCFCFCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC` ], + [ GROUND2, bitmap` +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCC6CC +CCCCCCCCCCCC6CCC +CCCCCCCCCCCCFCCC +CCCCCCCCCC6CFCCC +CCCCCCCCCCCFCCCC +C6CCCCCCCCCCCCCC +CCFCCCCCCCCCCCCC +CCFCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC` ], + [ GROUND3, bitmap` +CCCCC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CCCCCCCCCCFCCCC +C6CCCCCCCCCCCCCC +CCFCCCCCCCCCCCCC +CCFCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC` ], + [ GROUND7, bitmap` +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCLCCCCCCCCCCC +CCCLCCCCCCC6CCCC +CC9999CCCCCCFCCC +C969969CCCCCCCCC +C999999CCCCCCCCC +C996699CCCCCCCCC +CC9999CCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC` ], + [ GROUND8, bitmap` +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCC6CCCCCCCCCC +CCCC6CCCCCCCCCCC +CCCC6CCCCC11CCCC +CCCCFCCCCC1LLCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCC6CFCCCCC +CCCCCCC6CFCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC` ], + [ GROUND9, bitmap` +CCCCCCCCCCCCCCCC +CCCC6CCCCCCCCCCC +CCCCCFCCCCCCCCCC +CCCCCFCCCCCCCCCC +CCCCCCCCCCCCCC8C +CCCCCCCCCCC88C8C +CCCCCCCCCC8CC8CC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC +CC6CCCCCCCCCCCCC +CCC6CC6CCCCCCCCC +CCC6CFCCCCCCCCCC +CCCFCFCCCCCCCCCC +CCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCC` ], + [ HOLE_RED, bitmap` +CCCCCCCCCCCCCCCC +C33333333333333C +C3CCCCCCCCCCCC3C +CCCCLLLLLLLLCCCC +CCLL00000000LLCC +CL000000000000LC +C00000000000000C +C00000000000000C +C00000000000000C +C00000000000000C +C00000000000000C +CC000000000000CC +CCCC00000000CCCC +C3CCCCCCCCCCCC3C +C33333333333333C +CCCCCCCCCCCCCCCC` ], + [ HOLE_BLUE, bitmap` +CCCCCCCCCCCCCCCC +C77777777777777C +C7CCCCCCCCCCCC7C +CCCCLLLLLLLLCCCC +CCLL00000000LLCC +CL000000000000LC +C00000000000000C +C00000000000000C +C00000000000000C +C00000000000000C +C00000000000000C +CC000000000000CC +CCCC00000000CCCC +C7CCCCCCCCCCCC7C +C77777777777777C +CCCCCCCCCCCCCCCC` ], +]; + +const OVERLAYS = [ + bitmap` +................ +................ +................ +................ +..........FFFFFF +.........FFFFFFF +.........FFFFFFF +.........FFFFFFF +.........FFFFFFF +.........FFFFFFF +.........6FFFFFF +..........666666 +................ +................ +................ +................`, + bitmap` +................ +................ +................ +................ +FFFFF........... +FFFFFF.......... +FFFFFF.......... +FFFFFF.......... +FFFFFF.......... +FFFFFF.......... +FFFFF6.......... +66666........... +................ +................ +................ +................`, + bitmap` +................ +................ +................ +................ +................ +......FFFFFFFFFF +.....FFFFFFFFFFF +.....FFFFFFFFFFF +.....FFFFFFFFFFF +.....FFFFFFFFFFF +.....FFFFFFFFFFF +.....6FFFFFFFFFF +......6666666666 +................ +................ +................`, + bitmap` +................ +................ +................ +................ +................ +FFFFFFFFFFFFFF.. +FFFFFFFFFFFFFFF. +FFFFFFFFFFFFFFF. +FFFFFFFFFFFFFFF. +FFFFFFFFFFFFFFF. +FFFFFFFFFFFFFFF. +FFFFFFFFFFFFFF6. +66666666666666.. +................ +................ +................`, + bitmap` +................ +................ +................ +................ +................ +FFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF +6666666666666666 +................ +................ +................`, +] + +const HAMMER = bitmap` +........9666.... +.......669FFF... +........6F9FF... +.........FF1.... +............1... +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +................`; + +const MONSTERS = [ + [ bitmap` +................ +................ +................ +................ +................ +................ +................ +................ +................ +................ +.....88......... +....888DDD...... +....DDDDDDDD.... +................ +................ +................`, bitmap` +................ +................ +................ +................ +................ +................ +.....88DDDD..... +....882D202D.... +....D20DDDDD.... +....DDD00LD4.... +.....DDD4444.... +....77DDD447D... +....7D777777.... +................ +................ +................`, bitmap` +......8DDD...... +.....88D22D..... +.....88D022..... +.....02DDDDD.... +.....2200DD4.... +....DDD0LD44.... +.....DDD4444.... +...D777DDD47D... +..DD7D777D77D... +..DD.DD7777D1... +..D4.DD77D7D.... +..1..7555575.... +....5DD55555.... +................ +................ +................`, bitmap` +................ +.....88DDDD..... +....888D022..... +....822D222D.... +....D02D00DD.... +....DDD00LD4.... +.....DDD4444.... +..DD7777DD47D... +.D447D777777DD.. +.D4..DD77DD.D1.. +.14..D477D7.1... +.....7777D75.... +....5DD55555.... +................ +................ +................`, bitmap` +........9666.... +.......669FFF... +.....0DD6F9FF... +....880D0F11.... +....80DDDDD1.... +....DDD00DD4.... +.....DD00444.... +...D7777DD47D... +..DD7D777777D... +.1D4.DD77DDD1... +..1..D477D71.... +.....7777D75.... +....5DD55555.... +................ +................ +................`, bitmap` +........666..... +.......966FF.... +.....0669FFF.... +....8806691..... +....80DD6FD1.... +....DDD00DD4.... +.....DD00444.... +...D7777DD47D... +..DD7D777777D... +.1D4.DD77DDD1... +..1..D477D71.... +.....7777D75.... +....5DD55555.... +................ +................ +................` , bitmap` +........9666.... +.......669FFF... +........6F9FF... +.........F11.... +.....8DDD0D1.... +....880D0DD..... +....D0DDD0DD.... +...DDDD00D44.... +..DD7D00L477.... +..D44777777DD... +..D1.D477D7DD... +..1..7777D711... +....5DDDD551.... +................ +................ +................`, bitmap` +........9666.... +.......669FFF... +........6F9FF... +.........FF1.... +............1... +................ +................ +................ +................ +................ +.....88......... +....888DDD...... +....DDDDDDDD.... +................ +................ +................`,] +]; + + +const GAME_OVER_ART = bitmap` +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000002222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000002222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000022222222222222000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000002222221122221222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000022122211112222222222000000000000000000000000000000000000000000000000000000000000000066600000000000000000000000000000000000000000000000000000000000 +0000000000000222222211LL2222222222200000000006666660000000000000000000060000000000000000000666006666600000000000000666666666000000000000000000000000000000000000 +000000000000022222222LL22222211222200000000666666666600000000000000066666600000000000000006666006666660000000000066666666666600000000000000000000000000000000000 +000000000000222222222222222221L222220000066666666666600000000000000066666660000000000000006666066666660000000000666666666666660000000000000000000000000000000000 +0000000000022222222222222222222222211000066666666666660000000000000666666666000000000000006666666666660000000006666666666666660000000000000000000000000000000000 +0000000000022222222222222222222222111000666666666666660000000000000666666666000000000000066666666666666000000006666666666666660000000000000000000000000000000000 +0000000000022222111122222122222222111000666666666666600000000000000666666666000000000000066666666666666000000006666666666666660000000000000000000000000000000000 +0000000000222221111112222222222222111100666666066666600000000000000666000666600000000000666666666666666000000006666666600000000000000000000000000000000000000000 +0000000000222211111111222222222222111106666660000666000000000000006666006666600000000000666666666666666000000006666666000000000000000000000000000000000000000000 +0000000000212111111111122221222221111106666600000000000000000000006666606666600000000000666666666666666600000006666666600000000000000000000000000000000000000000 +0000000000222111111111L22211222221111L06666000000000000000000000006666666666600000000000666666666666666600000006666666666666660000000000000000000000000000000000 +000000000022211111111LL2222222222111LL06666000000000000000000000006666666666600000000006666666666666666600000006666666666666660000000000000000000000000000000000 +00000000002221111111LLL2222222221111LL06666000000000000000000000006666666666600000000006666666660066666600000006666666666666660000000000000000000000000000000000 +000000000002221111LLLL22222222211111L006666000000000000000000000066666666666600000000006666606660066666600000006666666666666660000000000000000000000000000000000 +000000000002222LLLLLL22211222211111LL006666000006666600000000000066666606666600000000006666606600006666600000006666666666666660000000000000000000000000000000000 +0000000000022222LLLL22221122211111LLL066666000006666666660000000066666606666600000000006666600000006666600000006666666660000000000000000000000000000000000000000 +000000000000222222222222222211111LLL0066666600006666666660000000066666000666600000000066666000000006666600000006666666000000000000000000000000000000000000000000 +00000000000002221222222222111111LLL00006666660666666666660000000066666000666600000000066666000000006666600000006666666600000000000000000000000000000000000000000 +0000000000000221122222221111111LLLL00006666666666666666000000000666666000666600000000066666000000006666600000006666666660000000000000000000000000000000000000000 +000000000000002221111111111111LLLL000006666666666666660000000000666666000666600000000066666000000006666600000006666666666666600000000000000000000000000000000000 +0000000000000001111111111111LLLLL0000000666666666666000000000000666660000666600000000066666000000000666600000006666666666666600000000000000000000000000000000000 +00000000000000000111111111LLLLL000000000666666666660000000000000666660000066600000000066666000000000666600000006666666666666600000000000000000000000000000000000 +00000000000000000011111LLLLLLL0000000000066666666000000000000000066660000066600000000066660000000000066600000000666666666666000000000000000000000000000000000000 +0000000000000000000001LLLLL0000000000000000666000000000000000000066600000066000000000066600000000000000000000000066666666660000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000060000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLL00000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLLLLLL000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLL0000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLL000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLLL00000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLL0000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLL000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000LLLLLLL0000000LLLLLLLLLLLLLL00000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000600000000000000LLLLLL000000000000LLLLLLLLLLLL0000000000000000000000000000000000000000000000 +0000000000000000LLLLLLLLLLLLLLLL000000000066666660000000000000006606666600000000000LLLLLL00000000000000LLLLLLLLLLL0066600000000000000000000000000000000000000000 +000000000000LLLLLLLLLLLLLLLLLLLLLLLL0000066666666666000000000000666666660000066000LLLLLL0666666666666600LLLLLLLLLL6666666000000000000000000000000000000000000000 +0000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLL0666666666666600000000000066666666000666600LLLLL006666666666666660LLLLLLLLL6666666600000000000000000000000000000000000000 +00000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL66666666666666000000000006666666600066660LLLLL0006666666666666666LLLLLLLLL6666666660000000000000000000000000000000000000 +000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL666666666666666000000000000666666600066660LLLLL00066666666666666600LLLLLLLL6666666666000000000000000000000000000000000000 +0000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL666666666666666660000000000066666660066666LLLLLL00066666666666666000LLLLLLLL6666666666000000000000000000000000000000000000 +00LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL666666666666666666000000000066666660066666LLLLLL000666666600000000000LLLLLLL6666LL6666000000000000000000000000000000000000 +0LLLLLLLLLL000000000LLLLLLLLLLLLLLLLL6666666666666666666000000000066666660066666LLLLLL000666666666660000000LLLLLL66666LL6666600000000000000000000000000000000000 +LLLLLLL000000000000000000LLLLLLLLLLLL66666666LLLL0666666000000000066666660666666LLLLLL000666666666666600000LLLLLL66666LL6666600000000000000000000000000000000000 +LLLLL0000000000000000000000LLLLLLLLLL66666666LLLLLL66666600000000066666660666666LLLLLLL00666666666666666000LLLLLL666666666666LL00000000000000000000000000000LLLL +LL000000000000000000000000000LLLLLLLL6666666LLLLLLL66666600000000066666660666660LLLLLLL00666666666666666000LLLLLL666666666666LLLLLL000000000000000000LLLLLLLLLLL +L000000000000000000000000000000LLLLLLL666666LLLLLLL66666600000000066666660666660LLLLLLLL0666666666666666000LLLLLL6666666666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +00000000000000000000000000000000LLLLLL666666LLLLLLL666666000000000066666606666600LLLLLLLL66666660LLLL600000LLLLLL66666666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +0000000000000000000000000000000000LLLL6666666LLL666666666000000000066666666666000LLLLLLLL666666LLLLLL000000LLLLLL66666666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +00000000000000000000000000000000000LLL6666666666666666666LL00000000666666666660000LLLLLLL666666LLLLLL00000LLLLLLL666666666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +000000000000000000000000000000000000LL666666666666666666LLLL00000006666666666600000LLLLLL66666LLLLLL000000LLLLLLL6666666666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +00000000000000000000000000000000000000L66666666666666666LLLLLLL000066666666660000000LLLLLL6666LLLLL0000000LLLLLL666666666666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL00 +000000LLLLLLLLLLL000000000000000000000066666666666666666LLLLLLLLL000666666666000000000LLLL6666LLLL0000000LLLLLLL66666LL66666LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL000000 +0LLLLLLLLLLLLLLLLLLLL0000000000000000000066666666666666LLLLLLLLLLLLL666666666000000000000666666000000000LLLLLLLL6666600066666LLLLLLLLLLLLLLLLL000000000000000000 +LLLLLLLLLLLLLLLLLLLLLLLL000000000000000000666666666666LLLLLLLLLLLLLLL6666666600000000000066666666666600LLLLLLLLL66666LLL6666600000000000000000000000000000000000 +LLLLLLLLLLLLLLLLLLLLLLLLLLL000000000000000066666666666LLLLLLLLLLLLLLL666666600000000000006666666666666LLLLLLLLLL66666LLLL666660000000000000000000000000000000000 +LLLLLLLLLLLLLLLLLLLLLLLLLLLL0000000000000000666666666LLLLLLLLLLLLLLLLL666666LLLLL000000006666666666666LLLLLLLLLL66666LLLL66666LLLLL00000000000000000000000000000 +LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL0000000000000006666666LLLLLLLLLLLLLLLLLL666666LLLLLLLLLLLLL666666666666LLLLLLLLLL666666LLLLL6666LLLLLLLL00000000000000000000000000 +LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL0000000000000006666LLLLLLLLLLLLLLLLLLLL666LLLLLLLLLLLLLLL66666666666LLLLLLLLLLLLL666LLLLLL66666LLLLLLLLLLLLLL0000000000000000000 +LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL0000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL666LLLLLLL66LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +0000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL00000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1111111111LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +00000000LLLLLLLLLLLLLLLLLLLLLLLLLLLL000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1111111LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +00000000000LLLLLLLLLLLLLLLLLLLLLLLLLLL000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1111111LLLLLLLLLLLLLL0000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +0000000000000LLLLLLLLLLLLLLLLLLLLLLLLLL0000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1111L1LLLLL000000000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLL +000000000000000LLLLLLLLLLLLLLLLLLLLLLLLL000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1111L1L000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLL +000000000000000000LLLLLLLLLLLLLLLLLLLLLLLL000000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLL11111L1000000000000000000000000000000000000000000000000LLLLLLLLLLL +0000000000000000000LLLLLLLLLLLLLLLLLLLLLLLL00000000000000000000000000000000LLLLLLLLL000000000011111L100000000000000000000000000000000000000000000000000000LLLLLL +000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLL000000000000000000000000000000000000000000000000011111L1000000000000000000000000000000000000000000000000000000000LL +00000000000000000000000LLLLLLLLLLLLLLLLLLLLLLL0000000000000000000000000000000000000000000000001LLLLL100000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000LLLLLLLLLLLLLLLLLLLLLL00000000000000000000000000000000000100000000001111111110000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000LLLLLLLLLLLLLLLLLLLLLL000000000000000000000000000000000111111111111111111111000000001000000000000000000000000000000000000000000000000 +00000000000000000000000000000LLLLLLLLLLLLLLLLLLLLL0000000000000000000000000000000011111111111L11111LL11110000011000000000000000000000000000000000000000000000000 +0000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLL00000000000000000000000000000001111111111L111111LL1111111111000000000000000000000000000000000000000000000000 +000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLL000000000000000000000000000001111111111L1111111L11111111L1000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLL000000000000000000000000000011LLLLLLLLL1111111L11111111L1000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLL00000000000000000000000000111111111111111111L1LLLLLLLL1000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLL00000000000000000000000100001111111L1111LL111111111100000LLLLLLLLLLLLLLLLLLLLLL000000000000000000000 +000000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLLL000000000000000000000000000000111LL1LL110000000L1LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL000000000000 +000000000000000000000000000CCC00000000000000LLLLLLLLLLLLLLLLLLLLLL0000000000000000000000000000111LLL11LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL000000 +00000000000000000000000000CCCCC00000000000000000LLLLLLLLLLLLLLLLLLLLLLL0000000000000000000000011111111LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL0 +00000000000000000000000000000CC000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLL000000000000000000111111100LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +000000000000000000000000000099C000000000000000000000000000000LLLLLLLLLLLLLL00LLL0000000000000001111L1000000000000000000000LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +444000000000000000000000099999999900000000000000000000000000000000000000000000000000000000000001111L1000000000000000000000000000000000000000LLLLLLLLLLLLLLLLLLLL +444440000000000000000000999999999999000000000000000000000000000000000000000000000000000000000001111L100000000000000000000000000000000000000000000000LLLLLLLLLLLL +444444440000000000000009996999999999900000000000000000000000000000000000000000000000000000000001111L10000000000000000000000000000000000000000000000000000LLLLLLL +444444444440000000000099996699999669990000000000000000000000000000000000000000000000000000000001111L100000000000000000000000000000000000000000000000000000000LLL +DDDDDDD44444444000000999999699996699999000000000000000000000000000000000000000000000000000000001111L100000000000000000000000000000000000000000000000000000000000 +DDDDDDDDD444444444000999999999996999999900000000000000000000000000000000000000000000000000000001111L100000000000000000000000000000000000000000000000000000000000 +DDDDDDDDDDDD444444444999969999999999999900000000000000000000000000000000000000000000000000000001111L100000000000000000000000000000000000000000000000000000000000 +DDDDDDDDDDDDDD444444499996669999999999990000000000000000000000000000000000000000000000000000000111LL100000000000000000000000004444444444000000000000000000000000 +DDDDDDDDDDDDDDDDD4444499996666699966999000000000000000000000000000000000000000000000000000000001LLL1100000000000444444444444444444444444444444444440000000000000 +DDDDDDDDDDDDDDDDDDD444499966666666669990000000000000000000000000000000000000000000000000000000111114144444444444444444444444444444444444444444444444444444000000 +CDDDDDDDDDDDDDDDDDDDD4499996666666699944444444000000000000000000000000000000000000000044444441144444444444444444444444444444444444444444444444444444444444444444 +CCCDDDDDDDDDDDDDDDDDDDDD4999999999999444444444444444444444400000000044444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 +CCCCCDDDDDDDDDDDDDDDDDDDDDD9999999994444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 +CCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDD4444444444444444444444444444444444444444444444444444444444444444444444444444DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD44444444444444444 +CCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDD44444444444444444444444444444444444444444444444444444444444DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD4444444 +CCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDD444444444444444444444444444444444444444DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD444 +CCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD +CCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD +CCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCCCC +CCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDD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CCC11111CC111111CCCCCCCCCCCC +CCCCCCCCCCCCCCC11111CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC11111CCC11C111CCCCCCCCCCCC +CCCCCCCCCCCCCC111111CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC111111111CC111CCCCCCCCCCCC +CCCCCCCCCCCC11111C1CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC1111111111C111CCCCCCCCCCCC +CCCCCCCCCCC11111CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC11111111111111CCCCCCCCCCCC +CCCCCCCCCC1111CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC11111111111CCCCCCCCCCCCC +CCCCCCCCC1111CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC1C1C111111CCCCCCCCCCCCCC`; + +let currentLegendChar = 400; // start after the other function ends +function getLegendChar2() { + const char = String.fromCharCode(currentLegendChar++); + if (char == "." || char == "\n" || char == " ") { + // skip reserved characters + return String.fromCharCode(currentLegendChar++); + } + return char; +} + +const splitGameOver = splitBitmap(GAME_OVER_ART); +const gameOverLegend = splitGameOver.map((chunk, index) => [ + getLegendChar2(), + chunk, +]); +// create the map by joining every char for the title into one string, then inserting newlines +const gameOverMap = gameOverLegend + .map((v) => v[0]) + .join("") + .replace(/(.{10})/g, "$1\n") + .slice(0, -1); + +function splitBitmap(bitmap) { + const rows = bitmap.trim().split("\n"); + const chunks = []; + const chunkRows = rows.length / 16; + const chunkCols = rows[0].length / 16; + + for (let i = 0; i < chunkRows; i++) { + for (let j = 0; j < chunkCols; j++) { + let chunk = []; + for (let r = 0; r < 16; r++) { + const rowIndex = i * 16 + r; + const startCol = j * 16; + const endCol = startCol + 16; + + chunk.push(rows[rowIndex].slice(startCol, endCol)); + } + chunks.push(chunk.join("\n")); + } + } + + return chunks; +} + +// get a unique number given an x and y, using cantor's pairing function +function getPositionHash(x, y) { + return ((x+y) * (x+y+1) * 0.5) + y; // cantor's pairing function +} + +// get a unique character for each position +function getLegendChar(x, y) { + x++; + y++; + return String.fromCharCode(getPositionHash(x, y) + 128); // add 128 so it's past all the normal chars we might want to use; +} + +const STARTING_LEGEND=[]; +const CUSTOM_LEGEND_CHARS = []; +for (let y = 0; y < 5; y++) { + let row = []; + for (let x = 0; x < 6; x++) { + const ch = getLegendChar(x, y); + row.push(ch); + STARTING_LEGEND.push([ch, EMPTY_BITMAP]); + } + CUSTOM_LEGEND_CHARS.push(row); +} + +const HOLES = [ + {x: 2, y: 1, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 3, y: 1, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 1, y: 2, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 2, y: 2, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 3, y: 2, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 4, y: 2, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 2, y: 3, type: -1, bonking: false, missedBonk: false, popupTime: -1}, + {x: 3, y: 3, type: -1, bonking: false, missedBonk: false, popupTime: -1}, +] + +const CURRENT_ANIMATIONS_LEGEND = []; + +function updateAnimations() { + setLegend(...CURRENT_ANIMATIONS_LEGEND, ...CORE_LEGEND); +} + +function popup(holeIndex, typeIndex) { + const hole = HOLES[holeIndex]; + x = hole.x; + y = hole.y; + hole.type = typeIndex; + hole.popupTime = Date.now(); + + const LEGEND_ARRAY = [getLegendChar(x, y), MONSTERS[typeIndex][0]]; + CURRENT_ANIMATIONS_LEGEND.push(LEGEND_ARRAY); + + setTimeout(() => { + if (!hole.bonking) { + LEGEND_ARRAY[1] = MONSTERS[typeIndex][1]; + updateAnimations(); + } + }, 50); + setTimeout(() => { + if (!hole.bonking) { + LEGEND_ARRAY[1] = MONSTERS[typeIndex][2]; + updateAnimations(); + } + }, 100); + setTimeout(() => { + if (!hole.bonking) { + LEGEND_ARRAY[1] = MONSTERS[typeIndex][3]; + updateAnimations(); + // remove the animation from the animation legend, it will stop re-rendering + CURRENT_ANIMATIONS_LEGEND.splice(CURRENT_ANIMATIONS_LEGEND.indexOf(LEGEND_ARRAY), 1); + } + }, 200); +} + +function bonk(holeIndex) { + const hole = HOLES[holeIndex]; + + if (hole.bonking || hole.missedBonk) { + return + } + + const x = hole.x; + const y = hole.y; + + // if they mis-bonk an empty hole + if (hole.type == -1) { + hole.missedBonk = true; + const LEGEND_ARRAY = [getLegendChar(x, y), HAMMER]; + CURRENT_ANIMATIONS_LEGEND.unshift(LEGEND_ARRAY); + updateAnimations(); + + setTimeout(() => { + hole.missedBonk = false; + + LEGEND_ARRAY[1] = EMPTY_BITMAP; + updateAnimations(); + + CURRENT_ANIMATIONS_LEGEND.splice(CURRENT_ANIMATIONS_LEGEND.indexOf(LEGEND_ARRAY), 1); + }, 1000) + return; + } + + hole.bonking = true; + score += Math.max(100, 1000 - (Date.now() - hole.popupTime)); + drawStats(); + + const LEGEND_ARRAY = [getLegendChar(x, y), MONSTERS[hole.type][4]]; + CURRENT_ANIMATIONS_LEGEND.push(LEGEND_ARRAY); + updateAnimations(); + + setTimeout(() => { + LEGEND_ARRAY[1] = MONSTERS[hole.type][5]; + updateAnimations(); + }, 50); + setTimeout(() => { + LEGEND_ARRAY[1] = MONSTERS[hole.type][6]; + updateAnimations(); + }, 100); + setTimeout(() => { + LEGEND_ARRAY[1] = MONSTERS[hole.type][7]; + updateAnimations(); + }, 125); + setTimeout(() => { + LEGEND_ARRAY[1] = HAMMER; + updateAnimations(); + }, 150); + setTimeout(() => { + LEGEND_ARRAY[1] = EMPTY_BITMAP; + updateAnimations(); + CURRENT_ANIMATIONS_LEGEND.splice(CURRENT_ANIMATIONS_LEGEND.indexOf(LEGEND_ARRAY), 1); + hole.bonking = false; + hole.type = -1; + }, 750); +} + + +function mole() { + if (!gameRunning) return; + + let holeIndex = -1; + let attempts = 0; + // repeat until we get an unused hole + while (holeIndex < 0 || HOLES[holeIndex].type != -1) { + holeIndex = Math.floor(Math.random() * 8); + if (++attempts > 36) { + console.log("Holes are full!"); + return; + } + } + + popup(holeIndex, 0); + + // adjust the current timer and start time to hit the max speed before 'double time' starts + const adjustedStartTime = START_TIME - DOUBLE_TIME + const adjustedTimer = Math.max(timer - DOUBLE_TIME, DOUBLE_TIME); + const timeout = START_INTERVAL - (START_INTERVAL - END_INTERVAL) * ((adjustedStartTime - adjustedTimer)/ adjustedStartTime) + setTimeout(mole, timeout); +} + +function drawStats() { + clearText(); + + addText(timer.toString(), { x: 9, y: 1, color: color`2` }); + let scoreX = 6; + if (score >= 100) { + scoreX = 5; + } + addText("Score: " + score.toString(), {x: scoreX, y: 14, color: color`2` }); +} + + +// looks weird bc the ground is varied +const MAIN_MAP = map` +163181 +43RB49 +2RBRB2 +35RB47 +124324`; + +// stuff for the background that goes behind the text +const OVERLAY_LEGEND = [ + [getLegendChar(2, 0), OVERLAYS[0]], // left (behind timer) + [getLegendChar(3, 0), OVERLAYS[1]], // right (behind timer) + [getLegendChar(1, 4), OVERLAYS[2]], // left (behind score) + [getLegendChar(2, 4), OVERLAYS[4]], // center (behind score) + [getLegendChar(3, 4), OVERLAYS[4]], // center (behind score) + [getLegendChar(4, 4), OVERLAYS[3]], // right (behind score) +]; + +// TODO: title screen +var gameRunning = false; +const START_TIME = 60; +const START_INTERVAL = 3000; // starting time between moles +const END_INTERVAL = 500; // ending time between moles +const DOUBLE_TIME = 15 // when the timer hits this number, 2 moles appear at once +var timer; +var score = 0; + +function startGame() { + console.log("%cStarting Game", "color: blue; font-size:16px") + timer = START_TIME; + score = 0; + gameRunning = true; + + // the way this works is, it sets a map where each tile has a different sprite. then, those can be controlled indiviudally by setting the legend. + // it sets the map afterward by adding sprites 1 by 1. This way, the top layer of sprites can be controlled individually + // this is basically all just a workaround for the fact that adding a new sprite adds it at the bottom of the z-order stack + setLegend(...CORE_LEGEND, ...STARTING_LEGEND, ...OVERLAY_LEGEND); + setMap(MAIN_MAP); + for (let x = 0; x < 6; x++) { + for (let y = 0; y < 5; y++) { + addSprite(x, y, CUSTOM_LEGEND_CHARS[y][x]); + } + } + + drawStats(); + const timerInterval = setInterval(() => { + timer--; + if (timer == 0) { + clearInterval(timerInterval) + endGame(); + }; + + clearText(); + drawStats(); + }, 1000) + + mole(); + // when the timer hits DOUBLE_TIME, 2 moles appear at once + setTimeout(mole, (timer - DOUBLE_TIME) * 1000) +} + +function endGame() { + gameRunning = false; + console.log(gameOverLegend) + setLegend(...gameOverLegend); + setMap(gameOverMap); + + clearText(); + let scoreX = 6; + if (score >= 100) { + scoreX = 5; + } + addText("Score: " + score.toString(), {x: scoreX, y: 12, color: color`2` }); +} + +startGame(); + +onInput("w", () => bonk(0)); +onInput("a", () => bonk(2)); +onInput("s", () => bonk(6)); +onInput("d", () => bonk(4)); +onInput("i", () => bonk(1)); +onInput("j", () => bonk(3)); +onInput("k", () => bonk(7)); +onInput("l", () => bonk(5));