|
65 | 65 | var background2 = {
|
66 | 66 | file : "background2.gif",
|
67 | 67 | x : 1024,
|
68 |
| - y : 633, |
| 68 | + y : 500, |
69 | 69 | startx : 0,
|
70 | 70 | starty : 0,
|
71 | 71 | type : "image",
|
|
313 | 313 | myGamePiece.left(1);
|
314 | 314 | } else if (event.key == "q" || event.key == "r") {
|
315 | 315 | reset_poor();
|
316 |
| - } else if (event.key == "f" || event.key == 32 ) { |
| 316 | + } else if (event.key == "f" || event.key == "m" ) { |
317 | 317 | myGamePiece.fire()
|
318 | 318 | } else if (event.key == "z" || event.key == "p") {
|
319 | 319 | myGamePiece.stop()
|
| 320 | + } else if (event.key == "P" || event.key == "O") { |
| 321 | + myGamePiece.pause() |
| 322 | + } else if (event.key == "C" || event.key == "H") { |
| 323 | + cheat() |
320 | 324 | }
|
321 | 325 | }),
|
322 | 326 | start : function() {
|
|
511 | 515 | myGame2.text=""
|
512 | 516 | this.iwon=1;
|
513 | 517 | gameover=1
|
| 518 | + myGamePiece.x = Math.floor(background.x/2) |
| 519 | + myGamePiece.y = Math.floor(background.y/2) |
| 520 | + myGamePiece.width *= 3 |
| 521 | + myGamePiece.height *= 3 |
514 | 522 | } else {
|
515 | 523 | myGame.text="LEVEL UP"
|
516 | 524 | myGame2.text=""
|
|
527 | 535 | updateGameArea()
|
528 | 536 | }
|
529 | 537 | }
|
530 |
| - this.cheat = function(isPiece) { |
| 538 | + this.bigcheat = function(isPiece) { |
| 539 | + // kill a ship |
| 540 | + // loop over my castles |
| 541 | + //for (j = 0; j < this.myCastles.length; j += 1) { |
| 542 | + // this.myCastles[j].active = 0; |
| 543 | + //} |
| 544 | + // loop over enemy castles |
| 545 | + for (j = 0; j < yourGamePiece.myCastles.length; j += 1) { |
| 546 | + yourGamePiece.myCastles[j].active = 0; |
| 547 | + } |
| 548 | + // loop over enemy bullets |
| 549 | + for (j = 0; j < yourGamePiece.myBullets.length; j += 1) { |
| 550 | + yourGamePiece.myBullets[j].active=0; |
| 551 | + } |
531 | 552 | // move to the right
|
532 |
| - var rockbottom = myGameArea.canvas.width - this.width - buffer; |
533 |
| - this.x = rockbottom; |
534 |
| - this.newPos(true) |
535 |
| - this.update() |
| 553 | + //var rockbottom = myGameArea.canvas.width - this.width - buffer; |
| 554 | + //this.x = rockbottom; |
| 555 | + //this.newPos(true) |
| 556 | + yourGamePiece.update() |
536 | 557 | //this.win()
|
537 | 558 | }
|
538 | 559 | this.die = function() {
|
|
678 | 699 | }
|
679 | 700 | }
|
680 | 701 |
|
| 702 | +function cheat() { |
| 703 | + // kill a ship |
| 704 | + j = Math.floor(Math.random() * yourGamePiece.myCastles.length) |
| 705 | + yourGamePiece.myCastles[j].active=0; |
| 706 | + // loop over enemy bullets |
| 707 | + for (j = 0; j < yourGamePiece.myBullets.length; j += 1) { |
| 708 | + yourGamePiece.myBullets[j].active=0; |
| 709 | + } |
| 710 | + //yourGamePiece.update() |
| 711 | + return |
| 712 | +} |
| 713 | + |
681 | 714 | function loveHearts(myPiece) {
|
682 | 715 | const nBroken = maxlives - myPiece.lives
|
683 | 716 | const nLive = myPiece.lives
|
|
712 | 745 | gameover = 1;
|
713 | 746 | myPiece.iwon=0;
|
714 | 747 | yourPiece.iwon=1;
|
| 748 | + yourPiece.x = Math.floor(background.x/2) |
| 749 | + yourPiece.y = Math.floor(background.y/2) |
| 750 | + yourPiece.width *= 3 |
| 751 | + yourPiece.height *= 3 |
715 | 752 | myGame.update();
|
716 | 753 | return true
|
717 | 754 | }
|
|
746 | 783 | myPiece.removeCastle(yourPiece.myCastles[j])
|
747 | 784 | if ( myPiece.lives < 1 ) {
|
748 | 785 | // what happens if you lose
|
749 |
| - if ( level == maxlevels ) { |
750 |
| - myGame.text="DOWN A LEVEL" |
751 |
| - level -= 1 |
752 |
| - if ( level < 1 ) level = 1 |
753 |
| - myGame2.text="PAUSED" |
754 |
| - pause_game=1 |
755 |
| - wait=pause_count |
756 |
| - updateGameArea() |
757 |
| - reset() |
758 |
| - } else { |
759 |
| - myGame.text="GAME OVER" |
760 |
| - myGame2.text="" |
761 |
| - gameover = 1; |
762 |
| - myPiece.iwon=0; |
763 |
| - yourPiece.iwon=1; |
764 |
| - } |
| 786 | + myGame.text="GAME OVER" |
| 787 | + myGame2.text="" |
| 788 | + myPiece.iwon=0; |
| 789 | + yourPiece.iwon=1; |
| 790 | + gameover = 1; |
| 791 | + yourPiece.x = Math.floor(background.x/2) |
| 792 | + yourPiece.y = Math.floor(background.y/2) |
| 793 | + yourPiece.width *= 3 |
| 794 | + yourPiece.height *= 3 |
| 795 | + //myGame.update(); |
765 | 796 | for (i = 0; i < myPiece.myBullets.length; i += 1) {
|
766 | 797 | myPiece.myBullets[i].active = 0
|
767 | 798 | }
|
|
841 | 872 | }
|
842 | 873 |
|
843 | 874 | for (i = 0; i < myGamePiece.myCastles.length; i += 1) {
|
844 |
| - myGamePiece.myCastles[i].update(); |
| 875 | + if ( myGamePiece.myCastles[i].active ) myGamePiece.myCastles[i].update(); |
845 | 876 | }
|
846 | 877 |
|
847 | 878 | for (i = 0; i < yourGamePiece.myCastles.length; i += 1) {
|
848 |
| - if (everyinterval(Math.floor(Math.random()*5000))) { |
| 879 | + if (yourGamePiece.myCastles[i].active && everyinterval(Math.floor(Math.random()*5000))) { |
849 | 880 | myGame.text=""
|
850 | 881 | myGame2.text=""
|
851 | 882 | yourGamePiece.clearArrows()
|
|
924 | 955 | reset()
|
925 | 956 | } else {
|
926 | 957 | myGame.text="GAME OVER"
|
927 |
| - gameover = 1; |
928 | 958 | myPiece.iwon=0;
|
| 959 | + gameover = 1; |
929 | 960 | yourPiece.iwon=1;
|
| 961 | + yourPiece.x = Math.floor(background.x/2) |
| 962 | + yourPiece.y = Math.floor(background.y/2) |
| 963 | + yourPiece.width *= 3 |
| 964 | + yourPiece.height *= 3 |
| 965 | + //myGame.update(); |
930 | 966 | }
|
931 | 967 | for (i = 0; i < myGamePiece.myBullets.length; i += 1) {
|
932 | 968 | myGamePiece.myBullets[i].active = 0
|
|
1094 | 1130 | <br>
|
1095 | 1131 | <button type="button" onmouseover="myGamePiece.fire()" onmousedown="myGamePiece.fire()" onmouseup="myGamePiece.fire()" ontouchstart="myGamePiece.fire()">FIRE</button>
|
1096 | 1132 | <br>
|
| 1133 | +<p>Meet the Tudors: Make it to the right of the screen to win</p> |
1097 | 1134 | <br>
|
1098 | 1135 | <br>
|
1099 | 1136 | <br>
|
1100 | 1137 | <br>
|
1101 | 1138 | <br>
|
1102 |
| -<button type="button onmousedown="bg()" onmouseover="bg()">Background</button> |
1103 |
| -<button type="button onmousedown="help()" onmouseover="help()">Help</button> |
1104 |
| -<p>Meet the Tudors: Make it to the right of the screen to win</p> |
| 1139 | +<br> |
| 1140 | +<br> |
| 1141 | +<br> |
| 1142 | +<br> |
| 1143 | +<br><br> |
| 1144 | +<br> |
| 1145 | +<br> |
| 1146 | +<br> |
| 1147 | +<br><br> |
| 1148 | +<br> |
| 1149 | +<br> |
| 1150 | +<br> |
| 1151 | +<br><br> |
| 1152 | +<br> |
| 1153 | +<br> |
| 1154 | +<br> |
| 1155 | +<br><br> |
| 1156 | +<br> |
| 1157 | +<br> |
| 1158 | +<br> |
| 1159 | +<br><br> |
| 1160 | +<br> |
| 1161 | +<br> |
| 1162 | +<br> |
| 1163 | +<br><br> |
| 1164 | +<br> |
| 1165 | +<br> |
| 1166 | +<br> |
| 1167 | +<br><br> |
| 1168 | +<br> |
| 1169 | +<br> |
| 1170 | +<br> |
| 1171 | +<br><br> |
| 1172 | +<br> |
| 1173 | +<br> |
| 1174 | +<br> |
| 1175 | +<br><br> |
| 1176 | +<br> |
| 1177 | +<br> |
| 1178 | +<br> |
| 1179 | +<br><br> |
| 1180 | +<br> |
| 1181 | +<br> |
| 1182 | +<br> |
| 1183 | +<br><br> |
| 1184 | +<br> |
| 1185 | +<br> |
| 1186 | +<br> |
| 1187 | +<br><br> |
| 1188 | +<br> |
| 1189 | +<br> |
| 1190 | +<br> |
| 1191 | +<br><br> |
| 1192 | +<br> |
| 1193 | +<br> |
| 1194 | +<br> |
| 1195 | +<br><br> |
| 1196 | +<br> |
| 1197 | +<br> |
| 1198 | +<br> |
| 1199 | +<br><br> |
| 1200 | +<br> |
| 1201 | +<br> |
| 1202 | +<br> |
| 1203 | +<br><br> |
| 1204 | +<br> |
| 1205 | +<br> |
| 1206 | +<br> |
| 1207 | +<br><br> |
| 1208 | +<br> |
| 1209 | +<br> |
| 1210 | +<br> |
| 1211 | +<br><br> |
| 1212 | +<br> |
| 1213 | +<br> |
| 1214 | +<br> |
| 1215 | +<br><br> |
| 1216 | +<br> |
| 1217 | +<br> |
| 1218 | +<br> |
| 1219 | +<br><br> |
| 1220 | +<br> |
| 1221 | +<br> |
| 1222 | +<br> |
| 1223 | +<br><br> |
| 1224 | +<br> |
| 1225 | +<br> |
| 1226 | +<br> |
| 1227 | +<br> |
1105 | 1228 | <br>
|
1106 | 1229 | <button onmousedown="pause('PAUSED')" onmouseover="pause('PAUSED')">pause</button>
|
1107 |
| -<button onmousedown="myGamePiece.cheat()">cheat</button> |
| 1230 | +<button onmousedown="cheat()">cheat</button> |
1108 | 1231 | <button onmousedown="myGamePiece.die()">die</button>
|
1109 | 1232 | <br>
|
1110 | 1233 | <audio id="myAudio" controls>
|
|
0 commit comments