
ミサイル防衛(シンプルシューティングゲーム)のプログラムを公開します。
【ご注意】
・本プログラムの動作等に関する質問にはお答えできません。
・本プログラムの使用により、何らかの障害が発生した場合にも、当方は一切の責任を負いません。
・本プログラムの転載、二次配布を禁止します。
→トップページ(ゲーム)に戻る
スポンサードリンク

↑制作の際、この本を参考にしました。
<body oncontextmenu="return false;" ontouchmove="event.preventDefault()" style="overflow-x:hidden;"> <!-- Android端末で長押しした時に「画像を保存」等のメニューを表示させないための処理 --><!-- 横スクロール禁止 -->
<!-- 背景 -->
<div id="background" style="position: absolute; left: 0px; top: 0px; width: 540; height: 540px; background-image: url(background.jpg);">
</div>
<!-- 赤色レイヤー(ゲームオーバー処理用) -->
<div id="backred" style="position: absolute; left: 0px; top: 0px; width: 540; height: 540px; background-image: url(backgroundr.jpg); opacity: 0;">
</div>
<!-- 爆風キャンバスレイヤー -->
<canvas id="canvas1" width="540" height="540" onSelectStart = "return false;" onMouseDown = "return false;" style="position: absolute; left: 0px; top: 0px; -moz-user-select: none; -khtml-user-select: none; user-select: none;"></canvas>
<!-- ミサイル -->
<script>
for (i=0; i<100; i++) {
document.write('<div id="div_missile'+i+'" style="position: absolute; left: -120px; top: -120px;"><img src="missile1.gif" id="img_missile'+i+'" style="width: 19px; height: 38px;"></div>');
}
</script>
<!-- アイテム -->
<div id="div_item" style="position: absolute; left: -120px; top: -120px;">
<img src="item0.gif" id="img_item" style="width: 30px; height: 17px;">
</div>
<!-- レーザーキャンバスレイヤー -->
<canvas id="canvas2" width="540" height="540" onSelectStart = "return false;" onMouseDown = "return false;" style="position: absolute; left: 0px; top: 0px; -moz-user-select: none; -khtml-user-select: none; user-select: none;"></canvas>
<!-- 白ウォール(キャラ隠蔽用) -->
<div style="position: absolute; left: 0px; top: 540px;">
<img src="wall_h.gif">
</div>
<div style="position: absolute; left: 540px; top: 0px;">
<img src="wall_v.gif">
</div>
<div id="div_title" style="position: absolute; left: 0px; top: 50px; width: 540px; text-align: center; opacity: 1; color: #ffffff;">
<img src="title.gif" id="title" style="margin-bottom: 5px; width: 500px;"><br>
<!-- -webkit-text-size-adjust: 100%; はiPhoneのテキストサイズ自動調整によるレイアウト崩れを防ぐもの -->
<p style="line-height: 1.2; -webkit-text-size-adjust: 100%;"><span id="title_contents">【 ゲームの遊び方 】<br>
『スタート』ボタンをクリックまたはタップでゲームスタート<br>
画面をクリックまたはタップをすると爆発が発生<br>
連鎖爆発を利用してミサイルをどんどんやっつけよう!</span><br>
<br>
<input type="image" src="start.gif" id="button_start" style="width: 200px;" onclick="init();"><br>
<br>
Copyright(C) 2016 <a href="//kunisan.jp/" target="_blank" style="color: #aaaaaa">KUNISAN.JP</a>. All Rights Reserved.</p>
</div>
<!-- エネルギー切れ表示用 -->
<div id="div_caution" style="position: absolute; left: 0px; top: 260px; width: 540px; text-align: center; opacity: 1;">
<span id="caution" style="color: #ff0000;"></span>
</div>
<!-- ゲームオーバー表示用 -->
<div id="div_gameover" style="position: absolute; left: -540px; top: 229px; width: 540px; text-align: center; opacity: 1;">
<img src="gameover.gif" id="gameover" style="width: 400px;">
</div>
<!-- エネルギー表示 -->
<div style="padding: 0; line-height: 1; position: absolute; left: 2px; top: 543px;">ENERGY</div>
<div style="position: absolute; left: 75px; top: 543px;"><img id="img_bar1" src="bar1.gif" style="width: 463px; height: 16px;"></div>
<!-- ダメージ表示 -->
<div style="padding: 0; line-height: 1; position: absolute; left: 2px; top: 562px;">DAMAGE</div>
<div style="position: absolute; left: 75px; top: 562px;"><img id="img_bar2" src="bar2.gif" style="width: 0px; height: 16px;"></div>
<!-- ベストスコア -->
<div style="padding: 0; line-height: 1; position: absolute; left: 2px; top: 582px;">
BEST SCORE: <span id="best_score">0</span>
</div>
<!-- スコア -->
<div style="padding: 0; line-height: 1; position: absolute; left: 192px; top: 582px;">
YOUR SCORE: <span id="your_score">0</span>
</div>
<!-- 発射数、ヒット数、ヒット確率 -->
<div style="padding: 0; line-height: 1; position: absolute; left: 2px; top: 602px;">
FIRE: <span id="fire">0</span>
</div>
<div style="padding: 0; line-height: 1; position: absolute; left: 102px; top: 602px;">
HIT: <span id="hit">0</span>
</div>
<div style="padding: 0; line-height: 1; position: absolute; left: 192px; top: 602px;">
RATE: <span id="rate">0</span>%
</div>
<!-- 言語選択ボタン用 -->
<div id="div_button_lang" style="position: absolute; left: 446px; top: 581px;">
<input type="image" src="lang_jp.gif" id="button_lang" style="width: 39px; height: 39px;" onclick="lang_change();">
</div>
<!-- オーディオボタン用 -->
<div id="div_button_audio" style="position: absolute; left: 499px; top: 581px;">
<input type="image" src="audio_on.gif" id="button_audio" style="width: 39px; height: 39px;" onclick="audio_change();">
</div>
<script>
//変数初期設定
var screenstatus = 0; //0-トップ画面, 1-ゲーム画面, 2-ゲームオーバー画面
var canvas = []; //キャンバス
var ctx = []; //キャンバス
var explosion = []; //爆風オブジェクト
var exp_num = 0; //爆風順番
var exp_timerId = []; //爆風タイマーID
var exp_con = 5; //爆風エネルギー消費量
var exp_rad = 20; //爆風半径
var laser = []; //レーザーオブジェクト
var laser_num = 0; //レーザー順番
var laser_timerId = []; //レーザータイマーID
var missile = []; //ミサイルオブジェクト
var mis_num = 0; //ミサイル順番
var mis_timer = []; //ミサイル発生タイマー
var mis_timerId = []; //ミサイルタイマーID
var item; //アイテムオブジェクト
var item_timer; //アイテムタイマー
var item_timerId; //アイテムタイマーID
var eng = 463; //エネルギー(最大値463)
var eng_timerId = 0; //エネルギー表示タイマーID
var eng_rec = 0.4; //エネルギー回復量
var damage = 0; //ダメージ(最大値463)
var damage_rec = 0.25; //ダメージ回復量
var damage_timerId = 0; //ダメージ表示タイマーID
var damage_sound = 0; //ダメージサウンド順番
var main_timerId = 0; //メインループ用タイマーID
var imagedata = []; //衝突判定用1
var data_i = []; //衝突判定用2
var round_data = []; //ラウンドデータ
var missile_data = []; //ミサイル種類データ
var score = 0; //スコア
var best_score = 0; //ベストスコア
var score_timerId = 0; //スコア表示タイマーID
var round = -1; //ラウンド
var round_timer = 0; //ラウンドタイマー
var timer_rate = 1; //タイマーレート(一周すると0.8でミサイル出現タイミングが早くなる)
var emp_sound = 0; //エネルギー切れサウンド順番
var fire = 0; //発射数
var hit = 0; //ヒット数
var rate = 0; //ヒット確率
var fire_timerId = 0; //発射数等表示タイマーID
var split_sound = 0; //ミサイル分裂サウンド順番
var acc_sound = 0; //ミサイル点火サウンド順番
var hit_sound = 0; //体力ミサイルヒットサウンド順番
var bosmis_sound = 0; //ボスミサイル発射サウンド順番
var audio_status = 1; //オーディオオン・オフ(0-オフ, 1-オン)
var lang_status = 0; //言語選択(0-日本語, 1-英語)
var srch1 = document.location.search; //クエリー取得
srch1 = srch1.replace(/\?/i,""); // ?を消去
var srch2 = srch1.split("&"); // 配列に分割する
var vl = srch2[0].replace(/LANG\=/i,""); //値のみ取得
if (vl == "en") {
lang_change();
}
//キャラクター初登場時に切り替え表示されないようにする処理
var image_files = ['item0.gif','item1.gif','item2.gif','item3.gif','item4.gif','missile1.gif','missile2.gif','missile3.gif','missile3a.gif','missile3b.gif','missile4.gif','missile4a.gif','missile5.gif','missile1_l.gif','missile2_l.gif','missile3_l.gif','missile3a_l.gif','missile3b_l.gif','missile4_l.gif','missile4a_l.gif','missile5_l.gif','boss0.gif','boss0_l.gif','boss1.gif','boss1_l.gif','boss2.gif','boss2_l.gif','boss3.gif','boss3_l.gif','boss4.gif','boss4_l.gif','boss5.gif','boss5_l.gif','missileboss.gif','missileboss_l.gif'];
for (i=0; i<image_files.length; i++){ //画面外にキャラクター表示
document.getElementById('img_missile'+i).src = image_files[i];
}
var audio_files = ['bgm.mp3',,,,,,,,,,'laser.wav','laser.wav','laser.wav','laser.wav','laser.wav','laser.wav','laser.wav','laser.wav','laser.wav','laser.wav','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','explosion.mp3','damage.mp3','damage.mp3','damage.mp3','damage.mp3','damage.mp3','gameover.mp3','empty.mp3','empty.mp3','empty.mp3','split.wav','split.wav','split.wav','item.wav','acc.mp3','acc.mp3','acc.mp3','hit.wav','hit.wav','hit.wav','bosmis.wav','bosmis.wav','bosmis.wav','alarm.mp3']; //オーディオファイル名一覧(0-BGM,10~19-レーザー発射1,20~39-爆発,40~44-ダメージ,45-ゲームオーバー,46~48-エネルギー切れ,49-51-ミサイル分裂,52-アイテムゲット,53~55-ミサイル点火,56~58-ヒット,59~61-ボスミサイル,62-ボスアラーム)
var audio = []; //オーディオ用配列
for (i=0; i<audio_files.length; i++){ //全体の音量調整
audio[i] = new Audio(audio_files[i]);
audio[i].volume = 0.4;
}
for (i=10; i<=19; i++){ //レーザー音小さく調整
audio[i].volume = 0.05;
}
audio[45].volume = 0.9; //ゲームオーバー音大きく調整
for (i=46; i<=48; i++) {
audio[i].volume = 0.7; //エネルギー切れやや大きく調整
}
for (i=49; i<=51; i++) {
audio[i].volume = 0.6; //ミサイル分裂大きく調整
}
audio[52].volume = 0.3; //アイテムゲット音やや小さく
for (i=53; i<=55; i++) {
audio[i].volume = 0.15; //ミサイル点火音やや小さく調整
}
for (i=56; i<=58; i++) {
audio[i].volume = 0.1; //ミサイル点火音やや小さく調整
}
for (i=59; i<=61; i++) {
audio[i].volume = 0.15; //ミサイル点火音やや小さく調整
}
audio[62].volume = 0.9; //ボスアラム音やや大きく
//ミサイルデータ
missile_data[0] = { //(直線遅)
image: 'missile1.gif', //画像ファイル
width: 10, //幅
length: 20, //長さ
speed: 2, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 10 //得点
}
missile_data[1] = { //(直線中速)
image: 'missile1.gif', //画像ファイル
width: 12, //幅
length: 24, //長さ
speed: 4, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 20 //得点
}
missile_data[2] = { //(直線速)
image: 'missile1.gif', //画像ファイル
width: 14, //幅
length: 28, //長さ
speed: 8, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 40 //得点
}
missile_data[3] = { //(斜遅)
image: 'missile2.gif', //画像ファイル
width: 12, //幅
length: 24, //長さ
speed: 5, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 30 //得点
}
missile_data[4] = { //(斜速)
image: 'missile2.gif', //画像ファイル
width: 14, //幅
length: 28, //長さ
speed: 9, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 50 //得点
}
missile_data[5] = { //(分裂速度遅)
image: 'missile3.gif', //画像ファイル
width: 12, //幅
length: 24, //長さ
speed: 7, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 120 //得点
}
missile_data[6] = { //(分裂後1速度遅)
image: 'missile3a.gif', //画像ファイル
width: 9, //幅
length: 24, //長さ
speed: 5, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 30 //得点
}
missile_data[7] = { //(分裂後2速度遅)
image: 'missile3b.gif', //画像ファイル
width: 6, //幅
length: 24, //長さ
speed: 3, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 10 //得点
}
missile_data[8] = { //(分裂速度速)
image: 'missile3.gif', //画像ファイル
width: 14, //幅
length: 28, //長さ
speed: 9, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 200 //得点
}
missile_data[9] = { //(分裂後1速度速)
image: 'missile3a.gif', //画像ファイル
width: 10, //幅
length: 28, //長さ
speed: 7, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 60 //得点
}
missile_data[10] = { //(分裂後2速度速)
image: 'missile3b.gif', //画像ファイル
width: 7, //幅
length: 28, //長さ
speed: 5, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 20 //得点
}
missile_data[11] = { //加速度遅
image: 'missile4.gif', //画像ファイル
width: 14, //幅
length: 28, //長さ
speed: 10, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 150 //得点
}
missile_data[12] = { //加速度速
image: 'missile4.gif', //画像ファイル
width: 16, //幅
length: 32, //長さ
speed: 14, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 200 //得点
}
missile_data[13] = { //S字速遅
image: 'missile5.gif', //画像ファイル
width: 14, //幅
length: 28, //長さ
speed: 7, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 150 //得点
}
missile_data[14] = { //S字速速
image: 'missile5.gif', //画像ファイル
width: 16, //幅
length: 32, //長さ
speed: 10, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 200 //得点
}
missile_data[30] = { //直線ボス
image: 'missile1.gif', //画像ファイル
width: 30, //幅
length: 60, //長さ
speed: 8, //スピード
life: 12, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 500 //得点
}
missile_data[31] = { //斜ボス
image: 'missile2.gif', //画像ファイル
width: 30, //幅
length: 60, //長さ
speed: 8, //スピード
life: 12, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 700 //得点
}
missile_data[32] = { //(分裂ボス)
image: 'missile3.gif', //画像ファイル
width: 30, //幅
length: 60, //長さ
speed: 9, //スピード
life: 12, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 1000 //得点
}
missile_data[33] = { //(分裂ボス)
image: 'missile3a.gif', //画像ファイル
width: 21, //幅
length: 60, //長さ
speed: 8, //スピード
life: 7, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 300 //得点
}
missile_data[34] = { //(分裂ボス)
image: 'missile3b.gif', //画像ファイル
width: 15, //幅
length: 60, //長さ
speed: 7, //スピード
life: 4, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 100 //得点
}
missile_data[35] = { //加速ボス
image: 'missile4.gif', //画像ファイル
width: 30, //幅
length: 60, //長さ
speed: 12, //スピード
life: 12, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 1000 //得点
}
missile_data[36] = { //S字ボス
image: 'missile5.gif', //画像ファイル
width: 30, //幅
length: 60, //長さ
speed: 8, //スピード
life: 12, //ライフ
maxradius: 50, //爆風最大径
damage: 160, //ダメージ
score: 1000 //得点
}
missile_data[50] = { //最終ボス(手裏剣)
image: 'boss0.gif', //画像ファイル
width: 100, //幅
length: 100, //長さ
speed: 6, //スピード
life: 50, //ライフ
maxradius: 70, //爆風最大径
damage: 240, //ダメージ
score: 2000 //得点
}
missile_data[51] = { //最終ボスミサイル
image: 'missileboss.gif', //画像ファイル
width: 10, //幅
length: 30, //長さ
speed: 11, //スピード
life: 1, //ライフ
maxradius: 30, //爆風最大径
damage: 80, //ダメージ
score: 50 //得点
}
//ラウンドデータ
round_data[0] = { //ラウンドデータ★直線
duration: 300, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[1] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [0,1], //ミサイルタイプ
mtimer: [20,60], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[2] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [0,1,2], //ミサイルタイプ
mtimer: [20,30,60], //ミサイルタイマー
mrate: [3,3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[3] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[4] = { //ラウンドデータ★斜行
duration: 300, //持続時間1/10秒単位
mtype: [3], //ミサイルタイプ
mtimer: [20], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[5] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [3,1], //ミサイルタイプ
mtimer: [10,20], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[6] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [3,1], //ミサイルタイプ
mtimer: [5,10], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[7] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[8] = { //ラウンドデータ★3分裂x1
duration: 300, //持続時間1/10秒単位
mtype: [6], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[9] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [6,1], //ミサイルタイプ
mtimer: [30,20], //ミサイルタイマー
mrate: [3,6] //ミサイル出現確率(タイマー以外で%)
}
round_data[10] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [6,1,2], //ミサイルタイプ
mtimer: [20,20,30], //ミサイルタイマー
mrate: [3,6,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[11] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[12] = { //ラウンドデータ★加速度
duration: 300, //持続時間1/10秒単位
mtype: [11], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [5] //ミサイル出現確率(タイマー以外で%)
}
round_data[13] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [11,3], //ミサイルタイプ
mtimer: [20,30], //ミサイルタイマー
mrate: [5,5] //ミサイル出現確率(タイマー以外で%)
}
round_data[14] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [11,3,6], //ミサイルタイプ
mtimer: [20,30,30], //ミサイルタイマー
mrate: [5,5,5] //ミサイル出現確率(タイマー以外で%)
}
round_data[15] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[16] = { //ラウンドデータ★S字
duration: 300, //持続時間1/10秒単位
mtype: [13], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [5] //ミサイル出現確率(タイマー以外で%)
}
round_data[17] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [13,2], //ミサイルタイプ
mtimer: [20,30], //ミサイルタイマー
mrate: [5,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[18] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [13,2,3], //ミサイルタイプ
mtimer: [20,30,20], //ミサイルタイマー
mrate: [5,3,5] //ミサイル出現確率(タイマー以外で%)
}
round_data[19] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[20] = { //ラウンドデータ★直線ボス
duration: 300, //持続時間1/10秒単位
mtype: [2], //ミサイルタイプ
mtimer: [20], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[21] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [2,1], //ミサイルタイプ
mtimer: [20,20], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[22] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [30,1], //ミサイルタイプ
mtimer: [30,30], //ミサイルタイマー
mrate: [3,5] //ミサイル出現確率(タイマー以外で%)
}
round_data[23] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[24] = { //ラウンドデータ★2段階x3分裂
duration: 300, //持続時間1/10秒単位
mtype: [5], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[25] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [5,11], //ミサイルタイプ
mtimer: [30,30], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[26] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [5,11,2], //ミサイルタイプ
mtimer: [30,30,30], //ミサイルタイマー
mrate: [5,3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[27] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[28] = { //ラウンドデータ★斜行ボス
duration: 300, //持続時間1/10秒単位
mtype: [4], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[29] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [4,3], //ミサイルタイプ
mtimer: [30,20], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[30] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [31,4], //ミサイルタイプ
mtimer: [30,30], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[31] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[32] = { //ラウンドデータ★S字速&加速速
duration: 300, //持続時間1/10秒単位
mtype: [14], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[33] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [14,12], //ミサイルタイプ
mtimer: [40,50], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[34] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [14,12,2], //ミサイルタイプ
mtimer: [40,60,40], //ミサイルタイマー
mrate: [3,3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[35] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[36] = { //ラウンドデータ★2段階x3分裂ボス
duration: 300, //持続時間1/10秒単位
mtype: [8], //ミサイルタイプ
mtimer: [50], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[37] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [8,6], //ミサイルタイプ
mtimer: [60,60], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[38] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [32,6], //ミサイルタイプ
mtimer: [50,60], //ミサイルタイマー
mrate: [2,2] //ミサイル出現確率(タイマー以外で%)
}
round_data[39] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[40] = { //ラウンドデータ★大量
duration: 300, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [5], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[41] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [1,3,5,11,13], //ミサイルタイプ
mtimer: [50,50,80,50,80], //ミサイルタイマー
mrate: [3,3,3,3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[42] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [3], //ミサイルタイプ
mtimer: [5], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[43] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[44] = { //ラウンドデータ★加速ボス
duration: 300, //持続時間1/10秒単位
mtype: [12], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[45] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [12,11], //ミサイルタイプ
mtimer: [30,40], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[46] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [35,11], //ミサイルタイプ
mtimer: [35,50], //ミサイルタイマー
mrate: [1,2] //ミサイル出現確率(タイマー以外で%)
}
round_data[47] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[48] = { //ラウンドデータ★パズル的
duration: 50, //持続時間1/10秒単位
mtype: [7], //ミサイルタイプ
mtimer: [1], //ミサイルタイマー
mrate: [1] //ミサイル出現確率(タイマー以外で%)
}
round_data[49] = { //ラウンドデータ //休止
duration: 40, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[50] = { //ラウンドデータ
duration: 80, //持続時間1/10秒単位
mtype: [2], //ミサイルタイプ
mtimer: [3], //ミサイルタイマー
mrate: [1] //ミサイル出現確率(タイマー以外で%)
}
round_data[51] = { //ラウンドデータ //休止
duration: 50, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[52] = { //ラウンドデータ
duration: 50, //持続時間1/10秒単位
mtype: [7], //ミサイルタイプ
mtimer: [1], //ミサイルタイマー
mrate: [1] //ミサイル出現確率(タイマー以外で%)
}
round_data[53] = { //ラウンドデータ //休止
duration: 40, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[54] = { //ラウンドデータ
duration: 80, //持続時間1/10秒単位
mtype: [14], //ミサイルタイプ
mtimer: [3], //ミサイルタイマー
mrate: [1] //ミサイル出現確率(タイマー以外で%)
}
round_data[55] = { //ラウンドデータ //休止
duration: 50, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[56] = { //ラウンドデータ
duration: 50, //持続時間1/10秒単位
mtype: [7], //ミサイルタイプ
mtimer: [1], //ミサイルタイマー
mrate: [1] //ミサイル出現確率(タイマー以外で%)
}
round_data[57] = { //ラウンドデータ //休止
duration: 40, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[58] = { //ラウンドデータ
duration: 60, //持続時間1/10秒単位
mtype: [12], //ミサイルタイプ
mtimer: [3], //ミサイルタイマー
mrate: [1] //ミサイル出現確率(タイマー以外で%)
}
round_data[59] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[60] = { //ラウンドデータ★S字ボス
duration: 300, //持続時間1/10秒単位
mtype: [14], //ミサイルタイプ
mtimer: [30], //ミサイルタイマー
mrate: [3] //ミサイル出現確率(タイマー以外で%)
}
round_data[61] = { //ラウンドデータ
duration: 300, //持続時間1/10秒単位
mtype: [14,13], //ミサイルタイプ
mtimer: [30,40], //ミサイルタイマー
mrate: [3,3] //ミサイル出現確率(タイマー以外で%)
}
round_data[62] = { //ラウンドデータ
duration: 200, //持続時間1/10秒単位
mtype: [36,13], //ミサイルタイプ
mtimer: [35,50], //ミサイルタイマー
mrate: [1,2] //ミサイル出現確率(タイマー以外で%)
}
round_data[63] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[64] = { //ラウンドデータ★最終ボス
duration: 490, //持続時間1/10秒単位
mtype: [50], //ミサイルタイプ
mtimer: [100], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
round_data[65] = { //ラウンドデータ //休止
duration: 70, //持続時間1/10秒単位
mtype: [0], //ミサイルタイプ
mtimer: [200], //ミサイルタイマー
mrate: [0] //ミサイル出現確率(タイマー以外で%)
}
//キャンバス初期設定(3枚)
for (i=1; i<=2; i++) {
canvas[i] = document.getElementById('canvas'+i);
ctx[i] = canvas[i].getContext('2d');
ctx[i].strokeStyle = '#000000';
ctx[i].fillStyle = '#000000';
ctx[i].lineWidth = 1;
ctx[i].lineCap = 'butt';
ctx[i].globalCompositeOperation = 'destination-out'; //透明処理で裏のレイヤーを表示できるようにする
ctx[i].fillRect(0,0,539,539);
}
//トップ画面 {
function top_title() {
screenstatus = 0;
document.getElementById('backred').style.opacity = 0;
document.getElementById('div_gameover').style.left = '-540px';
document.getElementById('div_title').style.left = '0';
document.getElementById('div_google_ads').style.left = '36px'; //Google広告
eng = 463; //エネルギー(最大値463)
damage = 0; //ダメージ(最大値463)
}
//ゲーム開始設定
function init() {
if (screenstatus == 0){ //ゲーム開始後、スペースキーを押しても誤作動しないようにする措置
screenstatus = 1;
document.getElementById('div_title').style.left = '-540px';
document.getElementById('caution').textContent = '';
document.getElementById('div_google_ads').style.left = '-540px'; //Google広告
//ミサイルライフ初期設定
for (i=0; i<=99; i++) {
missile[i] = {life: 0};
}
exp_num = 0; //爆風順番
exp_con = 5; //爆風エネルギー消費量
exp_rad = 20; //爆風半径
laser_num = 0; //レーザー順番
mis_num = 0; //ミサイル順番
item_timer = 800; //アイテムタイマー
eng_rec = 0.5; //エネルギー回復量
damage_rec = 0.08; //ダメージ回復量
score = 0; //スコア
round = -1; //ラウンド(開始ラウンド-1)
round_timer = 0; //ラウンドタイマー
timer_rate = 1; //タイマーレート(一周すると0.8でミサイル出現タイミングが早くなる)
fire = 0; //発射数
hit = 0; //ヒット数
if (audio_status == 1) {
audio[0].play(); //BGM演奏
}
audio[0].loop = true;
//メインループへ
clearInterval(main_timerId);
main_timerId = setInterval(mainLoop,100);
}
}
//メインループ
function mainLoop() {
round_timer -= 1; //ラウンドタイマー減少
if (round_timer <= 0) { //ラウンド更新
round += 1;
if (round == 64) {
audio[62].play(); //効果音
}
if (round >= round_data.length) {
round = 0;
timer_rate = 0.8;
}
round_timer = round_data[round].duration; //ラウンドタイマーセット
for (i=0; i < round_data[round].mtype.length; i++) {
mis_timer[i] = round_data[round].mtimer[i];
}
}
for (i=0; i < round_data[round].mtype.length; i++) { //各ミサイルタイマー処理
mis_timer[i] -= 1; //ミサイルタイマー減少
if (Math.random()* 100 <= round_data[round].mrate[i]){ //指定確率以内ならタイマーゼロ処理
mis_timer[i] = 0;
}
if ((mis_timer[i] <= 0)&&(missile[mis_num].life <= 0)) { //発生タイマーゼロかつ該当のミサイルライフゼロでミサイル発生
missile[mis_num] = new MisObj(document.getElementById('div_missile'+mis_num),document.getElementById('img_missile'+mis_num),round_data[round].mtype[i]); //ミサイルオブジェクトの作成
clearInterval(mis_timerId[mis_num]); //タイマークリア
mis_timerId[mis_num] = setInterval(misProcess,100,mis_num); //ミサイル処理開始(タイマーID渡す処理)
mis_timer[i] = Math.floor(round_data[round].mtimer[i] * timer_rate); //ミサイルタイマーリセット
mis_num = (mis_num < 99)?mis_num + 1 : 0;
}
}
item_timer -= 1; //アイテムタイマー減少
if (item_timer <= 0) { //アイテム出現
item = new ItemObj(document.getElementById('div_item'),document.getElementById('img_item')); //アイテムオブジェクトの作成
clearInterval(item_timerId); //タイマークリア
item_timerId = setInterval(itemProcess,50); //アイテム処理開始(タイマーID渡す処理)
item_timer = 400 + Math.floor(Math.random()*200);
}
//衝突判定用データ取得
// get imageData object from canvas
imagedata = ctx[1].getImageData(0, 0, canvas[1].width, canvas[1].height);
// get pixelArray from imagedata object
data_i = imagedata.data;
eng += eng_rec; //エネルギー自然回復
if (eng > 463) {
eng = 463;
}
damage -= damage_rec; //ダメージ自然回復
if (damage < 0) {
damage = 0;
}
if (damage > 463) {
gameover();
}
}
//ゲームオーバー処理
function gameover() {
screenstatus = 2;
audio[0].pause(); //BGM演奏停止
try{ //IEエラー回避処理用
audio[0].currentTime = 0;
} catch(e){
}
audio[45].play(); //効果音
clearInterval(main_timerId);
//ミサイルタイマーリセット、ライフゼロ、非表示
for (i=0; i<=99; i++) {
clearInterval(mis_timerId[i]); //タイマークリア
missile[i].life = 0;
document.getElementById('div_missile'+i).style.left = '-120px';
document.getElementById('div_missile'+i).style.top = '-120px';
}
clearInterval(item_timerId);
item = {life: 0};
document.getElementById('div_item').style.left = '-120px';
document.getElementById('div_item').style.top = '-120px';
document.getElementById('caution').textContent = '';
setTimeout(gameoverHyoji,5500);
setTimeout(top_title,11500);
}
//ゲームオーバー表示処理
function gameoverHyoji(){
document.getElementById('div_gameover').style.left = '0px';
}
function misProcess(num) { //ミサイル処理用関数
missile[num].process();
if (missile[num].life <= 0) { //ミサイルライフ0ならタイマー終了
clearInterval(mis_timerId[num]);
}
}
function itemProcess() { //アイテム処理用関数
item.process();
if (item.life <= 0) { //アイテムライフ0ならタイマー終了
clearInterval(item_timerId);
}
}
function laserProcess(num) { //レーザー処理用関数
laser[num].process();
if (laser[num].step <= 0) { //レーザーステップ0ならタイマー終了
clearInterval(laser_timerId[num]);
}
}
function expProcess(num) { //爆風処理用関数
explosion[num].process();
if (explosion[num].life < 0) { //爆風ライフ0未満ならタイマー終了
clearInterval(exp_timerId[num]);
}
}
//爆風コンストラクタ
function ExpObj(_xpos,_ypos,_maxrad,_color){
this.x = _xpos; //X座標
this.y = _ypos; //Y座標
this.maxrad = _maxrad; //最大半径
this.life = _maxrad * 2; //爆風ライフ
this.rad = 0; //爆風半径
this.color = _color; //爆風色
this.process = function() { //爆風処理
if (this.life >= this.maxrad) {
this.rad = this.maxrad * 2 - this.life + 2;
ctx[1].strokeStyle = this.color;
ctx[1].fillStyle = this.color;
ctx[1].lineWidth = 4;
ctx[1].globalCompositeOperation = 'source-over'; //透明処理解除
ctx[1].beginPath();
ctx[1].arc(this.x,this.y,this.rad,0,Math.PI*2,true);
ctx[1].stroke();
} else {
this.rad = this.life + 6;
ctx[1].strokeStyle = '#000000';
ctx[1].fillStyle = '#000000';
ctx[1].lineWidth = 4;
ctx[1].globalCompositeOperation = 'destination-out'; //透明処理で裏のレイヤーを表示できるようにする
ctx[1].beginPath();
if (this.rad > 6) {
ctx[1].arc(Math.floor(this.x),Math.floor(this.y),this.rad,0,Math.PI*2,true);
} else {
ctx[1].lineWidth = 8;
ctx[1].arc(Math.floor(this.x),Math.floor(this.y),4,0,Math.PI*2,true);
}
ctx[1].stroke();
}
this.life -= 2;
}
}
//レーザーコンストラクタ
function LaserObj(_xpos,_ypos){
this.x = _xpos; //X座標
this.y = _ypos; //Y座標
this.step = 3; //ステップ
ctx[2].strokeStyle = '#0000ff';
ctx[2].fillStyle = '#0000ff';
ctx[2].lineWidth = 2;
ctx[2].globalCompositeOperation = 'source-over'; //透明処理解除
ctx[2].beginPath();
ctx[2].moveTo(0,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
ctx[2].moveTo(539,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
this.process = function() { //レーザー表示処理
switch (this.step) {
case 3:
ctx[2].strokeStyle = '#8888ff';
ctx[2].fillStyle = '#8888ff';
ctx[2].lineWidth = 1;
ctx[2].globalCompositeOperation = 'source-over'; //透明処理解除
ctx[2].beginPath();
ctx[2].moveTo(0,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
ctx[2].moveTo(539,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
break;
case 2:
ctx[2].strokeStyle = '#ffffff';
ctx[2].fillStyle = '#ffffff';
ctx[2].lineWidth = 1;
ctx[2].lineCap = 'butt';
ctx[2].globalCompositeOperation = 'source-over'; //透明処理解除
ctx[2].beginPath();
ctx[2].moveTo(0,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
ctx[2].moveTo(539,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
break;
case 1:
ctx[2].strokeStyle = '#000000';
ctx[2].fillStyle = '#000000';
ctx[2].lineWidth = 3;
ctx[2].lineCap = 'round';
ctx[2].globalCompositeOperation = 'destination-out'; //透明処理で裏のレイヤーを表示できるようにする
ctx[2].beginPath();
ctx[2].moveTo(0,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
ctx[2].moveTo(539,539);
ctx[2].lineTo(this.x,this.y);
ctx[2].stroke();
break;
}
this.step -= 1;
}
}
//ミサイルコンストラクタ
function MisObj(_elem,_img,_type,_appendix,_xpos,_ypos){
this.elem = _elem; //ミサイル表示エレメント
this.img = _img; //ミサイル画像エレメント
this.type = _type; //ミサイル種類
this.appendix = _appendix; //付加プロパティ(分裂ミサイル用など)
this.x = _xpos; //X座標(暫定)
this.y = _ypos; //Y座標(暫定)
this.img.src = missile_data[this.type].image; //ミサイル画像
this.width = missile_data[this.type].width; //ミサイル太さ(直径)
this.length = missile_data[this.type].length; //ミサイル長さ
this.speed = missile_data[this.type].speed; //スピード
this.life = missile_data[this.type].life; //ミサイルライフ
this.maxradius = missile_data[this.type].maxradius; //爆風最大径
this.damage = missile_data[this.type].damage; //与えられるダメージ
this.score = missile_data[this.type].score; //得点
switch (this.type) {
case 0:
case 1:
case 2:
case 30:
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
this.dx = 0; //X移動量
this.dy = missile_data[this.type].speed; //Y移動量
break;
case 3:
case 4:
case 31:
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
this.dx = Math.random()*missile_data[this.type].speed*1.6 - missile_data[this.type].speed*0.8; //X移動量
this.dy = Math.sqrt(Math.abs(missile_data[this.type].speed*missile_data[this.type].speed - this.dx*this.dx)); //Y移動量
break;
case 5:
case 8:
case 32:
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
this.dx = 0; //X移動量
this.dy = missile_data[this.type].speed; //Y移動量
break;
case 6:
case 9:
case 33:
if (this.appendix == null) {
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
this.appendix = 100; //分裂Y座標がこの分上になる
}
if (this.appendix == 1) { //分裂左
this.dx = -missile_data[this.type].speed * 0.7;
this.dy = missile_data[this.type].speed * 0.7;
} else if (this.appendix == 2) { //分裂右
this.dx = missile_data[this.type].speed * 0.7;
this.dy = missile_data[this.type].speed * 0.7;
} else { //分裂真ん中
this.dx = 0; //X移動量
this.dy = missile_data[this.type].speed; //Y移動量
}
break;
case 7:
case 10:
case 34:
if (this.appendix == null) {
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
this.appendix = 100;
}
if (this.appendix == 1) { //分裂左
this.dx = -missile_data[this.type].speed * 0.7;
this.dy = missile_data[this.type].speed * 0.7;
} else if (this.appendix == 2) { //分裂右
this.dx = missile_data[this.type].speed * 0.7;
this.dy = missile_data[this.type].speed * 0.7;
} else { //分裂真ん中
this.dx = 0; //X移動量
this.dy = missile_data[this.type].speed; //Y移動量
}
break;
case 11:
case 12:
case 35:
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
this.dx = Math.random()*16 - 8; //X移動量
this.dy = 3; //Y移動量
this.appendix = 0; //状態1になると加速開始
break;
case 13:
case 14:
case 36:
this.x = Math.floor(Math.random()*(539-this.width - 72)) + Math.floor(this.width/2) + 36; //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
if (Math.random()<0.5) {
this.dx = -8; //X移動量
this.appendix = 0 //状態
} else {
this.dx = 8; //X移動量
this.appendix = 1 //状態
}
this.dy = this.speed; //Y移動量
break;
case 50:
this.x = Math.floor(Math.random()*(539-this.width)) + Math.floor(this.width/2); //X座標 = ミサイル真ん中
this.y = -1; //Y座標 = ミサイル先端部
if (Math.random()<0.5) {
this.dx = missile_data[this.type].speed; //X移動量
} else {
this.dx = -missile_data[this.type].speed; //Y移動量
}
this.dy = 2; //Y移動量
this.appendix = 0; //手裏剣回転状態
break;
case 51:
this.dx = 0; //X移動量
this.dy = missile_data[this.type].speed; //Y移動量
break;
}
this.img.style.width = this.width; //ミサイル表示太さ
this.img.style.height = this.length; //ミサイル表示長さ
this.elem.style.left = Math.floor((this.x - this.width/2)) + 'px';
this.elem.style.top = Math.floor((this.y - this.length)) + 'px';
this.process = function() { //ミサイル移動処理
switch (this.type) {
case 0:
case 1:
case 2:
case 30:
this.x += this.dx;
this.y += this.dy;
break;
case 3:
case 4:
case 31:
this.x += this.dx;
this.y += this.dy;
if ((this.x - this.width/2) < 0) {
this.x = this.width/2;
this.dx = -this.dx;
}
if ((this.x + this.width/2) > 539) {
this.x = 540 - this.width/2;
this.dx = -this.dx;
}
break;
case 5: //分裂ミサイル状態1
case 8:
case 32:
this.x += this.dx;
this.y += this.dy;
if ((this.x - this.width/2) < 0) {
this.x = this.width/2;
this.dx = -this.dx;
}
if ((this.x + this.width/2) > 539) {
this.x = 540 - this.width/2;
this.dx = -this.dx;
}
if ((this.y > 100)&&(Math.random() < 0.1)) { //分裂1
this.type += 1; //ミサイル種類変更
this.appendix = 0; //付加プロパティ(分裂ミサイル真ん中)
this.img.src = missile_data[this.type].image; //ミサイル画像
this.width = missile_data[this.type].width; //ミサイル太さ(直径)
this.length = missile_data[this.type].length; //ミサイル長さ
this.speed = missile_data[this.type].speed; //スピード
this.life = missile_data[this.type].life; //ライフ
this.maxradius = missile_data[this.type].maxradius; //爆風最大径
this.damage = missile_data[this.type].damage; //ダメージ
this.score = missile_data[this.type].score; //得点
this.img.style.width = this.width; //ミサイル表示太さ
this.img.style.height = this.length; //ミサイル表示長さ
this.dx = 0; //X移動量
this.dy = this.speed; //Y移動量
audio[49+split_sound].play(); //効果音
split_sound = (split_sound < 2)?split_sound + 1: 0; //ミサイル分裂サウンド順番+1、2より上は0に戻す
if (missile[mis_num].life <= 0) { //分裂ミサイル左
missile[mis_num] = new MisObj(document.getElementById('div_missile'+mis_num),document.getElementById('img_missile'+mis_num),this.type,1,this.x,this.y); //ミサイルオブジェクトの作成
clearInterval(mis_timerId[mis_num]); //タイマークリア
mis_timerId[mis_num] = setInterval(misProcess,100,mis_num); //ミサイル処理開始(タイマーID渡す処理)
mis_num = (mis_num < 99)?mis_num + 1 : 0;
}
if (missile[mis_num].life <= 0) { //分裂ミサイル右
missile[mis_num] = new MisObj(document.getElementById('div_missile'+mis_num),document.getElementById('img_missile'+mis_num),this.type,2,this.x,this.y); //ミサイルオブジェクトの作成
clearInterval(mis_timerId[mis_num]); //タイマークリア
mis_timerId[mis_num] = setInterval(misProcess,100,mis_num); //ミサイル処理開始(タイマーID渡す処理)
mis_num = (mis_num < 99)?mis_num + 1 : 0;
}
}
break;
case 6: //分裂ミサイル状態2
case 9:
case 33:
this.x += this.dx;
this.y += this.dy;
if ((this.x - this.width/2) < 0) {
this.x = this.width/2;
this.dx = -this.dx;
}
if ((this.x + this.width/2) > 539) {
this.x = 540 - this.width/2;
this.dx = -this.dx;
}
if ((this.y > (220 - this.appendix))&&(Math.random() < 0.08)) { //分裂2
this.type += 1; //ミサイル種類変更
this.appendix = 0; //付加プロパティ(分裂ミサイル真ん中)
this.img.src = missile_data[this.type].image; //ミサイル画像
this.width = missile_data[this.type].width; //ミサイル太さ(直径)
this.length = missile_data[this.type].length; //ミサイル長さ
this.speed = missile_data[this.type].speed; //スピード
this.life = missile_data[this.type].life; //ライフ
this.maxradius = missile_data[this.type].maxradius; //爆風最大径
this.damage = missile_data[this.type].damage; //ダメージ
this.score = missile_data[this.type].score; //得点
this.img.style.width = this.width; //ミサイル表示太さ
this.img.style.height = this.length; //ミサイル表示長さ
this.dx = 0; //X移動量
this.dy = this.speed; //Y移動量
audio[49+split_sound].play(); //効果音
split_sound = (split_sound < 2)?split_sound + 1: 0; //ミサイル分裂サウンド順番+1、2より上は0に戻す
if (missile[mis_num].life <= 0) { //分裂ミサイル左
missile[mis_num] = new MisObj(document.getElementById('div_missile'+mis_num),document.getElementById('img_missile'+mis_num),this.type,1,this.x,this.y); //ミサイルオブジェクトの作成
clearInterval(mis_timerId[mis_num]); //タイマークリア
mis_timerId[mis_num] = setInterval(misProcess,100,mis_num); //ミサイル処理開始(タイマーID渡す処理)
mis_num = (mis_num < 99)?mis_num + 1 : 0;
}
if (missile[mis_num].life <= 0) { //分裂ミサイル右
missile[mis_num] = new MisObj(document.getElementById('div_missile'+mis_num),document.getElementById('img_missile'+mis_num),this.type,2,this.x,this.y); //ミサイルオブジェクトの作成
clearInterval(mis_timerId[mis_num]); //タイマークリア
mis_timerId[mis_num] = setInterval(misProcess,100,mis_num); //ミサイル処理開始(タイマーID渡す処理)
mis_num = (mis_num < 99)?mis_num + 1 : 0;
}
}
break;
case 7: //分裂ミサイル状態3
case 10:
case 34:
this.x += this.dx;
this.y += this.dy;
if ((this.x - this.width/2) < 0) {
this.x = this.width/2;
this.dx = -this.dx;
}
if ((this.x + this.width/2) > 539) {
this.x = 540 - this.width/2;
this.dx = -this.dx;
}
break;
case 11:
case 12:
case 35:
if ((this.y > 20)&&(this.appendix == 0)&&(Math.random() < 0.05)){ //Y座標指定より下で確率が合えば加速開始
this.appendix = 1;
this.img.src = 'missile4a.gif';
audio[53+acc_sound].play(); //効果音
acc_sound = (acc_sound < 2)?acc_sound + 1: 0; //ミサイル点火サウンド順番+1、2より上は0に戻す
}
if (this.appendix == 1) {
this.dy = (this.dy < this.speed)? this.dy+1: this.speed; //指定速度まで加速
}
this.x += this.dx;
this.y += this.dy;
if ((this.x - this.width/2) < 0) {
this.x = this.width/2;
this.dx = -this.dx;
}
if ((this.x + this.width/2) > 539) {
this.x = 540 - this.width/2;
this.dx = -this.dx;
}
break;
case 13:
case 14:
case 36:
this.x += this.dx;
this.y += this.dy;
if(this.appendix == 0){
this.dx += 1;
if (this.dx >8){
this.dx = 8;
this.appendix = 1;
}
} else {
this.dx -=1
if (this.dx <-8){
this.dx = -8;
this.appendix = 0;
}
}
break;
case 50:
this.x += this.dx;
this.y += this.dy;
if ((this.x - this.width/2) < 0) {
this.x = this.width/2;
this.dx = -this.dx;
}
if ((this.x + this.width/2) > 539) {
this.x = 540 - this.width/2;
this.dx = -this.dx;
}
if ((missile[mis_num].life <= 0)&&(this.appendix == 0)) { //ボスミサイル発射
missile[mis_num] = new MisObj(document.getElementById('div_missile'+mis_num),document.getElementById('img_missile'+mis_num),51,0,this.x,this.y); //ミサイルオブジェクトの作成
clearInterval(mis_timerId[mis_num]); //タイマークリア
mis_timerId[mis_num] = setInterval(misProcess,100,mis_num); //ミサイル処理開始(タイマーID渡す処理)
mis_num = (mis_num < 99)?mis_num + 1 : 0;
audio[59+bosmis_sound].play(); //効果音
bosmis_sound = (bosmis_sound < 2)?bosmis_sound + 1: 0; //ボスミサイル発射サウンド順番+1、2より上は0に戻す
}
this.appendix = (this.appendix < 9)?this.appendix+1 : 0; //手裏剣アニメ処理
break;
case 51:
this.x += this.dx;
this.y += this.dy;
break;
}
//衝突判定処理
var shototsu1 = 0, shototsu2 = 0, shototsu3 = 0, shototsu4 = 0, shototsu5 = 0, shototsu6 = 0;
if (this.type != 50) {
// calculate offset into array for pixel
if ((this.y >=0)&&(this.y <= 539)) {
var i1 = (Math.floor(this.y) * canvas[1].width + Math.floor(this.x)) * 4; //ミサイル下
shototsu1 = (data_i[i1]+data_i[i1+1]+data_i[i1+2])*data_i[i1+3]/255;
}
if ((this.y > this.length/2)&&(this.y <= 539 + this.length/2)) {
var i4 = (((Math.floor(this.y)-Math.floor(this.length/2)) * canvas[1].width) + Math.floor(this.x)) * 4; //ミサイル中心
shototsu4 = (data_i[i4]+data_i[i4+1]+data_i[i4+2])*data_i[i4+3]/255;
}
if ((this.y > this.length)&&(this.y <= 539 + this.length)) {
var i2 = (((Math.floor(this.y)-this.length) * canvas[1].width) + (Math.floor(this.x-this.width/2))) * 4; //ミサイル左上
var i3 = (((Math.floor(this.y)-this.length) * canvas[1].width) + (Math.floor(this.x+this.width/2))) * 4; //ミサイル右上
shototsu2 = (data_i[i3]+data_i[i3+1]+data_i[i3+2])*data_i[i3+3]/255+(data_i[i2]+data_i[i2+1]+data_i[i2+2])*data_i[i2+3]/255;
}
} else {
//ボス専用当たり判定
// calculate offset into array for pixel
if ((this.y >=0)&&(this.y <= 539)) {
var i1 = (Math.floor(this.y) * canvas[1].width + Math.floor(this.x)) * 4; //ボス下
shototsu1 = (data_i[i1]+data_i[i1+1]+data_i[i1+2])*data_i[i1+3]/255;
}
if ((this.y > this.length/4)&&(this.y <= 539 + this.length/4)) {
var i3 = (((Math.floor(this.y)-this.length/4) * canvas[1].width) + Math.floor(this.x)) * 4; //ボス1/4下
shototsu3 = (data_i[i3]+data_i[i3+1]+data_i[i3+2])*data_i[i3+3]/255;
}
if ((this.y > this.length/2)&&(this.y <= 539 + this.length/2)) {
var i4 = (((Math.floor(this.y)-Math.floor(this.length/2)) * canvas[1].width) + Math.floor(this.x)) * 4; //ボス中心
var i5 = (((Math.floor(this.y)-Math.floor(this.length/2)) * canvas[1].width) + (Math.floor(this.x-this.width/2))) * 4; //ボス中左
var i6 = (((Math.floor(this.y)-Math.floor(this.length/2)) * canvas[1].width) + (Math.floor(this.x+this.width/2))) * 4; //ボス中右
var i8 = (((Math.floor(this.y)-Math.floor(this.length/2)) * canvas[1].width) + (Math.floor(this.x-this.width/4))) * 4; //ボス中左1/4
var i9 = (((Math.floor(this.y)-Math.floor(this.length/2)) * canvas[1].width) + (Math.floor(this.x+this.width/4))) * 4; //ボス中右1/4
shototsu4 = (data_i[i4]+data_i[i4+1]+data_i[i4+2])*data_i[i4+3]/255+(data_i[i5]+data_i[i5+1]+data_i[i5+2])*data_i[i5+3]/255+(data_i[i6]+data_i[i6+1]+data_i[i6+2])*data_i[i6+3]/255+(data_i[i8]+data_i[i8+1]+data_i[i8+2])*data_i[i8+3]/255+(data_i[i9]+data_i[i9+1]+data_i[i9+2])*data_i[i9+3]/255;
}
if ((this.y > this.length*0.75)&&(this.y <= 539 + this.length*0.75)) {
var i7 = (((Math.floor(this.y)-this.length*0.75) * canvas[1].width) + Math.floor(this.x)) * 4; //ボス1/4上
shototsu5 = (data_i[i7]+data_i[i7+1]+data_i[i7+2])*data_i[i7+3]/255;
}
if ((this.y > this.length)&&(this.y <= 539 + this.length)) {
var i2 = (((Math.floor(this.y)-this.length) * canvas[1].width) + Math.floor(this.x)) * 4; //ボス上
shototsu2 = (data_i[i2]+data_i[i2+1]+data_i[i2+2])*data_i[i2+3]/255;
}
}
// document.getElementById('checker').textContent = data_i[i3]+' '+data_i[i3+1]+' '+data_i[i3+2]+' ' + data_i[i3+3] + ' ' + shototsu3; //チェッカー
//爆風衝突の場合
if ((shototsu1 + shototsu2 + shototsu3 + shototsu4 + shototsu5 >= 250)) {
if (this.life >= 2) { //ボスキャラ用処理(ダメージ有り)
switch(this.type){
case 30:
this.img.src = 'missile1_l.gif';
break;
case 31:
this.img.src = 'missile2_l.gif';
break;
case 32:
this.img.src = 'missile3_l.gif';
break;
case 33:
this.img.src = 'missile3a_l.gif';
break;
case 34:
this.img.src = 'missile3b_l.gif';
break;
case 35:
if (this.appendix == 0) {
this.img.src = 'missile4_l.gif';
} else {
this.img.src = 'missile4a_l.gif';
}
break;
case 36:
this.img.src = 'missile5_l.gif';
break;
case 50:
this.img.src = 'boss'+ Math.floor(this.appendix/2) +'_l.gif';
break;
case 51:
this.img.src = 'missileboss_l.gif';
break;
}
audio[56+hit_sound].play(); //効果音
hit_sound = (hit_sound < 2)?hit_sound + 1: 0; //サウンド順番+1、2より上は0に戻す
}
this.life -= 1;
if (this.life <= 0) {
clearInterval(exp_timerId[exp_num]); //爆風タイマークリア
explosion[exp_num] = new ExpObj(Math.floor(this.x),Math.floor(this.y - this.length/2),this.maxradius,'#aaaaaa'); //爆風オブジェクトの作成
hit += 1; //ヒット数
score += missile_data[this.type].score; //スコア加算
exp_timerId[exp_num] = setInterval(expProcess,100,exp_num); //爆風処理開始(タイマーID渡す処理)
audio[20+(exp_num % 20)].play(); //効果音
exp_num = (exp_num < 99)?exp_num + 1: 0; //爆風順番+1、99より上は0に戻す
//画面外に消す
this.x = -120;
this.y = -120;
}
} else if ((this.life >=1)||(this.type == 50)) { //ボスキャラ用処理(ダメージ無し)
switch(this.type){
case 30:
this.img.src = 'missile1.gif';
break;
case 31:
this.img.src = 'missile2.gif';
break;
case 32:
this.img.src = 'missile3.gif';
break;
case 33:
this.img.src = 'missile3a.gif';
break;
case 34:
this.img.src = 'missile3b.gif';
break;
case 35:
if (this.appendix == 0) {
this.img.src = 'missile4.gif';
} else {
this.img.src = 'missile4a.gif';
}
break;
case 36:
this.img.src = 'missile5.gif';
break;
case 50:
this.img.src = 'boss' + Math.floor(this.appendix/2) + '.gif';
break;
case 51:
this.img.src = 'missileboss.gif';
break;
}
}
if (this.y - this.length / 2 > 539) { //画面一番下に到達したら
this.life = 0;
damage += this.damage;
clearInterval(exp_timerId[exp_num]); //爆風タイマークリア
explosion[exp_num] = new ExpObj(this.x,this.y - Math.floor(this.length / 4 * 3),Math.floor(Math.sqrt(this.damage+20))*5,'#ff0000'); //爆風オブジェクトの作成
exp_timerId[exp_num] = setInterval(expProcess,100,exp_num); //爆風処理開始(タイマーID渡す処理)
exp_num = (exp_num < 99)?exp_num + 1: 0; //爆風順番+1、99より上は0に戻す
audio[40+damage_sound].play(); //効果音
damage_sound = (damage_sound < 4)?damage_sound + 1: 0; //ダメージサウンド順番+1、4より上は0に戻す
//画面外に消す
this.x = -120;
this.y = -120;
}
this.elem.style.left = Math.floor((this.x - this.width/2)) + 'px';
this.elem.style.top = Math.floor((this.y - this.length)) + 'px';
}
}
//アイテムコンストラクタ
function ItemObj(_elem,_img){
this.elem = _elem; //アイテム表示エレメント
this.img = _img; //アイテム画像エレメント
if (round <= 3) {
this.type = 0; //ラウンドが若いうちはアイテムエネルギー固定
} else if ((round >= 12)&&(round <= 15)&&(exp_rad <= 22)) {
this.type = 2; //ラウンド12以降で爆風半径が変わっていない場合はアイテム爆風半径大固定
} else {
this.type = Math.floor(Math.random() * 5); //アイテム種類
}
if (Math.random() < 0.5) {
this.x = -28; //X座標(暫定)
this.dx = + 4; //X座標移動量
} else {
this.x = 540; //X座標(暫定)
this.dx = - 4; //X座標移動量
}
this.y = Math.random()*500; //Y座標
this.img.src = 'item' + this.type + '.gif'; //アイテム画像
this.life = 100; //アイテムライフ
this.elem.style.left = this.x + 'px';
this.elem.style.top = this.y + 'px'
this.process = function() { //アイテム移動処理
this.x += this.dx
//衝突判定処理
// calculate offset into array for pixel
if (this.x >= 0) {
var i1 = ((Math.floor(this.y) + 8) * canvas[1].width + Math.floor(this.x)) * 4;
} else {
var i1 = ((Math.floor(this.y) + 8) * canvas[1].width + 0) * 4;
}
if (this.x <= 509) {
var i3 = ((Math.floor(this.y) + 8) * canvas[1].width + Math.floor(this.x) + 30) * 4;
} else {
var i3 = ((Math.floor(this.y) + 8) * canvas[1].width + 539) * 4;
}
if ((this.x >= 15)&&(this.x <= 494)) {
var i2= ((Math.floor(this.y)) * canvas[1].width + this.x + 15) * 4;
var i4= ((Math.floor(this.y) + 16) * canvas[1].width + this.x + 15) * 4;
} else {
var i2 = i1;
var i4 = i2;
}
// get RGBA values
var shototsu1 = (data_i[i1]+data_i[i1+1]+data_i[i1+2])*data_i[i1+3]/255;
var shototsu2 = (data_i[i2]+data_i[i2+1]+data_i[i2+2])*data_i[i2+3]/255;
var shototsu3 = (data_i[i3]+data_i[i3+1]+data_i[i3+2])*data_i[i3+3]/255;
var shototsu4 = (data_i[i4]+data_i[i4+1]+data_i[i4+2])*data_i[i4+3]/255;
//爆風衝突の場合
if ((shototsu1 >= 750)||(shototsu2 >= 750)||(shototsu3 >= 750)||(shototsu4 >= 750)) {
this.life = 0;
hit += 1; //ヒット数
audio[52].play(); //効果音
switch(this.type) {
case 0: //エネルギー回復
eng += 150;
break;
case 1: //ダメージ回復
damage -= 200;
break;
case 2: //爆風半径大
exp_rad += 4;
if (exp_rad > 40) {
exp_rad = 40;
}
break;
case 3: //ボーナス
score += 1000;
eng += 30;
damage -= 30;
break;
case 4: //ミサイル全滅
for (i=0; i<=99; i++){
if (missile[i].life > 0) {
clearInterval(exp_timerId[exp_num]); //爆風タイマークリア
explosion[exp_num] = new ExpObj(Math.floor(missile[i].x),Math.floor(missile[i].y - missile[i].width),missile[i].maxradius,'#aaaaaa'); //爆風オブジェクトの作成
score += missile[i].score; //スコア加算
exp_timerId[exp_num] = setInterval(expProcess,100,exp_num); //爆風処理開始(タイマーID渡す処理)
audio[20+(exp_num % 20)].play(); //効果音
exp_num = (exp_num < 99)?exp_num + 1: 0; //爆風順番+1、99より上は0に戻す
missile[i].life = 0;
document.getElementById('div_missile'+i).style.left = '-120px';
document.getElementById('div_missile'+i).style.top = '-120px';
clearInterval(mis_timerId[i]); //ミサイルタイマークリア
}
}
}
clearInterval(item_timerId); //アイテムタイマークリア
//画面外に消す
this.x = -120;
this.y = -120;
}
if ((this.x < -28)||(this.x > 540)) {
this.life = 0;
clearInterval(item_timerId); //アイテムタイマークリア
}
this.elem.style.left = this.x + 'px';
this.elem.style.top = this.y + 'px'
}
}
//爆風&レーザー開始処理
function circleDraw(drawx,drawy){
if ((eng >= exp_con)&&(drawx>=0)&&(drawy>=0)&&(drawx<=539)&&(drawy<=539)) {
eng -= exp_con; //エネルギー減
clearInterval(laser_timerId[laser_num]); //タイマークリア
laser[laser_num] = new LaserObj(drawx,drawy); //レーザーオブジェクトの作成
laser_timerId[laser_num] = setInterval(laserProcess,100,laser_num); //レーザー処理開始(タイマーID渡す処理)
if (audio_status == 1) {
audio[10+(laser_num % 10)].play(); //効果音
}
laser_num = (laser_num < 20)?laser_num + 1: 0; //レーザー順番+1、10より上は0に戻す
fire += 1; //発射回数
clearInterval(exp_timerId[exp_num]); //タイマークリア
explosion[exp_num] = new ExpObj(drawx,drawy,exp_rad,'#ffffff'); //爆風オブジェクトの作成
exp_timerId[exp_num] = setInterval(expProcess,100,exp_num); //爆風処理開始(タイマーID渡す処理)
exp_num = (exp_num < 99)?exp_num + 1: 0; //爆風順番+1、99より上は0に戻す
} else if (eng < exp_con) {
if (audio_status == 1) {
audio[46+emp_sound].play(); //効果音
}
emp_sound = (emp_sound < 2)?emp_sound + 1: 0; //EMPTYサウンド順番+1、2より上は0に戻す
}
}
//エネルギー表示処理
function energyHyoji(){
var h_eng = Math.floor(eng);
if (h_eng > 463) {
h_eng = 463;
}
document.getElementById('img_bar1').style.width = parseInt(h_eng);
if ((h_eng < exp_con)&&(screenstatus == 1)) {
document.getElementById('caution').textContent = 'ENERGY EMPTY!';
} else {
document.getElementById('caution').textContent = '';
}
}
//ダメージ表示処理
function damageHyoji(){
var h_damage = Math.floor(damage);
if (h_damage < 0) {
h_damage = 0;
}
if (h_damage > 463) {
h_damage = 463;
}
if (h_damage > 263) {
document.getElementById('backred').style.opacity = (h_damage - 263)/200;
} else {
document.getElementById('backred').style.opacity = 0;
}
document.getElementById('img_bar2').style.width = parseInt(h_damage);
}
//スコア表示処理
function scoreHyoji(){
document.getElementById('your_score').textContent = score;
if (score > best_score) {
best_score = score;
document.getElementById('best_score').textContent = best_score;
}
}
//発射数、ヒット数、ヒット確率表示処理
function fireHyoji(){
document.getElementById('fire').textContent = fire;
document.getElementById('hit').textContent = hit;
if (fire > 0) {
rate = Math.floor(hit / fire * 1000 + 0.5) / 10;
} else {
rate = 0;
}
document.getElementById('rate').textContent = rate;
}
//タッチパネル処理
function processTouch(evt){
//タッチオブジェクト
var touchObj = evt.changedTouches[0];
//タッチのX座標、Y座標取得
var touchX = parseInt(touchObj.pageX);
var touchY = parseInt(touchObj.pageY);
if (screenstatus == 1) {
//爆風処理
circleDraw(touchX,touchY);
}
}
//マウス処理
function processMouse(evt){
//マウスのX座標、Y座標取得
var mouseX = parseInt(evt.pageX);
var mouseY = parseInt(evt.pageY);
if (screenstatus == 1) {
//爆風処理
circleDraw(mouseX,mouseY);
}
}
function audio_change() { //オーディオ有無
if (audio_status == 1) {
audio_status = 0;
document.getElementById('button_audio').src = 'audio_off.gif';
for (i=0; i<audio_files.length; i++){
audio[i].muted = true;
}
audio[0].pause(); //BGM停止
} else {
audio_status = 1;
document.getElementById('button_audio').src = 'audio_on.gif';
for (i=0; i<audio_files.length; i++){
audio[i].muted = false;
}
if (screenstatus == 1) {
audio[0].play(); //BGM演奏
}
}
}
function lang_change() { //言語選択
if (lang_status == 1) {
lang_status = 0;
document.getElementById('button_lang').src = 'lang_jp.gif';
document.getElementById('title').src = 'title.gif';
document.getElementById('button_start').src = 'start.gif';
document.getElementById('gameover').src = 'gameover.gif';
document.getElementById('title_contents').innerHTML = ' 【 ゲームの遊び方 】<br> 『スタート』ボタンをクリックまたはタップでゲームスタート<br>画面をクリックまたはタップをすると爆発が発生<br>連鎖爆発を利用してミサイルをどんどんやっつけよう!';
} else {
lang_status = 1;
document.getElementById('button_lang').src = 'lang_en.gif';
document.getElementById('title').src = 'title_en.gif';
document.getElementById('button_start').src = 'start_en.gif';
document.getElementById('gameover').src = 'gameover_en.gif';
document.getElementById('title_contents').innerHTML = '[ HOW TO PLAY ]<br>Click or tap the "START" button below to start the game.<br>An explosion begins where you click or tap in the screen.<br>Destroy missiles by chain explosions!';
}
}
//タッチパネル処理
if ((window.TouchEvent)&&(window.innerHeight > window.innerWidth)){
window.addEventListener('touchstart', processTouch);
} else {
//マウスボタン処理
window.addEventListener('mousedown', processMouse);
}
//エネルギー表示
clearInterval(eng_timerId);
eng_timerId = setInterval(energyHyoji,199);
//ダメージ表示
clearInterval(damage_timerId);
damage_timerId = setInterval(damageHyoji,198);
//スコア表示
clearInterval(score_timerId);
score_timerId = setInterval(scoreHyoji,297);
//発射数、ヒット数、ヒット確率表示
clearInterval(fire_timerId);
fire_timerId = setInterval(fireHyoji,396);
//マウスカーソルの変更
document.getElementById('canvas2').style.cursor = 'crosshair';
document.getElementById('div_title').style.cursor = 'crosshair';
//トップ画面表示
document.addEventListener('DOMContentLoaded',top_title());
//スマホ、タブレットの場合にはデフォルトでサウンドオフ
if ((window.TouchEvent)&&(window.innerHeight > window.innerWidth)){
audio_change();
}
</script>
</body>

↑制作の際、この本を参考にしました。
スポンサードリンク
→トップページ(ゲーム)に戻る