| 1 | var death_count = 0; |
| 2 | var score_count = 0; |
| 3 | var timer = 501; |
| 4 | var width = 20; |
| 5 | // functions |
| 6 | //my function |
| 7 | function restart() { |
| 8 | resetnumbers(); |
| 9 | clearDesign(); |
| 10 | pensetup_lose(); |
| 11 | setScreen("1. title_screen"); |
| 12 | } |
| 13 | function resetnumbers() { |
| 14 | score_count = 0; |
| 15 | timer = 0; |
| 16 | } |
| 17 | function clearDesign() { |
| 18 | penColor("white"); |
| 19 | dot(1000); |
| 20 | moveTo(160, 255); |
| 21 | } |
| 22 | function pensetup_lose() { |
| 23 | penDown(); |
| 24 | hide(); |
| 25 | penWidth(width--); |
| 26 | } |
| 27 | function losescreen_background() { |
| 28 | for (var i = 0; i < 500; i++) { |
| 29 | penChange_lose(); |
| 30 | moveForward(i); |
| 31 | } |
| 32 | penUp(); |
| 33 | moveTo(160, 255); |
| 34 | } |
| 35 | function penChange_lose() { |
| 36 | turnRight(90); |
| 37 | penRGB(randomNumber(0, 57), randomNumber(0, 57), randomNumber(0, 57)); |
| 38 | } |
| 39 | //partner's function |
| 40 | function time() { |
| 41 | timer = timer - 1; |
| 42 | setText("map1_time", "Timer: " + timer); |
| 43 | setText("map2_time", "Timer: " + timer); |
| 44 | setText("map3_time", "Timer: " + timer); |
| 45 | if (timer === 0) { |
| 46 | setScreen("lose_screen1"); |
| 47 | deathCount(); |
| 48 | scoreCount("subtract"); |
| 49 | } |
| 50 | } |
| 51 | function scoreCount(operation) { |
| 52 | if (operation == "add"){ |
| 53 | score_count = score_count + 100; |
| 54 | } |
| 55 | else if (operation == "subtract"){ |
| 56 | score_count = score_count - 100; |
| 57 | } |
| 58 | } |
| 59 | function deathCount() { |
| 60 | death_count++; |
| 61 | setText("deathcount_label1", "Death " + "Count: " + death_count); |
| 62 | setText("deathcount_label2", "Death " + "Count: " + death_count); |
| 63 | setText("deathcount_label3", "Death " + "Count: " + death_count); |
| 64 | } |
| 65 | function myfx() { |
| 66 | setScreen("winscreen"); |
| 67 | pensetup(); |
| 68 | moveTo(160, 255); |
| 69 | for (var i = 0; i < 1000; i++) { |
| 70 | penChange(); |
| 71 | moveForward(i); |
| 72 | } |
| 73 | } |
| 74 | function pensetup() { |
| 75 | penDown(); |
| 76 | hide(); |
| 77 | penWidth(3); |
| 78 | } |
| 79 | function penChange() { |
| 80 | turnRight(156); |
| 81 | penRGB(randomNumber(100, 255), randomNumber(100, 255), randomNumber(100, 255)); |
| 82 | } |
| 83 | //intro code |
| 84 | onEvent("start1", "click", function() { |
| 85 | timer = 501; |
| 86 | setScreen("3. maze_1"); |
| 87 | setText("map1_score", "Score: " + score_count); |
| 88 | }); |
| 89 | onEvent("begin1", "click", function() { |
| 90 | setScreen("2. txt_screen.1"); |
| 91 | }); |
| 92 | // maze 1 code |
| 93 | setInterval(time, 1000); |
| 94 | onEvent("background_1", "mouseover", function() { |
| 95 | setScreen("lose_screen1"); |
| 96 | deathCount(); |
| 97 | scoreCount("subtract"); |
| 98 | }); |
| 99 | onEvent("mountain_image", "click", function() { |
| 100 | setScreen("4. txt_screen.2"); |
| 101 | scoreCount("add"); |
| 102 | }); |
| 103 | onEvent("start2", "click", function() { |
| 104 | setScreen("5. maze_2"); |
| 105 | setText("map2_score", "Score:" + score_count); |
| 106 | }); |
| 107 | //lose screen 1 |
| 108 | onEvent("playagain1", "click", function() { |
| 109 | setScreen("2. txt_screen.1"); |
| 110 | }); |
| 111 | // maze 2 code |
| 112 | onEvent("background_2", "mouseover", function() { |
| 113 | setScreen("lose_screen2"); |
| 114 | deathCount(); |
| 115 | scoreCount("subtract"); |
| 116 | }); |
| 117 | onEvent("maze2_star", "click", function() { |
| 118 | setScreen("6. txt_screen.3"); |
| 119 | scoreCount("add"); |
| 120 | }); |
| 121 | onEvent("start3", "click", function() { |
| 122 | setScreen("7. maze_3"); |
| 123 | setText("map3_score", "Score: " + score_count); |
| 124 | }); |
| 125 | //lose screen 2 |
| 126 | onEvent("playagain2", "click", function() { |
| 127 | setScreen("4. txt_screen.2"); |
| 128 | }); |
| 129 | // maze 3 code |
| 130 | onEvent("background_3", "mouseover", function() { |
| 131 | setScreen("lose_screen3"); |
| 132 | deathCount(); |
| 133 | scoreCount("subtract"); |
| 134 | }); |
| 135 | onEvent("scary", "mouseover", function() { |
| 136 | setScreen("6. txt_screen.3"); |
| 137 | scoreCount("add"); |
| 138 | }); |
| 139 | onEvent("map3_rock", "click", myfx); |
| 140 | //lose screen 3 |
| 141 | onEvent("playagain3", "click", function() { |
| 142 | setScreen("7. maze_3"); |
| 143 | }); |
| 144 | onEvent("scary", "mouseover", function() { |
| 145 | setScreen("scary_screen"); |
| 146 | losescreen_background(); |
| 147 | playSound("Scary Scream-SoundBible.com-1115384336 - Copy.mp3", false); |
| 148 | }); |
| 149 | onEvent("Tryagain", "click", function() { |
| 150 | setScreen("3. maze_1"); |
| 151 | }); |
| 152 | onEvent("map3_rock", "click", function() { |
| 153 | setScreen("winscreen"); |
| 154 | }); |
| 155 | onEvent("restartgame", "click", restart); |