現在javascriptを勉強中です
東海道53次をテーマに次のようなすごろくゲームを作っています。
チャンスタイムはランダムのページに飛ばすことができるコマンドです。
(できれば一回しか使えないようにしたいのですが
、、)
また手持ちのサイコロの初期数は3個で、振るたびに一つずつ減り、0個になるとゲームオーバー、ミニゲームやクイズにクリアするとサイコロを一つ手に入れることができるプログラムを作っています。
(説明下手ですみません)
しかし実力不足で、完全にいきずまってしまいました。。。
本当に完成させたくて、質問させていただきました。。
あくまでプログラム部分は説明のためですので、必要でしたら中身を変えてくださっても構いません。。
html
HTML
1<!DOCTYPE HTML> 2<html> 3<head> 4<meta charset="utf-8"> 5<title>東海道53次の旅</title> 6<script src="info2.js"></script> 7</head> 8<body> 9ここがスタート地点の品川か... 10<br>ゴール地点の三条大橋?? 11<br>ふふ...知らねえが、そんなもん3秒でついてやらあ!!!(泣) 12<br> 13<br> 14<input type="button" value="賽を投げまする" onclick="sai()"> 15<input type="button" value="賽の数を数える" onClick="howmanysai()"> 16<input type="button" value="稼ぎに出る" onClick="location.href='game1.html'"> 17<input type="button" value="chance time!" onclick="chance();this.disabled = true;"> 18 19<script type="text/javascript"> 20i=0; 21 22</script> 23</body> 24</html> 25______________________
javascript
1goURL = new Array(); 2 3goURL[0] = "final3.html"; 4goURL[1] = "final4.html"; 5goURL[2] = "final5.html"; 6goURL[3] = "final6.html"; 7goURL[4] = "final7.html"; 8goURL[5] = "final8.html"; 9goURL[6] = "final9.html"; 10goURL[7] = "final10.html"; 11goURL[8] = "final11.html"; 12:::::::: 13goURL[51] = "final54.html"; 14goURL[52] = "final55.html"; 15goURL[53] = "final56.html"; 16 17 18n = Math.floor(Math.random() * 5)+1; 19s=3; //サイコロの初期の数 20function sai(){ 21//ここにサイコロを減らすファンクションを入れようとしたのですが、上手くいきませんでした。 22 23alert(n+"が出たみたいですよ!!"); 24 25 26if(i+n<54){ 27location.href = goURL[i+n]; 28} 29else{ 30alert("残念!勢い余って目的地を通り過ぎました。。。"); 31} 32} 33 34 35function howmanysai(){ 36 37 38alert("あなたの手持ちの賽の数は"+〇〇個+"です♩"); 39//ここもどのように変えればいいかわからなかったです。。 40 41} 42
html
1<!DOCTYPE HTML> 2<html> 3<head> 4<meta charset="utf-8"> 5<title>東海道53次の旅クイズ</title> 6 7</head> 8<body><form name="quiz"> 9<p>Q1 ? 10<br><input type=radio name="a" checked>正解 11<input type=radio name="a">不正解 12<input type=radio name="a">不正解 13<p>Q2 ? 14<br><input type=radio name="b" checked>不正解 15<input type=radio name="b">不正解 16<input type=radio name="b">正解 17<p>Q3 ? 18<br><input type=radio name="c" checked>不正解 19<input type=radio name="c">正解 20<input type=radio name="c">不正解 21 22<p><input type=button value=" 採点 " onClick="saiten()"> 23</form> 24 25<script type="text/javascript"> 26 27function saiten(){ 28var point=0; 29var max=30; 30 31 32if(document.quiz.a[0].checked){point+=10;} 33if(document.quiz.b[2].checked){point+=10;} 34if(document.quiz.c[1].checked){point+=10;} 35 36 37if(point==max){ここにサイコロを一つ増やすファンクションを入れたいです・・・ 38location.href="元のページ"; 39 40} 41else{alert(""+point+"点です。\n残念。。。"); 42location.href="元のページ"; 43} 44document.quiz.a[0].checked=true; 45document.quiz.b[0].checked=true; 46document.quiz.c[0].checked=true; 47} 48//--> 49</script> 50</body> 51</html> 52 53
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。