forked from gabboraron/iss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pingpong.js
96 lines (82 loc) · 3.52 KB
/
pingpong.js
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
"use strict"
console.log("ping is pong");
var point = 0;
var remainpoints = 0;
var firstround = true;
var pointtext1='<a-text value="';
var pointtext2='" color="#BBB" position="-20 0 0" scale="50 50 50" rotation="0 90 0"></a-text>';
//document.getElementById('OK').addEventListener('click',cls);
function cls(){
//console.log("clsOK");
/*if(ok == 0){
document.getElementById('IntroText').value="Nice! Now on left of you are your points! Press OK again to start the game!";
ok = 1;
console.log("ok: ", ok);
}*/
document.getElementById('intro').innerHTML = "";
//document.getElementById('mapmenu').innerHTML = "";
document.getElementById('Point').innerHTML = pointtext1 + "0" + pointtext2;
setInterval(function(){game();},5500);
}
var shitHTML1 = '<a-sphere radius="3" position=" 0 0 0" color="brown"><a-animation attribute="position" to="';
var shitHTML2 = ' ';
var shitHTML3 = ' -40" fill="forwards" dur="5000"></a-animation></a-sphere>';
var x = 0;
var y = 0;
function game(){
if(remainpoints < 15){
shitsend();
}else{
document.getElementById('intro').innerHTML = '<a-text id="IntroText" value="Sorry, now we faild because too many wreckage remained in our spaceship! Now we have to evacuate! Please take off the headset!" color="red" position="-2 3 -3" scale="1.5 1.5 1.5"></a-text>';
}
}
function shitsend(){
var isthere = false;
var x1 = 0;
while (!isthere)
{
x1 = Math.floor(Math.random()*15)+(-45) + Math.floor(Math.random()*50)+(-5);
//console.log(" x1: ",x1);
if((x1<x-20 || x1>x+20) && (x1>-46 && x1<16)){isthere = true; x = x1;}
}
isthere = false;
while (!isthere)
{
x1 = Math.floor(Math.random()*40)+(-15);
if(x1!=y){isthere = true; y = x1;}
}
//shitHtml();
whereis();
}
function shitHtml1(){
document.getElementById("shitball").innerHTML = shitHTML1 + x + shitHTML2 + y + shitHTML3;
/*console.log("shithtml ok");
console.log(" x: ", x);
console.log(" y: ", y);*/
}
function shitHtml2(){
document.getElementById("shitball").innerHTML = shitHTML1 + x + shitHTML2 + y + ' -30" fill="forwards" dur="5000"></a-animation></a-sphere>';
}
function whereis(){
var done=false;
if((x>-10 && x<-20) && (y<30 && y>20)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>0 && x<-10) && (y<10 && y>20)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-10 && x<10) && (y<10 && y>20)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-30 && x<-20) && (y<10 && y>0)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-40 && x<-30) && (y<20 && y>10)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-40 && x<-30) && (y<40 && y>30)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-10 && x<0) && (y<50 && y>40)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-10 && x<10) && (y<50 && y>40)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>0 && x<20) && (y<30 && y>20)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>0 && x<10) && (y<0 && y>-10)) {pointIncAndShow(); shitHtml1(); done = true;}
if((x>-10 && x<-20) && (y<0 && y>-10)) {pointIncAndShow(); shitHtml1(); done = true;}
if((done == false) && (firstround == false)){shitHtml2(); setTimeout(showOldFaild,5000); remainpoints = remainpoints +1;}
if(firstround == true){firstround = false;}
}
function showOldFaild() {
document.getElementById("lostshits").innerHTML = document.getElementById("lostshits").innerHTML + '<a-sphere radius="3" position=" ' + x + ' ' + y + ' -30" color="brown"></a-sphere>';
}
function pointIncAndShow(){
point = point + 1;
document.getElementById('Point').innerHTML = pointtext1 + point + pointtext2;
}