質問編集履歴
3
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,404 +20,4 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
```HTML
|
26
|
-
|
27
|
-
<!DOCTYPE html>
|
28
|
-
|
29
|
-
<html lang="ja">
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<head>
|
34
|
-
|
35
|
-
<meta charset="utf-8">
|
36
|
-
|
37
|
-
<title>じゃんけんゲーム</title>
|
38
|
-
|
39
|
-
<link rel="stylesheet" type="text/css" href="css/index2.css">
|
40
|
-
|
41
|
-
<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
|
42
|
-
|
43
|
-
<script type="text/javascript" src="js/underscore-min.js"></script>
|
44
|
-
|
45
|
-
<script type="text/javascript" src="js/trial2.js"></script>
|
46
|
-
|
47
|
-
<script type="text/javascript" src="js/jquery.fullImage.js"></script>
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
</head>
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<body>
|
56
|
-
|
57
|
-
<div id="wrapper" >
|
58
|
-
|
59
|
-
<div id="resultImg"></div>
|
60
|
-
|
61
|
-
<section class="remove"> <h1>じゃんけんゲーム</h1>
|
62
|
-
|
63
|
-
<INPUT type="button" id="explain" value="最初に読んで!" onClick="alert('波動拳<昇竜拳<ジャンプコンボの順に威力が大きい!\n指定されるまで次の選択をしないで????')">
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
<p class="me">選択肢を選んでください。</p>
|
68
|
-
|
69
|
-
<ol>
|
70
|
-
|
71
|
-
<li class="MySelect" data-assign="0"><img src=img/select0.jpg ></li>
|
72
|
-
|
73
|
-
<li class="MySelect" data-assign="1"><img src=img/select1.jpg ></li>
|
74
|
-
|
75
|
-
<li class="MySelect" data-assign="2"><img src=img/select2.jpg ></li>
|
76
|
-
|
77
|
-
</ol>
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="gamen">
|
82
|
-
|
83
|
-
<img id="gif" src="img/tachi.gif">
|
84
|
-
|
85
|
-
<meter id ="EnemyGage" value="1"></meter>
|
86
|
-
|
87
|
-
<meter id ="MyGage" value="1"></meter>
|
88
|
-
|
89
|
-
</div>
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
<div id="resultImg"></div>
|
98
|
-
|
99
|
-
<div id="result">Choose the Next!</div>
|
100
|
-
|
101
|
-
</section>
|
102
|
-
|
103
|
-
</div>
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
<input type="button" id="escape" value="逃げる" onclick="location.reload();" />
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
</body>
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
</html>
|
118
|
-
|
119
|
-
```
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
```javascript
|
124
|
-
|
125
|
-
// Generated by CoffeeScript 1.10.0
|
126
|
-
|
127
|
-
(function() {
|
128
|
-
|
129
|
-
$(function() {
|
130
|
-
|
131
|
-
var back, lose, win;
|
132
|
-
|
133
|
-
win = function(damage, time) {
|
134
|
-
|
135
|
-
var attack;
|
136
|
-
|
137
|
-
return attack = setTimeout(function() {
|
138
|
-
|
139
|
-
var _eneGage;
|
140
|
-
|
141
|
-
_eneGage = $('#EnemyGage').val() - damage;
|
142
|
-
|
143
|
-
$('#EnemyGage').val(_eneGage);
|
144
|
-
|
145
|
-
|
23
|
+
コード修正中です。
|
146
|
-
|
147
|
-
};
|
148
|
-
|
149
|
-
lose = function(damage, time) {
|
150
|
-
|
151
|
-
var attacked;
|
152
|
-
|
153
|
-
return attacked = setTimeout(function() {
|
154
|
-
|
155
|
-
var _myGage;
|
156
|
-
|
157
|
-
_myGage = $('#MyGage').val() - damage;
|
158
|
-
|
159
|
-
$('#MyGage').val(_myGage);
|
160
|
-
|
161
|
-
}, time);
|
162
|
-
|
163
|
-
};
|
164
|
-
|
165
|
-
back = function(time) {
|
166
|
-
|
167
|
-
var top;
|
168
|
-
|
169
|
-
return top = setTimeout(function() {
|
170
|
-
|
171
|
-
$('#gif').attr('src', 'img/tachi.gif');
|
172
|
-
|
173
|
-
$('#result').css('display', 'inline');
|
174
|
-
|
175
|
-
$('.temp').attr('class', 'MySelect');
|
176
|
-
|
177
|
-
}, time);
|
178
|
-
|
179
|
-
};
|
180
|
-
|
181
|
-
console.log;
|
182
|
-
|
183
|
-
$('.MySelect').click(function() {
|
184
|
-
|
185
|
-
var enemy, user;
|
186
|
-
|
187
|
-
enemy = _.random(0, 2);
|
188
|
-
|
189
|
-
user = Number($(this).attr('data-assign'));
|
190
|
-
|
191
|
-
console.log("OK1");
|
192
|
-
|
193
|
-
$('.MySelect').attr('class', 'temp');
|
194
|
-
|
195
|
-
$('#result').css('display', 'none');
|
196
|
-
|
197
|
-
if (user === 0) {
|
198
|
-
|
199
|
-
if (enemy === 0) {
|
200
|
-
|
201
|
-
$('#gif').attr('src', 'img/hadohado.gif');
|
202
|
-
|
203
|
-
console.log("OK2");
|
204
|
-
|
205
|
-
back(5000);
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
if (enemy === 1) {
|
210
|
-
|
211
|
-
$('#gif').attr('src', 'img/hadosyoryu.gif');
|
212
|
-
|
213
|
-
win(0.2, 1700);
|
214
|
-
|
215
|
-
back(5000);
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
if (enemy === 2) {
|
220
|
-
|
221
|
-
$('#gif').attr('src', 'img/hadoujp.gif');
|
222
|
-
|
223
|
-
lose(0.4, 2500);
|
224
|
-
|
225
|
-
back(4200);
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
if (user === 1) {
|
232
|
-
|
233
|
-
if (enemy === 0) {
|
234
|
-
|
235
|
-
$('#gif').attr('src', 'img/syoryuhado.gif');
|
236
|
-
|
237
|
-
lose(0.2, 1600);
|
238
|
-
|
239
|
-
back(4400);
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
if (enemy === 1) {
|
244
|
-
|
245
|
-
$('#gif').attr('src', 'img/syoryusyoryu.gif');
|
246
|
-
|
247
|
-
back(3000);
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
if (enemy === 2) {
|
252
|
-
|
253
|
-
$('#gif').attr('src', 'img/syoryujp.gif');
|
254
|
-
|
255
|
-
win(0.3, 1400);
|
256
|
-
|
257
|
-
back(3950);
|
258
|
-
|
259
|
-
}
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
if (user === 2) {
|
264
|
-
|
265
|
-
if (enemy === 0) {
|
266
|
-
|
267
|
-
$('#gif').attr('src', 'img/jphadou.gif');
|
268
|
-
|
269
|
-
win(0.4, 3000);
|
270
|
-
|
271
|
-
back(5000);
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
if (enemy === 1) {
|
276
|
-
|
277
|
-
$('#gif').attr('src', 'img/jpsyoryu.gif');
|
278
|
-
|
279
|
-
lose(0.3, 2600);
|
280
|
-
|
281
|
-
back(4000);
|
282
|
-
|
283
|
-
}
|
284
|
-
|
285
|
-
if (enemy === 2) {
|
286
|
-
|
287
|
-
$('#gif').attr('src', 'img/jpjp.gif');
|
288
|
-
|
289
|
-
setTimeout(function() {
|
290
|
-
|
291
|
-
var _eneGage, _myGage;
|
292
|
-
|
293
|
-
_myGage = $('#MyGage').val() - 0.2;
|
294
|
-
|
295
|
-
$('#MyGage').val(_myGage);
|
296
|
-
|
297
|
-
_eneGage = $('#EnemyGage').val() - 0.2;
|
298
|
-
|
299
|
-
return $('#EnemyGage').val(_eneGage);
|
300
|
-
|
301
|
-
}, 2500);
|
302
|
-
|
303
|
-
return back(3600);
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
/* if enemy is 0 and user is 1
|
312
|
-
|
313
|
-
$('#gif').attr "src","img/syoryuhado.gif" #相手波動拳自分昇竜件#
|
314
|
-
|
315
|
-
rest_me = document.getElementById "MyGage"
|
316
|
-
|
317
|
-
ratio = rest_me.value
|
318
|
-
|
319
|
-
rest_me.value -= 0.1
|
320
|
-
|
321
|
-
if enemy is 0 and user is 2
|
322
|
-
|
323
|
-
$('#gif').attr "src","img/jphadou.gif" #相手波動拳自分ジャンプ#
|
324
|
-
|
325
|
-
rest_enemy = document.getElementById "EnemyGage"
|
326
|
-
|
327
|
-
#rest_enemy = $("#EnemyGage").val
|
328
|
-
|
329
|
-
console.log(rest_enemy)
|
330
|
-
|
331
|
-
setTimeout ->
|
332
|
-
|
333
|
-
rest_enemy.value -= 0.4
|
334
|
-
|
335
|
-
console.log(rest_enemy)
|
336
|
-
|
337
|
-
,3000
|
338
|
-
|
339
|
-
setTimeout ->
|
340
|
-
|
341
|
-
$('#gif').attr "src","img/tachi.gif"
|
342
|
-
|
343
|
-
,5000
|
344
|
-
|
345
|
-
if enemy is 1 and user is 0
|
346
|
-
|
347
|
-
my_point += 3
|
348
|
-
|
349
|
-
return ' WIN'
|
350
|
-
|
351
|
-
if enemy is 1 and user is 1
|
352
|
-
|
353
|
-
return 'DROW'
|
354
|
-
|
355
|
-
if enemy is 1 and user is 2
|
356
|
-
|
357
|
-
$('#gif').attr "src","img/jpsyoryu.gif" #相手昇竜拳自分ジャンプ攻撃#
|
358
|
-
|
359
|
-
rest_me = document.getElementById "MyGage"
|
360
|
-
|
361
|
-
ratio = rest_me.value
|
362
|
-
|
363
|
-
rest_me.value -= 0.3
|
364
|
-
|
365
|
-
return 'LOSE'
|
366
|
-
|
367
|
-
if enemy is 2 and user is 0
|
368
|
-
|
369
|
-
$('#gif').html """img/example.gif""" #相手ジャンプ自分波動拳#
|
370
|
-
|
371
|
-
rest_me = document.getElementById "MyGage"
|
372
|
-
|
373
|
-
ratio = rest_me.value
|
374
|
-
|
375
|
-
rest_me.value -= 0.4
|
376
|
-
|
377
|
-
return 'LOSE'
|
378
|
-
|
379
|
-
if enemy is 2 and user is 1
|
380
|
-
|
381
|
-
my_point += 6
|
382
|
-
|
383
|
-
return ' WIN'
|
384
|
-
|
385
|
-
if enemy is 2 and user is 2
|
386
|
-
|
387
|
-
return 'DROW'
|
388
|
-
|
389
|
-
*/
|
390
|
-
|
391
|
-
});
|
392
|
-
|
393
|
-
if (parseFloat($('#EnemyGage').val()) <= 0) {
|
394
|
-
|
395
|
-
console.log('kati');
|
396
|
-
|
397
|
-
$('.remove').empty();
|
398
|
-
|
399
|
-
$('#resultImg').html("<img src=\"img/youwin.jpg\"/>");
|
400
|
-
|
401
|
-
$('#resultImg').fadeIn(10000);
|
402
|
-
|
403
|
-
}
|
404
|
-
|
405
|
-
if ($('#MyGage').val() <= 0) {
|
406
|
-
|
407
|
-
console.log('make');
|
408
|
-
|
409
|
-
$('.remove').empty();
|
410
|
-
|
411
|
-
$('#resultImg').html("<img src=\"img/gameover.jpg\"/>");
|
412
|
-
|
413
|
-
return $('#resultImg').fadeIn(10000);
|
414
|
-
|
415
|
-
}
|
416
|
-
|
417
|
-
});
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
}).call(this);
|
422
|
-
|
423
|
-
```
|
2
jsのコード追加 文字数制限のためcoffeeのコードを解除しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,366 +18,406 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
e
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
i
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
back 4400
|
120
|
-
|
121
|
-
if enemy is 1 #昇竜
|
122
|
-
|
123
|
-
$('#gif').attr 'src','img/syoryusyoryu.gif'
|
124
|
-
|
125
|
-
back 3000
|
126
|
-
|
127
|
-
if enemy is 2 #ジャンプ
|
128
|
-
|
129
|
-
$('#gif').attr 'src','img/syoryujp.gif'
|
130
|
-
|
131
|
-
win 0.3,1400
|
132
|
-
|
133
|
-
back 3950
|
134
|
-
|
135
|
-
if user is 2 #ジャンプVS
|
136
|
-
|
137
|
-
if enemy is 0 #波動
|
138
|
-
|
139
|
-
$('#gif').attr 'src','img/jphadou.gif'
|
140
|
-
|
141
|
-
win 0.4,3000
|
142
|
-
|
143
|
-
back 5000
|
144
|
-
|
145
|
-
if enemy is 1 #昇竜
|
146
|
-
|
147
|
-
$('#gif').attr 'src','img/jpsyoryu.gif'
|
148
|
-
|
149
|
-
lose 0.3,2600
|
150
|
-
|
151
|
-
back 4000
|
152
|
-
|
153
|
-
if enemy is 2 #ジャンプ
|
154
|
-
|
155
|
-
$('#gif').attr 'src','img/jpjp.gif'
|
156
|
-
|
157
|
-
setTimeout ->
|
158
|
-
|
159
|
-
_myGage = $('#MyGage').val() - 0.2
|
160
|
-
|
161
|
-
$('#MyGage').val _myGage
|
162
|
-
|
163
|
-
#rest_enemy.value -= 0.2
|
164
|
-
|
165
|
-
_eneGage = $('#EnemyGage').val() - 0.2
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
$('#EnemyGage').val _eneGage
|
172
|
-
|
173
|
-
,2500
|
174
|
-
|
175
|
-
back 3600
|
176
|
-
|
177
|
-
### if enemy is 0 and user is 1
|
178
|
-
|
179
|
-
$('#gif').attr "src","img/syoryuhado.gif" #相手波動拳自分昇竜件#
|
180
|
-
|
181
|
-
rest_me = document.getElementById "MyGage"
|
182
|
-
|
183
|
-
ratio = rest_me.value
|
184
|
-
|
185
|
-
rest_me.value -= 0.1
|
186
|
-
|
187
|
-
if enemy is 0 and user is 2
|
188
|
-
|
189
|
-
$('#gif').attr "src","img/jphadou.gif" #相手波動拳自分ジャンプ#
|
190
|
-
|
191
|
-
rest_enemy = document.getElementById "EnemyGage"
|
192
|
-
|
193
|
-
#rest_enemy = $("#EnemyGage").val
|
194
|
-
|
195
|
-
console.log(rest_enemy)
|
196
|
-
|
197
|
-
setTimeout ->
|
198
|
-
|
199
|
-
rest_enemy.value -= 0.4
|
200
|
-
|
201
|
-
console.log(rest_enemy)
|
202
|
-
|
203
|
-
,3000
|
204
|
-
|
205
|
-
setTimeout ->
|
206
|
-
|
207
|
-
$('#gif').attr "src","img/tachi.gif"
|
208
|
-
|
209
|
-
,5000
|
210
|
-
|
211
|
-
if enemy is 1 and user is 0
|
212
|
-
|
213
|
-
my_point += 3
|
214
|
-
|
215
|
-
return ' WIN'
|
216
|
-
|
217
|
-
if enemy is 1 and user is 1
|
218
|
-
|
219
|
-
return 'DROW'
|
220
|
-
|
221
|
-
if enemy is 1 and user is 2
|
222
|
-
|
223
|
-
$('#gif').attr "src","img/jpsyoryu.gif" #相手昇竜拳自分ジャンプ攻撃#
|
224
|
-
|
225
|
-
rest_me = document.getElementById "MyGage"
|
226
|
-
|
227
|
-
ratio = rest_me.value
|
228
|
-
|
229
|
-
rest_me.value -= 0.3
|
230
|
-
|
231
|
-
return 'LOSE'
|
232
|
-
|
233
|
-
if enemy is 2 and user is 0
|
234
|
-
|
235
|
-
$('#gif').html """img/example.gif""" #相手ジャンプ自分波動拳#
|
236
|
-
|
237
|
-
rest_me = document.getElementById "MyGage"
|
238
|
-
|
239
|
-
ratio = rest_me.value
|
240
|
-
|
241
|
-
rest_me.value -= 0.4
|
242
|
-
|
243
|
-
return 'LOSE'
|
244
|
-
|
245
|
-
if enemy is 2 and user is 1
|
246
|
-
|
247
|
-
my_point += 6
|
248
|
-
|
249
|
-
return ' WIN'
|
250
|
-
|
251
|
-
if enemy is 2 and user is 2
|
252
|
-
|
253
|
-
return 'DROW'###
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
rest_enemy = document.getElementById "#EnemyGage"
|
258
|
-
|
259
|
-
if rest_enemy.value <= 0
|
260
|
-
|
261
|
-
# if $('#EnemyGage').val() <= 0
|
262
|
-
|
263
|
-
console.log 'kati'
|
264
|
-
|
265
|
-
$('.remove').empty()
|
266
|
-
|
267
|
-
$('#resultImg').html """<img src="img/youwin.jpg"/>"""
|
268
|
-
|
269
|
-
$('#resultImg').fadeIn 10000
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
if $('#MyGage').val() <= 0
|
274
|
-
|
275
|
-
console.log 'make'
|
276
|
-
|
277
|
-
$('.remove').empty()
|
278
|
-
|
279
|
-
$('#resultImg').html """<img src="img/gameover.jpg"/>"""
|
280
|
-
|
281
|
-
$('#resultImg').fadeIn 10000
|
282
|
-
|
283
|
-
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```HTML
|
26
|
+
|
27
|
+
<!DOCTYPE html>
|
28
|
+
|
29
|
+
<html lang="ja">
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
<head>
|
34
|
+
|
35
|
+
<meta charset="utf-8">
|
36
|
+
|
37
|
+
<title>じゃんけんゲーム</title>
|
38
|
+
|
39
|
+
<link rel="stylesheet" type="text/css" href="css/index2.css">
|
40
|
+
|
41
|
+
<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
|
42
|
+
|
43
|
+
<script type="text/javascript" src="js/underscore-min.js"></script>
|
44
|
+
|
45
|
+
<script type="text/javascript" src="js/trial2.js"></script>
|
46
|
+
|
47
|
+
<script type="text/javascript" src="js/jquery.fullImage.js"></script>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
</head>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<body>
|
56
|
+
|
57
|
+
<div id="wrapper" >
|
58
|
+
|
59
|
+
<div id="resultImg"></div>
|
60
|
+
|
61
|
+
<section class="remove"> <h1>じゃんけんゲーム</h1>
|
62
|
+
|
63
|
+
<INPUT type="button" id="explain" value="最初に読んで!" onClick="alert('波動拳<昇竜拳<ジャンプコンボの順に威力が大きい!\n指定されるまで次の選択をしないで????')">
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<p class="me">選択肢を選んでください。</p>
|
68
|
+
|
69
|
+
<ol>
|
70
|
+
|
71
|
+
<li class="MySelect" data-assign="0"><img src=img/select0.jpg ></li>
|
72
|
+
|
73
|
+
<li class="MySelect" data-assign="1"><img src=img/select1.jpg ></li>
|
74
|
+
|
75
|
+
<li class="MySelect" data-assign="2"><img src=img/select2.jpg ></li>
|
76
|
+
|
77
|
+
</ol>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="gamen">
|
82
|
+
|
83
|
+
<img id="gif" src="img/tachi.gif">
|
84
|
+
|
85
|
+
<meter id ="EnemyGage" value="1"></meter>
|
86
|
+
|
87
|
+
<meter id ="MyGage" value="1"></meter>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<div id="resultImg"></div>
|
98
|
+
|
99
|
+
<div id="result">Choose the Next!</div>
|
100
|
+
|
101
|
+
</section>
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<input type="button" id="escape" value="逃げる" onclick="location.reload();" />
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
</body>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
</html>
|
284
118
|
|
285
119
|
```
|
286
120
|
|
287
121
|
|
288
122
|
|
289
|
-
```
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
123
|
+
```javascript
|
124
|
+
|
125
|
+
// Generated by CoffeeScript 1.10.0
|
126
|
+
|
127
|
+
(function() {
|
128
|
+
|
129
|
+
$(function() {
|
130
|
+
|
131
|
+
var back, lose, win;
|
132
|
+
|
133
|
+
win = function(damage, time) {
|
134
|
+
|
135
|
+
var attack;
|
136
|
+
|
137
|
+
return attack = setTimeout(function() {
|
138
|
+
|
139
|
+
var _eneGage;
|
140
|
+
|
141
|
+
_eneGage = $('#EnemyGage').val() - damage;
|
142
|
+
|
143
|
+
$('#EnemyGage').val(_eneGage);
|
144
|
+
|
145
|
+
}, time);
|
146
|
+
|
147
|
+
};
|
148
|
+
|
149
|
+
lose = function(damage, time) {
|
150
|
+
|
151
|
+
var attacked;
|
152
|
+
|
153
|
+
return attacked = setTimeout(function() {
|
154
|
+
|
155
|
+
var _myGage;
|
156
|
+
|
157
|
+
_myGage = $('#MyGage').val() - damage;
|
158
|
+
|
159
|
+
$('#MyGage').val(_myGage);
|
160
|
+
|
161
|
+
}, time);
|
162
|
+
|
163
|
+
};
|
164
|
+
|
165
|
+
back = function(time) {
|
166
|
+
|
167
|
+
var top;
|
168
|
+
|
169
|
+
return top = setTimeout(function() {
|
170
|
+
|
171
|
+
$('#gif').attr('src', 'img/tachi.gif');
|
172
|
+
|
173
|
+
$('#result').css('display', 'inline');
|
174
|
+
|
175
|
+
$('.temp').attr('class', 'MySelect');
|
176
|
+
|
177
|
+
}, time);
|
178
|
+
|
179
|
+
};
|
180
|
+
|
181
|
+
console.log;
|
182
|
+
|
183
|
+
$('.MySelect').click(function() {
|
184
|
+
|
185
|
+
var enemy, user;
|
186
|
+
|
187
|
+
enemy = _.random(0, 2);
|
188
|
+
|
189
|
+
user = Number($(this).attr('data-assign'));
|
190
|
+
|
191
|
+
console.log("OK1");
|
192
|
+
|
193
|
+
$('.MySelect').attr('class', 'temp');
|
194
|
+
|
195
|
+
$('#result').css('display', 'none');
|
196
|
+
|
197
|
+
if (user === 0) {
|
198
|
+
|
199
|
+
if (enemy === 0) {
|
200
|
+
|
201
|
+
$('#gif').attr('src', 'img/hadohado.gif');
|
202
|
+
|
203
|
+
console.log("OK2");
|
204
|
+
|
205
|
+
back(5000);
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
if (enemy === 1) {
|
210
|
+
|
211
|
+
$('#gif').attr('src', 'img/hadosyoryu.gif');
|
212
|
+
|
213
|
+
win(0.2, 1700);
|
214
|
+
|
215
|
+
back(5000);
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
if (enemy === 2) {
|
220
|
+
|
221
|
+
$('#gif').attr('src', 'img/hadoujp.gif');
|
222
|
+
|
223
|
+
lose(0.4, 2500);
|
224
|
+
|
225
|
+
back(4200);
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
if (user === 1) {
|
232
|
+
|
233
|
+
if (enemy === 0) {
|
234
|
+
|
235
|
+
$('#gif').attr('src', 'img/syoryuhado.gif');
|
236
|
+
|
237
|
+
lose(0.2, 1600);
|
238
|
+
|
239
|
+
back(4400);
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
if (enemy === 1) {
|
244
|
+
|
245
|
+
$('#gif').attr('src', 'img/syoryusyoryu.gif');
|
246
|
+
|
247
|
+
back(3000);
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
if (enemy === 2) {
|
252
|
+
|
253
|
+
$('#gif').attr('src', 'img/syoryujp.gif');
|
254
|
+
|
255
|
+
win(0.3, 1400);
|
256
|
+
|
257
|
+
back(3950);
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
if (user === 2) {
|
264
|
+
|
265
|
+
if (enemy === 0) {
|
266
|
+
|
267
|
+
$('#gif').attr('src', 'img/jphadou.gif');
|
268
|
+
|
269
|
+
win(0.4, 3000);
|
270
|
+
|
271
|
+
back(5000);
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
if (enemy === 1) {
|
276
|
+
|
277
|
+
$('#gif').attr('src', 'img/jpsyoryu.gif');
|
278
|
+
|
279
|
+
lose(0.3, 2600);
|
280
|
+
|
281
|
+
back(4000);
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
if (enemy === 2) {
|
286
|
+
|
287
|
+
$('#gif').attr('src', 'img/jpjp.gif');
|
288
|
+
|
289
|
+
setTimeout(function() {
|
290
|
+
|
291
|
+
var _eneGage, _myGage;
|
292
|
+
|
293
|
+
_myGage = $('#MyGage').val() - 0.2;
|
294
|
+
|
295
|
+
$('#MyGage').val(_myGage);
|
296
|
+
|
297
|
+
_eneGage = $('#EnemyGage').val() - 0.2;
|
298
|
+
|
299
|
+
return $('#EnemyGage').val(_eneGage);
|
300
|
+
|
301
|
+
}, 2500);
|
302
|
+
|
303
|
+
return back(3600);
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
/* if enemy is 0 and user is 1
|
312
|
+
|
313
|
+
$('#gif').attr "src","img/syoryuhado.gif" #相手波動拳自分昇竜件#
|
314
|
+
|
315
|
+
rest_me = document.getElementById "MyGage"
|
316
|
+
|
317
|
+
ratio = rest_me.value
|
318
|
+
|
319
|
+
rest_me.value -= 0.1
|
320
|
+
|
321
|
+
if enemy is 0 and user is 2
|
322
|
+
|
323
|
+
$('#gif').attr "src","img/jphadou.gif" #相手波動拳自分ジャンプ#
|
324
|
+
|
325
|
+
rest_enemy = document.getElementById "EnemyGage"
|
326
|
+
|
327
|
+
#rest_enemy = $("#EnemyGage").val
|
328
|
+
|
329
|
+
console.log(rest_enemy)
|
330
|
+
|
331
|
+
setTimeout ->
|
332
|
+
|
333
|
+
rest_enemy.value -= 0.4
|
334
|
+
|
335
|
+
console.log(rest_enemy)
|
336
|
+
|
337
|
+
,3000
|
338
|
+
|
339
|
+
setTimeout ->
|
340
|
+
|
341
|
+
$('#gif').attr "src","img/tachi.gif"
|
342
|
+
|
343
|
+
,5000
|
344
|
+
|
345
|
+
if enemy is 1 and user is 0
|
346
|
+
|
347
|
+
my_point += 3
|
348
|
+
|
349
|
+
return ' WIN'
|
350
|
+
|
351
|
+
if enemy is 1 and user is 1
|
352
|
+
|
353
|
+
return 'DROW'
|
354
|
+
|
355
|
+
if enemy is 1 and user is 2
|
356
|
+
|
357
|
+
$('#gif').attr "src","img/jpsyoryu.gif" #相手昇竜拳自分ジャンプ攻撃#
|
358
|
+
|
359
|
+
rest_me = document.getElementById "MyGage"
|
360
|
+
|
361
|
+
ratio = rest_me.value
|
362
|
+
|
363
|
+
rest_me.value -= 0.3
|
364
|
+
|
365
|
+
return 'LOSE'
|
366
|
+
|
367
|
+
if enemy is 2 and user is 0
|
368
|
+
|
369
|
+
$('#gif').html """img/example.gif""" #相手ジャンプ自分波動拳#
|
370
|
+
|
371
|
+
rest_me = document.getElementById "MyGage"
|
372
|
+
|
373
|
+
ratio = rest_me.value
|
374
|
+
|
375
|
+
rest_me.value -= 0.4
|
376
|
+
|
377
|
+
return 'LOSE'
|
378
|
+
|
379
|
+
if enemy is 2 and user is 1
|
380
|
+
|
381
|
+
my_point += 6
|
382
|
+
|
383
|
+
return ' WIN'
|
384
|
+
|
385
|
+
if enemy is 2 and user is 2
|
386
|
+
|
387
|
+
return 'DROW'
|
388
|
+
|
389
|
+
*/
|
390
|
+
|
391
|
+
});
|
392
|
+
|
393
|
+
if (parseFloat($('#EnemyGage').val()) <= 0) {
|
394
|
+
|
395
|
+
console.log('kati');
|
396
|
+
|
397
|
+
$('.remove').empty();
|
398
|
+
|
399
|
+
$('#resultImg').html("<img src=\"img/youwin.jpg\"/>");
|
400
|
+
|
401
|
+
$('#resultImg').fadeIn(10000);
|
402
|
+
|
403
|
+
}
|
404
|
+
|
405
|
+
if ($('#MyGage').val() <= 0) {
|
406
|
+
|
407
|
+
console.log('make');
|
408
|
+
|
409
|
+
$('.remove').empty();
|
410
|
+
|
411
|
+
$('#resultImg').html("<img src=\"img/gameover.jpg\"/>");
|
412
|
+
|
413
|
+
return $('#resultImg').fadeIn(10000);
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
});
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
}).call(this);
|
382
422
|
|
383
423
|
```
|
1
setTimeoutについての質問を記述し忘れていました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
if文が動作しない
|
1
|
+
if文が動作しない➕ setTimeoutについて。
|
test
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
現在gif画像を使って、じゃんけんゲームもどきを作っているのですが、相手の体力がなくなった時に動作するようにしたif文が動作しません。
|
2
2
|
|
3
|
+
また、setTimeoutでタイミングをズラしてダメージが反映されたり、
|
4
|
+
|
5
|
+
gif画像をデフォルトの画像に戻すということをしているのですが、この場合、
|
6
|
+
|
7
|
+
選択肢を連打されたり、gifが終了する前に次の選択肢を選ばれたら挙動がおかしくなってしまいます。
|
8
|
+
|
9
|
+
そこで、選択肢がクリックされたら、選択肢のclass(MySelect)をattrで変更し、デフォルトの画像に戻るsetTimeout処理でそのクラスを元に戻せば、終わるまで選択肢をクリックしても、大丈夫になると考えたのですが、うまくいきませんでした。(普通に連打できてしまう。)
|
10
|
+
|
11
|
+
あとは。clearTimeoutを使えば良いのかなと考えていますが、うまく思いつきません。
|
12
|
+
|
13
|
+
アドバイスをいただけると嬉しいです。
|
14
|
+
|
3
15
|
初心者なもので、拙いコードですがご了承ください。
|
4
16
|
|
5
17
|
動作していないif文は一番最後の2つです。
|