-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
474 lines (348 loc) · 11.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
76
77
78
79
80
81
82
83
84
85
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<!DOCTYPE html>
<html style=" height:100%;width:100%">
<head>
<meta charset="UTF-8" >
<title>runRect</title>
<link href="style.css" type="text/css" rel="stylesheet"></link>
</head>
<body id="result" >
<!-- by Smirnov Vlad -->
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter43358829 = new Ya.Metrika({
id:43358829,
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
} catch(e) { }
});
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = "https://mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/43358829" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
<div id="wrapper" >
<div id ="option" >
<div id="optionExitButton" ><h2 align="center">Выход в меню</h2></div>
<div id = "optionSpeedAbout">
<h2>Максимальная скорость объектов:</h2></div>
<div id = "optionSpeed">
<input type="range" min="0" max="10" onchange="document.getElementById('rangeSpeed').innerHTML = this.value;maxSpeed+=this.value-maxSpeedOption;maxSpeedOption=this.value;" list="speed" value=0> <span id="rangeSpeed">0</span></p>
<datalist id="speed" >
</datalist>
</div>
<div id = "optionHardAbout">
<h2>количество объектов на поле:</h2>
</div>
<div id = "optionHard">
<input type="range" min="18" max="25" onchange="document.getElementById('rangeValue').innerHTML = this.value;maxHard=this.value;" list="hard" value=20> <span id="rangeValue">20</span></p>
<datalist id="hard" >
</datalist>
</div>
</div>
<div id ="about" >
<div id="aboutHeader">
<h4> <div id="aboutHeader1"> автор </div></h3>
<h2><div id="aboutHeader2" >правила</div></h2>
<h4> <div id="aboutHeader3">создание </div></h3>
</div>
<big><div id ="aboutText"><p> Вы управляете квадратом через клавиши :A , S , D , W , Spase . Цель игры не столкнуться с падающими объектами .</p> <p> Для усложнения игры вы можете поменять значения скорости и количество падающих объектов в настройках. </p>
</div></big>
<div id="aboutLastButton" align ="center"><h2 style="margin-top:29px;">назад</h2></div>
<div id="aboutExitButton" align ="center"><h2>Выход в меню</h2></div>
<div id="aboutNextButton" align ="center" ><h2 style="margin-top:29px;">дальше</h2></div>
</div>
<div id ="meny" >
<div id="rec" >
<h1 style="padding-left :22%;padding-top :25%;">runRect</h1>
</div>
<div id="wrapStart">
<div id="startButton" align ="center"><h2>Старт</h2></div>
<div id="optionButton" align ="center"><h2>Настройки</h2></div>
<div id="aboutButton" align ="center"><h2>О проекте</h2></div>
</div>
<h3>
<div id="stat" align = "center" style="margin-top:50px";>
(для начала игры нажмите старт )
</div>
</h3>
</div>
<div id="wrapperCanvas">
<canvas id="canvasld" >
Hey привет
</canvas>
</div>
</div>
<script src="js/devise.js"></script>
<script src="js/vector.js"></script>
<script src="js/polygon.js"></script>
<script src="js/creatOb.js"></script>
<script src="js/extraFun.js"></script>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/navigation.js"></script>
<script type="text/javascript">
/*if(device.mobile()) alert('Смартфон');
if(device.desktop()) alert('ПК');
if(device.tablet()) alert('Планшет');
//Ориентация экрана
if(device.landscape()) alert('Альбомная (в ширину)');
if(device.portrait()) alert('Портретная (в высоту)');
//ОС устройства
if(device.ios()) alert('iOS');
if(device.ipad()) alert('ipad');
if(device.iphone()) alert('iphone');
if(device.ipod()) alert('ipod');
if(device.android()) alert('android');
if(device.windows()) alert('windows');
if(device.blackberry()) alert('blackberry');
if(device.fxos()) alert('fxos');
*/
var canvas = document.getElementById("canvasld");
var width = 500;//window.innerWidth/3;
var height =800;// window.innerHeight-20;
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext("2d");
canvas.onclick =function(e){
var x,y;
x = e.offsetX;
y = e.offsetY;
var clickXY = new vector();
clickXY.x = x;
clickXY.y = y;
console.log(e);
// обрабатываем кнопку паузы
if(x > 450 && x < width && y < 50 && y > 0){
if(startGame==1){
startGame =0;
clear();
if(instructionTime>0 && !sensor){
instructionTime--;
ctx.drawImage(imageInstruc,0,500,500,300);
}
if(sensor){
ctx.drawImage(imageStop,menyVector.x,menyVector.y,50,50);
ctx.drawImage(imageRight,menyVector.x+100,menyVector.y,50,50);
ctx.drawImage(imageLeft,menyVector.x-100,menyVector.y,50,50);
ctx.drawImage(imageDown,menyVector.x,menyVector.y+100,50,50);
ctx.drawImage(imageTop,menyVector.x,menyVector.y-100,50,50);
}
print("МОЙ СЧЕТ : "+score,50);
plaer.draw();
for( var i = 0; i < blockagePolygon.length ;++i) {
blockagePolygon[i].draw();
}
//ctx.drawImage(imageStart,450,0,50,50);
drawStart();
}
else
startGame =1;
// обрабатывет нажатия
}
else{
var axisOX = new vector();
axisOX.x = menyVector.x + 1;
axisOX.y = menyVector.y ;
var a = getAngle( getVectorEB( clickXY , menyVector) , getVectorEB(axisOX , menyVector) );
if (a<0)
a = 360 + a;
if( (a > 0 && a < 45) ||(a < 360 && a > 315) )
plaer.vx = speed;
if( (a > 135 && a < 225) )
plaer.vx = -speed;
if( (a > 45 && a < 135) )
plaer.vy = -speed;
if( (a > 225 && a < 315) )
plaer.vy = speed + 0.6;
if(getLong(clickXY,menyVector)<50) {
plaer.vy = 0;
plaer.vx= 0;
}
}
};
var time =function (){
if(!startGame)
return;
clear();
if(sensor){
ctx.drawImage(imageStop,menyVector.x,menyVector.y,50,50);
ctx.drawImage(imageRight,menyVector.x+100,menyVector.y,50,50);
ctx.drawImage(imageLeft,menyVector.x-100,menyVector.y,50,50);
ctx.drawImage(imageDown,menyVector.x,menyVector.y+100,50,50);
ctx.drawImage(imageTop,menyVector.x,menyVector.y-100,50,50);
}
if(instructionTime>0 && !sensor){
instructionTime--;
ctx.drawImage(imageInstruc,0,500,500,300);
}
//print("до следущего уровня: "+score+"/"+nextLevel+" макс счет:"+ maxScore,0);
print("МОЙ СЧЕТ : "+score,50);
//print(maxScore,30);
if(getRandomArbitrary(0,150)>148-maxHard+19){//////////////////
switch( getRandomInt(1,Math.min(level,maxLevel))) {
case 1 :creatBlockageLevel1(getRandomArbitrary(-20,width+20) , getRandomArbitrary(plaer.center.x-1000,plaer.center.x-400)); break;
case 2 :creatBlockageLevel2(getRandomArbitrary(-20,width+20) , getRandomArbitrary(plaer.center.x-1000,plaer.center.x-400)); break;
case 3 :creatBlockageLevel3(getRandomArbitrary(-20,width+20) , getRandomArbitrary(plaer.center.x-1000,plaer.center.x-400)); break;
}
}
if(plaer.searchConflictPolygon(blockagePolygon)){
blockagePolygon.splice(0,blockagePolygon.length-1 );
$("#wrapperCanvas").hide();//document.write("выш рекорд");
$("#meny").show();
//instructionTime =500;
startGame=false;
maxScore = Math.max(maxScore,score);
var ans = "<p>Мой cчет за игру : " + score +"</p><p>Мой максимальный счет : " + maxScore +"</p>";
score = 0;
$("#stat").html( ans);
newGame();
}
plaer.newCord();
if(plaer.center.y < 10 ) {
plaer.vy =0;
plaer.center.y =10;
}
if(plaer.center.y > height ) {
plaer.vy =0;
plaer.center.y = height ;
}
if( plaer.center.x < 0 ) {
plaer.vx =0;
plaer.center.x =0;
}
if( plaer.center.x > width - 10 ) {
plaer.vx =0;
plaer.center.x =width - 10 ;
}
// plaer.newMove();
plaer.draw();
for( var i = 0; i < blockagePolygon.length ;++i) {
if(blockagePolygon[i].movedBorder(height)){
blockagePolygon.splice(i, 1);
i--;
score++;
if(score==20){
nextLevel =60;
level=2;
}
if(score==60){
nextLevel =100;
level=3;
}
if(score==100){
nextLevel =200;
level++;
}
continue;
}
blockagePolygon[i].newCordLevel();
blockagePolygon[i].newCord();
// blockagePolygon[i].updatePlanetaryCord();
// print( blockagePolygon[i].center.y,100);
// blockagePolygon[i].center.y++;
blockagePolygon[i].draw();
}
ctx.drawImage(imagePause,450,0,50,50);
}
document.onkeydown = function(e) {
console.log(e);
switch(e.keyCode) {
case 68 : plaer.vx = speed;break;
case 39 : plaer.vx = speed;break;
case 65: plaer.vx = -speed;break;
case 37: plaer.vx = -speed;break;
case 87: plaer.vy =-speed;break;
case 38: plaer.vy =-speed;break;
case 83: plaer.vy =speed+0.6;break;
case 40: plaer.vy =speed+0.6;break;
case 32: plaer.vy =0;
plaer.vx =0;
;break;
}
}
setInterval(time,10);
var sensor ;
var maxScore = 0;
var score = 0 ;
var startGame = false;
var plaer;
var level=3;
var nextLevel = 20;
var maxLevel=3;
var maxSpeedOption=0;
var maxSpeed=1;
var maxHard=19;
var instructionTime=500;
var loadImage=0;
var speed = 1.1 ;
var imageInstruc =new Image();
var imagePause =new Image();
var menyVector = new vector();
menyVector.y =600;
menyVector.x =230;
/*
image.onload = function (){
loadImage++;
};
image2.onload = function (){
loadImage++;
};*/
var imageTop =new Image();
var imageDown =new Image();
var imageRight =new Image();
var imageLeft =new Image();
var imageStop =new Image();
imageLeft.src="left.png";
imageRight.src="right.png";
imageTop.src="top.png";
imageDown.src="down.png";
imageStop.src="stop.png";
imageInstruc.src="instruction.png";
imagePause.src="pause2.png";
if (device.mobile() || device.tablet())
sensor =true;
else
sensor =false;
var blockagePolygon = [];
newGame();
/*
var x2 = width /2-100;
var y2 = height /2-100;
var creatPolyCord = [];
creatPolyCord[0]= new vector();
creatPolyCord[0].x = 0+x2;
creatPolyCord[0].y = 0+y2;
creatPolyCord[1]= new vector();
creatPolyCord[1].x =100+x2;
creatPolyCord[1].y = 0+y2;
creatPolyCord[2]= new vector();
creatPolyCord[2].x =100+x2;
creatPolyCord[2].y =10+y2;
creatPolyCord[3]= new vector();
creatPolyCord[3].x = 0+x2;
creatPolyCord[3].y = 10+y2;
var id = blockagePolygon.length;
blockagePolygon[id]= new polygonBlockageLevel2(creatPolyCord ,50+x2,50+y2);
//blockagePolygon[id].center2Id=3;
blockagePolygon[id].x = 50 + x2;
blockagePolygon[id].y = 5 + y2;
blockagePolygon[id].vy=0;
blockagePolygon[id].moveAngle= 1;
blockagePolygon[id].updatePlanetaryCord();
blockagePolygon[id].updatePlanetaryCord();*/
//creatBlockageLevel3( 400,400 );
</script>
</body>
</html>