diff --git a/js/Makefile b/js/Makefile index 1ef7d05..d55a57e 100644 --- a/js/Makefile +++ b/js/Makefile @@ -1,5 +1,7 @@ -MAPS=$(wildcard ../maps/flood*.map) +MAPS= +MAPS+=$(wildcard ../maps/trampoline*.map) +MAPS+=$(wildcard ../maps/flood*.map) MAPS+=$(wildcard ../maps/contest?.map ../maps/contest10.map) MAPS+=$(wildcard ../maps/ems*.map) MAPS+=../maps/pacman.map ../maps/pacman2.map diff --git a/js/gui.js b/js/gui.js index 17d5995..6792f97 100644 --- a/js/gui.js +++ b/js/gui.js @@ -1,4 +1,4 @@ -var mineGui_mine, mineGui_curmap, mineGui_curndx, mineGui_moves = ""; +var mineGui_mine = false, mineGui_curmap, mineGui_curndx, mineGui_moves = ""; var mineGui_movesBackup = []; var mineGui_customNdx = 1; var mineGui_canvas = true; @@ -14,7 +14,9 @@ var mineGui_spriteOffset = { 'L': 3, 'O': 4, '.': 0, - ' ': 1 + ' ': 1, + 'A': 8,'B': 8,'C': 8,'D': 8,'E': 8,'F': 8,'G': 8,'H': 8,'I': 8, + '1': 9,'2': 9,'3': 9,'4': 9,'5': 9,'6': 9,'7': 9,'8': 9,'9': 9 }; var mineGui_images = {}; @@ -192,7 +194,8 @@ function mineGui_updateMine() { } function mineGui_show() { - var waterLevel = Math.max(mineGui_mine.meta.Water, 0); + if (!mineGui_mine) return; + var waterLevel = Math.max(mineGui_mine.water_level, 0); var map = mineGui_mine.toString().split(/\n/); var canv = document.getElementById("mineGui_mineCanvas"); var mapNode = document.getElementById("mineGui_mineMap"); diff --git a/js/maps.js b/js/maps.js index 5e50cbb..757a86a 100644 --- a/js/maps.js +++ b/js/maps.js @@ -1,2 +1,2 @@ -var mineMaps = {"flood1":"###########\n#....R....#\n#.*******.#\n#.\\\\\\\\\\\\\\.#\n#. .#\n#..*\\\\\\*..#\n#.#*\\\\\\*#.#\n#########L#\n\nWater 1\nFlooding 8 \nWaterproof 5\nHighscore 945\n","flood2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nFlooding 5\nWaterproof 3\nHighscore 281\n","flood3":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nWaterproof 10 \nFlooding 10\nWater 2\nHighscore 1303\n","flood4":"########################\n#.....................\\#\n#......*\\ ...........#\n#......*... ......* ...#\n#.. \\\\... .*..... ...#\n#.. ....... ....... ...#\n#.. ....... .\\\\.... ...# ######\n#. .... .....\\...# #\\\\\\\\#\n#\\\\\\......... .........# #....#\n########### R ########*#####\n #.......... ........***\\\\\\#\n #.......... ............**#\n #.......... ......... *.*\\#\n #....\\\\.... ....\\\\..... ..L\n #.....................****#\n #........\\*...............#\n #........... .........#\n #.........................#\n ###########################\n\nWater 1\nFlooding 20\nWaterproof 10\nHighscore 1592\n","flood5":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nWater 2\nFlooding 11\nWaterproof 5\nHighscore 575\n","contest1":"######\n#. *R#\n# \\.#\n#\\ * #\nL .\\#\n######\n\nHighscore 212\n","contest2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nHighscore 281\n","contest3":"########\n#..R...#\n#..*...#\n#..#...#\n#.\\.\\..L\n####**.#\n#\\.....#\n#\\..* .#\n########\n\nHighscore 275\n","contest4":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nHighscore 575\n","contest5":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nHighscore 1303\n","contest6":"###############\n#\\\\\\.......** #\n#\\\\#.#####...##\n#\\\\#.....*##. #\n#\\#####\\...## #\n#\\......####* #\n#\\.######* #.\\#\n#\\.#. *...##.##\n#\\##. .. *...#\n#\\...... L#.#.#\n###########.#.#\n#\\..........#.#\n##.##########.#\n#R.#\\.........#\n###############\n\nHighscore 1177\n","contest7":" #######\n ## *#\n ##R *##\n ##\\\\\\\\##\n ##....##\n ##..\\ . ##\n ## . L . ##\n ##\\\\\\# #\\\\\\\\##\n ###### #######\n\nHighscore 869\n","contest8":"##############\n#\\\\... ......#\n###.#. ...*..#\n #.#. ... ..#\n### #. \\ ..#\n#. .#..... **#######\n#.#\\#..... ..\\\\\\*. #\n#*\\\\#.###. ####\\\\\\ #\n#\\\\.#. ...## \\ #\n#\\#.#..... ....# \\ # \n###.#..... ....# ##\n#\\\\.#..... ....#\\ # \n########.. ..###*####\n#......... .........#\n#......... ....***..#\n#..\\\\\\\\\\ # ####.....#\n#........*R..\\\\\\ .#\n##########L##########\n\nHighscore 1973\n","contest9":" #L#######\n #*** \\\\ #\n #\\\\\\ .. #\n#########.## ##########\n#.......\\ ..........* .#\n#*******\\......#....#\\\\ .#\n###\\.\\\\\\...**..#....... *#\n#*****\\\\ .\\\\..## #\\.#\n######### .... ##########\n # #\n ####*#### \n #.......#\n######### \\\\\\\\*##########\n#*\\\\ **# *..*\\ \\\\\\\\\\#\n#.\\**\\*** .....**.# \\\\##\\#\n#\\R...... .\\\\.. \\\\\\\\\\#\n##########################\n\nHighscore 3093\n","contest10":"#############################\n#..........................\\#\n#..\\\\###...#.... ###.#\n#..\\*\\\\\\.. #.... ..##\\\\..\\#.#\n#..\\*\\.... #.... ..#\\#....#.#\n#...\\###.. #.... ....#....#.#\n#... ..... ..... .####......#\n#\\\\. #.... .......#\n#... #..#. .....*\\ ##.......#\n#.#....... ...#.. ....######\n#. ...#... ...#.\\ ....#..* #\n##........ ...#.. #....#.#\\\\#\n#.....*... .....*\\#\\\\.....*.#\n#.***.* .......*\\****.....#.#\n#.\\\\\\.. ................ .#\n#.##### .###### ##### #\n#....\\\\.................... #\n#....****...#.##.....\\\\\\\\..\\#\n#....\\\\\\\\...#.........*....\\#\n#....\\\\\\\\...#.\\\\. #\\###.\\#\n#.... ..#.... ...#\\\\\\\\. #\n#........ ..#.... ...#..... #\n#........ ........#R#\n###########################L#\n\nHighscore 3634\n","ems1":"#######\n#L\\\\\\##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n## ##\n## ##\n##R ##\n## # ##\n#\\ # \\#\n## # ##\n## # ##\n## # ##\n## # ##\n#######\n\nAuthor ems_ (irc)\nHighscore 334\n","ems2":"#########\n###***###\n###***###\n###***###\n###***###\n###***###\n###***###\n# .**\\\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# .#\\#\n### **#\n### R \\\\#\n### #L#\n### ###\n### ###\n### ###\n### ###\n### ###\n### ###\n#########\n\nAuthor ems_ (irc)\nHighscore 691\n","ems3":"################\n#\\.****####\\#*##\n#\\.\\\\\\\\.***...##\n##*####.#*###..#\n#\\.R....#...##\\#\n#\\ ####...#.#*.#\n#\\ **######.#..#\n##...\\\\\\\\\\\\...##\n#L.##########.##\n################\n\nAuthor ems_ (irc)\nHighscore 1199\n","ems3v2":"################\n#\\.****####\\#*##\n#\\.\\\\\\\\.***...##\n##*####.#*###..#\n#\\.R....#...##\\#\n#\\ ####...#.#*.#\n#\\ **######.#..#\n##...\\\\\\\\\\\\...##\n#L.#\\########.##\n################\n\nAuthor ems_ (irc)\nHighscore 1272\n","ems4":"#########\n#* L#\n#\\ #\n#\\\\ #\n##\\\\ #\n###\\\\ #\n####\\\\ #\n#####\\\\ #\n####### #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n# #*#*# #\n# R* * #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n###*#*#.#\n#\\. . #\\#\n### # ###\n### # ###\n## # ##\n## # ##\n## # ##\n## # ##\n## # ##\n#########\n\nAuthor ems_ (irc)\nHighscore 908\n","ems5":"###################\n#************* ##\n##***********# * ##\n###*********##.*.##\n####*******####*###\n#####*****#####*###\n######***######*###\n#######*#######*###\n###### * ######*###\n#\\ . #*###\n#\\ \\ #*###\n#\\ ** #*###\n#\\ ## #*###\n#\\ #*###\n#\\ \\ \\ #*###\n#\\ ** ** #*###\n#\\ ## ## #*###\n#\\ #*###\n#\\ \\ \\ \\ #*###\n#R ** ** ** #*\\##\n#### ## ## ## #*###\n###L . ##\n#### ## ## ## ## #\n### # ## # # #\n### # ## # # #\n### # ## # # #\n###################\n\nAuthor ems_ (irc)\nHighscore 897\n","ems5v2":"###################\n#************* ##\n##***********# * ##\n###*********##.*.##\n####*******####*###\n#####*****#####*###\n######***######*###\n#######*#######*###\n###### * ######*###\n#\\ . #*###\n#\\ \\ #*###\n#\\ ** #*###\n#\\ ## #*###\n#\\ #*###\n#\\ \\ \\ #*###\n#\\ ** ** #*###\n#\\ ## ## #*###\n#\\ #*###\n#\\ \\ \\ \\ #*###\n#R ** ** ** #*\\##\n#### ## ## ## #*###\n#### . ##\n#### ## ## ## ## ##\n## ## # # # #\n## * L# #\\ # # *#\n## ## # \\ # ## #\n## #### # \\# \\# #\n###################\n\nAuthor ems_ (irc)\nHighscore 1144\n","ems6":"###########################\n#............R............#\n#.####.######L######.####.#\n#.####.#*#########*#.####.#\n#.####..\\#*******#\\..####.#\n#.######..\\\\\\\\\\\\\\..######.#\n#.####*######.######*####.#\n#.####\\.....#.#.....\\####.#\n#......####.#.#.####....#.#\n#####.#***#.#.#.#***#.#.#.#\n#......\\\\\\..#.#..\\\\\\..#.#.#\n#.#########*****#####.#.#.#\n#..........\\\\\\\\\\......#...#\n###########################\n\nAuthor ems_ (irc)\nWater 7\nWaterproof 42\nHighscore 1414\n","pacman":"###########################\n#............#............#\n#.####.#####.#.#####.####.#\n#\\# #.# #.#.# #.# #\\#\n#.####.#####.#.#####.####.#\n#.........................#\n#.####.#.#########.#.####.#\n#......#.....#.....#......#\n######.#####.#.#####.######\n #.# #.#\n######.# #### #### #.######\nL . # # . **\n######.# ######### #.######\n #.# #.#\n######.# ######### #.######\n#............#............#\n#.####.#####.#.#####.####.#\n#\\...#. R .#...\\#\n####.#.#.#########.#.#.####\n#......#.....#.....#......#\n#.##########.#.##########.#\n#.........................#\n###########################\n\nAuthor newsham (www.thenewsh.com/~newsham/x/pacman.map)\nHighscore 191\n","pacman2":"###########################\n#\\\\\\\\\\\\\\\\\\\\\\\\#\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#####\\#\\#####\\####\\#\n#.# #\\# #\\#\\# #\\# #.#\n#\\####\\#####\\#\\#####\\####\\#\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#\\#########\\#\\####\\#\n#\\\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\\\#\n######\\#####\\#\\#####\\######\n #\\# #\\#\n######\\# #### #### #\\######\nL \\ # # \\ **\n######\\# ######### #\\######\n #\\# #\\#\n######\\# ######### #\\######\n#\\\\\\\\\\\\\\\\\\\\\\\\#\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#####\\#\\#####\\####\\#\n#.\\\\\\#\\ R \\#\\\\\\.#\n####\\#\\#\\#########\\#\\#\\####\n#\\\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\\\#\n#\\##########\\#\\##########\\#\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n###########################\n\nHighscore 15039\n"}; +var mineMaps = {"trampoline1":"############\n#..*.R..*..#\n#..A....B..######\n#....2.. ..#\\\\\\C#\n#......* *.#\\\\\\1#\n########L########\n\nTrampoline A targets 1\nTrampoline B targets 1\nTrampoline C targets 2\n","trampoline2":" ######\n #....#\n #.**.#\n #.**.#\n #.**.#\n######.\\\\.######\n#**....*.......#\n#\\\\....L\\\\\\....#\n#A......*****..#\n######R.....###########\n ###.....*.....\\\\\\#\n #\\\\\\\\#..1...\\\\\\#\n #\\\\\\\\#......\\\\\\#\n ################\n\nTrampoline A targets 1\n","trampoline3":"#######################################\n#****................#..1...\\\\\\\\\\\\\\B..#\n#R.......##############################\n#.. ..................................#\n#.. ........ \\ ......#\n#.. .*. ....**.*...#....... ..........#\n#.. ... ....\\\\\\\\...#.A..... ..........#\n#.. ... ....\\ .....#....... * \\\\..#\n#.. ... ....\\......#....... ..........#\n#.. ... ....\\......#....... ..........#\n#.. ... ...........#................**#\n#..\\\\\\\\\\...........#................\\\\#\n########### ############## ############\n#...*.................................#\n#....*.................. ......#\n#... .*....*.............. ..... .....#\n#....*2*........########.. ..... .....L\n#...*...*.......#\\\\\\#..... ...*.......#\n#.....\\\\\\.......#\\\\\\#....**..***......#\n#.... .......#\\\\\\#*................#\n#...............#\\\\\\#*...**...*.......#\n#...............#.....................#\n###### ############## ### #######\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n#######################################\n\nTrampoline A targets 1\nTrampoline B targets 2\n\n","flood1":"###########\n#....R....#\n#.*******.#\n#.\\\\\\\\\\\\\\.#\n#. .#\n#..*\\\\\\*..#\n#.#*\\\\\\*#.#\n#########L#\n\nWater 1\nFlooding 8 \nWaterproof 5\nHighscore 945\n","flood2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nFlooding 5\nWaterproof 3\nHighscore 281\n","flood3":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nWaterproof 10 \nFlooding 10\nWater 2\nHighscore 1303\n","flood4":"########################\n#.....................\\#\n#......*\\ ...........#\n#......*... ......* ...#\n#.. \\\\... .*..... ...#\n#.. ....... ....... ...#\n#.. ....... .\\\\.... ...# ######\n#. .... .....\\...# #\\\\\\\\#\n#\\\\\\......... .........# #....#\n########### R ########*#####\n #.......... ........***\\\\\\#\n #.......... ............**#\n #.......... ......... *.*\\#\n #....\\\\.... ....\\\\..... ..L\n #.....................****#\n #........\\*...............#\n #........... .........#\n #.........................#\n ###########################\n\nWater 1\nFlooding 20\nWaterproof 10\nHighscore 1592\n","flood5":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nWater 2\nFlooding 11\nWaterproof 5\nHighscore 575\n","contest1":"######\n#. *R#\n# \\.#\n#\\ * #\nL .\\#\n######\n\nHighscore 212\n","contest2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nHighscore 281\n","contest3":"########\n#..R...#\n#..*...#\n#..#...#\n#.\\.\\..L\n####**.#\n#\\.....#\n#\\..* .#\n########\n\nHighscore 275\n","contest4":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nHighscore 575\n","contest5":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nHighscore 1303\n","contest6":"###############\n#\\\\\\.......** #\n#\\\\#.#####...##\n#\\\\#.....*##. #\n#\\#####\\...## #\n#\\......####* #\n#\\.######* #.\\#\n#\\.#. *...##.##\n#\\##. .. *...#\n#\\...... L#.#.#\n###########.#.#\n#\\..........#.#\n##.##########.#\n#R.#\\.........#\n###############\n\nHighscore 1177\n","contest7":" #######\n ## *#\n ##R *##\n ##\\\\\\\\##\n ##....##\n ##..\\ . ##\n ## . L . ##\n ##\\\\\\# #\\\\\\\\##\n ###### #######\n\nHighscore 869\n","contest8":"##############\n#\\\\... ......#\n###.#. ...*..#\n #.#. ... ..#\n### #. \\ ..#\n#. .#..... **#######\n#.#\\#..... ..\\\\\\*. #\n#*\\\\#.###. ####\\\\\\ #\n#\\\\.#. ...## \\ #\n#\\#.#..... ....# \\ # \n###.#..... ....# ##\n#\\\\.#..... ....#\\ # \n########.. ..###*####\n#......... .........#\n#......... ....***..#\n#..\\\\\\\\\\ # ####.....#\n#........*R..\\\\\\ .#\n##########L##########\n\nHighscore 1973\n","contest9":" #L#######\n #*** \\\\ #\n #\\\\\\ .. #\n#########.## ##########\n#.......\\ ..........* .#\n#*******\\......#....#\\\\ .#\n###\\.\\\\\\...**..#....... *#\n#*****\\\\ .\\\\..## #\\.#\n######### .... ##########\n # #\n ####*#### \n #.......#\n######### \\\\\\\\*##########\n#*\\\\ **# *..*\\ \\\\\\\\\\#\n#.\\**\\*** .....**.# \\\\##\\#\n#\\R...... .\\\\.. \\\\\\\\\\#\n##########################\n\nHighscore 3093\n","contest10":"#############################\n#..........................\\#\n#..\\\\###...#.... ###.#\n#..\\*\\\\\\.. #.... ..##\\\\..\\#.#\n#..\\*\\.... #.... ..#\\#....#.#\n#...\\###.. #.... ....#....#.#\n#... ..... ..... .####......#\n#\\\\. #.... .......#\n#... #..#. .....*\\ ##.......#\n#.#....... ...#.. ....######\n#. ...#... ...#.\\ ....#..* #\n##........ ...#.. #....#.#\\\\#\n#.....*... .....*\\#\\\\.....*.#\n#.***.* .......*\\****.....#.#\n#.\\\\\\.. ................ .#\n#.##### .###### ##### #\n#....\\\\.................... #\n#....****...#.##.....\\\\\\\\..\\#\n#....\\\\\\\\...#.........*....\\#\n#....\\\\\\\\...#.\\\\. #\\###.\\#\n#.... ..#.... ...#\\\\\\\\. #\n#........ ..#.... ...#..... #\n#........ ........#R#\n###########################L#\n\nHighscore 3634\n","ems1":"#######\n#L\\\\\\##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n## ##\n## ##\n##R ##\n## # ##\n#\\ # \\#\n## # ##\n## # ##\n## # ##\n## # ##\n#######\n\nAuthor ems_ (irc)\nHighscore 334\n","ems2":"#########\n###***###\n###***###\n###***###\n###***###\n###***###\n###***###\n# .**\\\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# .#\\#\n### **#\n### R \\\\#\n### #L#\n### ###\n### ###\n### ###\n### ###\n### ###\n### ###\n#########\n\nAuthor ems_ (irc)\nHighscore 691\n","ems3":"################\n#\\.****####\\#*##\n#\\.\\\\\\\\.***...##\n##*####.#*###..#\n#\\.R....#...##\\#\n#\\ ####...#.#*.#\n#\\ **######.#..#\n##...\\\\\\\\\\\\...##\n#L.##########.##\n################\n\nAuthor ems_ (irc)\nHighscore 1199\n","ems3v2":"################\n#\\.****####\\#*##\n#\\.\\\\\\\\.***...##\n##*####.#*###..#\n#\\.R....#...##\\#\n#\\ ####...#.#*.#\n#\\ **######.#..#\n##...\\\\\\\\\\\\...##\n#L.#\\########.##\n################\n\nAuthor ems_ (irc)\nHighscore 1272\n","ems4":"#########\n#* L#\n#\\ #\n#\\\\ #\n##\\\\ #\n###\\\\ #\n####\\\\ #\n#####\\\\ #\n####### #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n# #*#*# #\n# R* * #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n###*#*#.#\n#\\. . #\\#\n### # ###\n### # ###\n## # ##\n## # ##\n## # ##\n## # ##\n## # ##\n#########\n\nAuthor ems_ (irc)\nHighscore 908\n","ems5":"###################\n#************* ##\n##***********# * ##\n###*********##.*.##\n####*******####*###\n#####*****#####*###\n######***######*###\n#######*#######*###\n###### * ######*###\n#\\ . #*###\n#\\ \\ #*###\n#\\ ** #*###\n#\\ ## #*###\n#\\ #*###\n#\\ \\ \\ #*###\n#\\ ** ** #*###\n#\\ ## ## #*###\n#\\ #*###\n#\\ \\ \\ \\ #*###\n#R ** ** ** #*\\##\n#### ## ## ## #*###\n###L . ##\n#### ## ## ## ## #\n### # ## # # #\n### # ## # # #\n### # ## # # #\n###################\n\nAuthor ems_ (irc)\nHighscore 897\n","ems5v2":"###################\n#************* ##\n##***********# * ##\n###*********##.*.##\n####*******####*###\n#####*****#####*###\n######***######*###\n#######*#######*###\n###### * ######*###\n#\\ . #*###\n#\\ \\ #*###\n#\\ ** #*###\n#\\ ## #*###\n#\\ #*###\n#\\ \\ \\ #*###\n#\\ ** ** #*###\n#\\ ## ## #*###\n#\\ #*###\n#\\ \\ \\ \\ #*###\n#R ** ** ** #*\\##\n#### ## ## ## #*###\n#### . ##\n#### ## ## ## ## ##\n## ## # # # #\n## * L# #\\ # # *#\n## ## # \\ # ## #\n## #### # \\# \\# #\n###################\n\nAuthor ems_ (irc)\nHighscore 1144\n","ems6":"###########################\n#............R............#\n#.####.######L######.####.#\n#.####.#*#########*#.####.#\n#.####..\\#*******#\\..####.#\n#.######..\\\\\\\\\\\\\\..######.#\n#.####*######.######*####.#\n#.####\\.....#.#.....\\####.#\n#......####.#.#.####....#.#\n#####.#***#.#.#.#***#.#.#.#\n#......\\\\\\..#.#..\\\\\\..#.#.#\n#.#########*****#####.#.#.#\n#..........\\\\\\\\\\......#...#\n###########################\n\nAuthor ems_ (irc)\nWater 7\nWaterproof 42\nHighscore 1414\n","pacman":"###########################\n#............#............#\n#.####.#####.#.#####.####.#\n#\\# #.# #.#.# #.# #\\#\n#.####.#####.#.#####.####.#\n#.........................#\n#.####.#.#########.#.####.#\n#......#.....#.....#......#\n######.#####.#.#####.######\n #.# #.#\n######.# #### #### #.######\nL . # # . **\n######.# ######### #.######\n #.# #.#\n######.# ######### #.######\n#............#............#\n#.####.#####.#.#####.####.#\n#\\...#. R .#...\\#\n####.#.#.#########.#.#.####\n#......#.....#.....#......#\n#.##########.#.##########.#\n#.........................#\n###########################\n\nAuthor newsham (www.thenewsh.com/~newsham/x/pacman.map)\nHighscore 191\n","pacman2":"###########################\n#\\\\\\\\\\\\\\\\\\\\\\\\#\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#####\\#\\#####\\####\\#\n#.# #\\# #\\#\\# #\\# #.#\n#\\####\\#####\\#\\#####\\####\\#\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#\\#########\\#\\####\\#\n#\\\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\\\#\n######\\#####\\#\\#####\\######\n #\\# #\\#\n######\\# #### #### #\\######\nL \\ # # \\ **\n######\\# ######### #\\######\n #\\# #\\#\n######\\# ######### #\\######\n#\\\\\\\\\\\\\\\\\\\\\\\\#\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#####\\#\\#####\\####\\#\n#.\\\\\\#\\ R \\#\\\\\\.#\n####\\#\\#\\#########\\#\\#\\####\n#\\\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\\\#\n#\\##########\\#\\##########\\#\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n###########################\n\nHighscore 15039\n"}; if (typeof exports !== "undefined") {exports.maps = mineMaps;} diff --git a/js/mine.js b/js/mine.js index 2d3d08b..9d845b3 100644 --- a/js/mine.js +++ b/js/mine.js @@ -2,14 +2,6 @@ var Mine = function() { var ALIVE = 0, LOST = 1, ABORTED = 2, WON = 3; - function defaultMeta() { - return { - Water: 0, - Flooding: 0, - Waterproof: 10, - } - } - function repeat(str, n) { return new Array(n+1).join(str); } @@ -45,7 +37,18 @@ var Mine = function() { this.moves = 0; this.score = 0; this.moves_below_water = 0; + this.water = { + level: 0, + flooding: 0, + proof: 10 + }; + this.lift = this.robot = false; + this.trampoline = { + sources: { }, // x, y and target + targets: { }, // x, y and sources + }; + this.trampoline.targets = {}; for (i = 0; i < height; ++i) { // padding if (map[i].length < width) map[i] += repeat(' ', width - map[i].length); @@ -70,6 +73,18 @@ var Mine = function() { if (this.robot !== false) throw "Only one robot is allowed"; this.robot = { x: x, y: i }; break; + default: + if (line[x] >= 'A' && line[x] <= 'I') { + if (this.trampoline.sources[line[x]]) throw "Can have only one trampoline " + line[x]; + this.trampoline.sources[line[x]] = { x: x, y: i, target: false }; + this.trampoline.fromSources + } else if (line[x] >= '1' && line[x] <= '9') { + if (this.trampoline.targets[line[x]]) throw "Can have only one trampoline target " + line[x]; + this.trampoline.targets[line[x]] = { x: x, y: i, sources: [] }; + } else { + throw "Invalid character in map: '" + line[x] + "'"; + } + break; } } } @@ -78,12 +93,49 @@ var Mine = function() { if (this.robot === false) throw "Need a robot"; // meta data - this.meta = defaultMeta(); + this.meta = {}; for (i = 0; i < lines.length; ++i) { if (0 == lines[i].length) continue; - pair = lines[i].split(/ +/); - this.meta[pair[0]] = pair.splice(1).join(" "); + var words = lines[i].split(/ +/); + switch (words[0]) { + case 'Water': + this.water.level = words[1]; + break; + case 'Flooding': + this.water.flooding = words[1]; + break; + case 'Waterproof': + this.water.proof = words[1]; + break; + case 'Trampoline': + if (words.length !== 4 || words[2] !== 'targets') + throw "Invalid trampoline: '" + words.join(" ") +"'"; + if (words[1].length != 1 || words[1] < 'A' || words[1] > 'I') + throw "Invalid trampoline source '" + words[1] +"'"; + if (words[3].length != 1 || words[3] < '1' || words[3] > '9') + throw "Invalid trampoline target '" + words[3] +"'"; + if (!this.trampoline.sources[words[1]]) throw "Trampoline " + words[1] + " not defined"; + if (!this.trampoline.targets[words[3]]) throw "Trampoline target " + words[3] + " not defined"; + if (this.trampoline.sources[words[1]].target) throw "Trampoline " + words[1] + " already has a target"; + this.trampoline.sources[words[1]].target = words[3]; + this.trampoline.targets[words[3]].sources.push(words[1]); + break; + default: + this.meta[words[0]] = words.splice(1).join(" "); + break; + } } + for (i in this.trampoline.sources) { + if (this.trampoline.sources.hasOwnProperty(i)) { + if (!this.trampoline.sources[i].target) throw "Trampoline " + i + " has no target"; + } + } + for (i in this.trampoline.targets) { + if (this.trampoline.targets.hasOwnProperty(i)) { + if (0 == this.trampoline.targets[i].sources.length) throw "Trampoline target " + i + " has no sources"; + } + } + this.water_level = this.water.level; this.state = ALIVE; }; @@ -94,7 +146,7 @@ var Mine = function() { Mine.prototype.validMove = function (command) { if (this.state != ALIVE) return false; - var n; + var n, c; command = command.toUpperCase(); switch (command) { case 'L': @@ -102,7 +154,8 @@ var Mine = function() { n = (command == 'L' ? -1 : 1); if (this.robot.x + n < 0) return false; if (this.robot.x + n >= this.width) return false; - switch (this.map[this.robot.y][this.robot.x+n]) { + c = this.map[this.robot.y][this.robot.x+n]; + switch (c) { case '#': return false; case ' ': case '.': @@ -113,6 +166,9 @@ var Mine = function() { if (this.robot.x + 2*n < 0) return false; if (this.robot.x + 2*n >= this.width) return false; if (' ' == this.map[this.robot.y][this.robot.x+2*n]) return true; + default: + if (this.trampoline.sources.hasOwnProperty(c)) return true; + break; } break; case 'U': @@ -120,7 +176,8 @@ var Mine = function() { n = (command == 'D' ? -1 : 1); if (this.robot.y + n < 0) return false; if (this.robot.y + n >= this.height) return false; - switch (this.map[this.robot.y+n][this.robot.x]) { + c = this.map[this.robot.y+n][this.robot.x]; + switch (c) { case '#': return false; case ' ': case '.': @@ -128,7 +185,10 @@ var Mine = function() { case 'L': return false; case 'O': return true; case '*': return false; - " style="} + default: + if (this.trampoline.sources.hasOwnProperty(c)) return true; + break; + } break; case 'W': case 'A': @@ -139,7 +199,7 @@ var Mine = function() { Mine.prototype.move = function(command) { if (this.state != ALIVE) return false; - var n; + var n, c, s, t; command = command.toUpperCase(); if (this.validMove(command)) { switch (command.toUpperCase()) { @@ -147,7 +207,8 @@ var Mine = function() { case 'R': n = (command == 'L' ? -1 : 1); this.map[this.robot.y][this.robot.x] = ' '; - switch (this.map[this.robot.y][this.robot.x+n]) { + c = this.map[this.robot.y][this.robot.x+n]; + switch (c) { case '*': this.map[this.robot.y][this.robot.x+2*n] = '*'; break; @@ -158,6 +219,18 @@ var Mine = function() { case 'O': this._foundLift(); break; + default: + if (this.trampoline.sources.hasOwnProperty(c)) { + s = this.trampoline.sources[c]; + t = this.trampoline.targets[s.target]; + for (n = 0; n < t.sources.length; ++n) { + s = this.trampoline.sources[t.sources[n]]; + this.map[s.y][s.x] = ' '; + } + this.robot.x = t.x; + this.robot.y = t.y; + n = 0; + } } this.robot.x += n; this.map[this.robot.y][this.robot.x] = 'R'; @@ -166,7 +239,8 @@ var Mine = function() { case 'D': n = (command == 'D' ? -1 : 1); this.map[this.robot.y][this.robot.x] = ' '; - switch (this.map[this.robot.y+n][this.robot.x]) { + c = this.map[this.robot.y+n][this.robot.x]; + switch (c) { case '\\': this.lambdas--; this.found_lambdas++; @@ -174,6 +248,18 @@ var Mine = function() { case 'O': this._foundLift(); break; + default: + if (this.trampoline.sources.hasOwnProperty(c)) { + s = this.trampoline.sources[c]; + t = this.trampoline.targets[s.target]; + for (n = 0; n < t.sources.length; ++n) { + s = this.trampoline.sources[t.sources[n]]; + this.map[s.y][s.x] = ' '; + } + this.robot.x = t.x; + this.robot.y = t.y; + n = 0; + } } this.robot.y += n; this.map[this.robot.y][this.robot.x] = 'R'; @@ -185,7 +271,9 @@ var Mine = function() { } this.moves++; if (0 == this.lambdas) { - if (false !== this.lift) this.map[this.lift.y][this.lift.x] = 'O'; + if (false !== this.lift && 'L' == this.map[this.lift.y][this.lift.x]) { + this.map[this.lift.y][this.lift.x] = 'O'; + } } var newMap = [], x, y, below; @@ -216,14 +304,14 @@ var Mine = function() { } this.map = newMap; - if (this.robot.y < this.meta['Water']) { + if (this.robot.y < this.water_level) { this.moves_below_water++; - if (this.moves_below_water > this.meta['Waterproof']) this._drown(); + if (this.moves_below_water > this.water.proof) this._drown(); } else { this.moves_below_water = 0; } - if (this.meta['Flooding'] > 0 && 0 == (this.moves % this.meta['Flooding'])) { - this.meta['Water']++; + if (this.water.flooding > 0 && 0 == (this.moves % this.water.flooding)) { + ++this.water_level; } switch (this.state) { @@ -274,12 +362,24 @@ var Mine = function() { Mine.prototype.metaText = function() { var k, keys = [], lines = []; + if (this.water.level != 0) lines.push("Water " + this.water.level); + if (this.water.flooding != 0) lines.push("Flooding " + this.water.flooding); + if (this.water.proof != 10) lines.push("Waterproof " + this.water.proof); + for (k in this.trampoline.sources) { + if (this.trampoline.sources.hasOwnProperty(k)) keys.push(k); + } + keys.sort(); + for (k = 0; k < keys.length; ++k) { + lines.push("Trampoline " + keys[k] + " targets " + this.trampoline.sources[keys[k]].target); + } + + keys = []; for (k in this.meta) { if (this.meta.hasOwnProperty(k)) keys.push(k); } keys.sort(); for (k = 0; k < keys.length; ++k) { - lines[k] = keys[k] + " " + this.meta[keys[k]]; + lines.push( keys[k] + " " + this.meta[keys[k]]); } return lines.join("\n"); }; diff --git a/js/sprites.png b/js/sprites.png new file mode 100644 index 0000000..6fd4079 Binary files /dev/null and b/js/sprites.png differ diff --git a/js/target.png b/js/target.png new file mode 100644 index 0000000..d1cfc24 Binary files /dev/null and b/js/target.png differ diff --git a/js/trampoline.png b/js/trampoline.png new file mode 100644 index 0000000..f11fecb Binary files /dev/null and b/js/trampoline.png differ diff --git a/maps/ems6.map b/maps/ems6.map new file mode 100644 index 0000000..7e2d78c --- /dev/null +++ b/maps/ems6.map @@ -0,0 +1,19 @@ +########################### +#............R............# +#.####.######L######.####.# +#.####.#*#########*#.####.# +#.####..\#*******#\..####.# +#.######..\\\\\\\..######.# +#.####*######.######*####.# +#.####\.....#.#.....\####.# +#......####.#.#.####....#.# +#####.#***#.#.#.#***#.#.#.# +#......\\\..#.#..\\\..#.#.# +#.#########*****#####.#.#.# +#..........\\\\\......#...# +########################### + +Author ems_ (irc) +Water 7 +Waterproof 42 +Highscore 1414 diff --git a/maps/solutions.txt b/maps/solutions.txt index 50ae872..9993a52 100644 --- a/maps/solutions.txt +++ b/maps/solutions.txt @@ -1,3 +1,5 @@ +trampoline1: RRLDDRRRRUULLDLLLURRRRRRDD (424) + flood1: LLLLDDRRLDRRDRRDLLUUURRRRRDDDD (945) flood2: RRUDRRULURULLLLDDDL (281) flood3: LLUURUUURUULRRRRRRRDDDDDDDLLRRUUUUULLLLLRDDDDDD (1303) diff --git a/maps/trampoline1.map b/maps/trampoline1.map new file mode 100644 index 0000000..c03b5bf --- /dev/null +++ b/maps/trampoline1.map @@ -0,0 +1,10 @@ +############ +#..*.R..*..# +#..A....B..###### +#....2.. ..#\\\C# +#......* *.#\\\1# +########L######## + +Trampoline A targets 1 +Trampoline B targets 1 +Trampoline C targets 2 diff --git a/maps/trampoline2.map b/maps/trampoline2.map new file mode 100644 index 0000000..f628a4b --- /dev/null +++ b/maps/trampoline2.map @@ -0,0 +1,16 @@ + ###### + #....# + #.**.# + #.**.# + #.**.# +######.\\.###### +#**....*.......# +#\\....L\\\....# +#A......*****..# +######R.....########### + ###.....*.....\\\# + #\\\\#..1...\\\# + #\\\\#......\\\# + ################ + +Trampoline A targets 1 diff --git a/maps/trampoline3.map b/maps/trampoline3.map new file mode 100644 index 0000000..58cb0e7 --- /dev/null +++ b/maps/trampoline3.map @@ -0,0 +1,29 @@ +####################################### +#****................#..1...\\\\\\\B..# +#R.......############################## +#.. ..................................# +#.. ........ \ ......# +#.. .*. ....**.*...#....... ..........# +#.. ... ....\\\\...#.A..... ..........# +#.. ... ....\ .....#....... * \\..# +#.. ... ....\......#....... ..........# +#.. ... ....\......#....... ..........# +#.. ... ...........#................**# +#..\\\\\...........#................\\# +########### ############## ############ +#...*.................................# +#....*.................. ......# +#... .*....*.............. ..... .....# +#....*2*........########.. ..... .....L +#...*...*.......#\\\#..... ...*.......# +#.....\\\.......#\\\#....**..***......# +#.... .......#\\\#*................# +#...............#\\\#*...**...*.......# +#...............#.....................# +###### ############## ### ####### +#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\# +####################################### + +Trampoline A targets 1 +Trampoline B targets 2 + diff --git a/specs/images/bricks.bmp b/specs/images/bricks.bmp new file mode 100644 index 0000000..bf27a8f Binary files /dev/null and b/specs/images/bricks.bmp differ diff --git a/specs/images/lambda.bmp b/specs/images/lambda.bmp new file mode 100644 index 0000000..8e75311 Binary files /dev/null and b/specs/images/lambda.bmp differ diff --git a/specs/images/lift.bmp b/specs/images/lift.bmp new file mode 100644 index 0000000..c40df88 Binary files /dev/null and b/specs/images/lift.bmp differ diff --git a/specs/images/miner.bmp b/specs/images/miner.bmp new file mode 100644 index 0000000..becd98c Binary files /dev/null and b/specs/images/miner.bmp differ diff --git a/specs/images/openlift.bmp b/specs/images/openlift.bmp new file mode 100644 index 0000000..388d049 Binary files /dev/null and b/specs/images/openlift.bmp differ diff --git a/specs/images/rock.bmp b/specs/images/rock.bmp new file mode 100644 index 0000000..258cb9d Binary files /dev/null and b/specs/images/rock.bmp differ diff --git a/specs/trampoline.pdf b/specs/trampoline.pdf new file mode 100644 index 0000000..a60aee5 Binary files /dev/null and b/specs/trampoline.pdf differ