Skip to content

Commit

Permalink
Finish for today
Browse files Browse the repository at this point in the history
  • Loading branch information
Parking-Master committed Oct 2, 2022
1 parent ed25a9e commit dee0dd3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ <h4 id="create-a-lobby">To create a lobby</h4>
2. Click "CREATE LOBBY"<br>
3. Enter your lobby name.<br>
4. Click "Next" (or hit enter)<br>
4. Add your custom options, then click "Next"<br>
5. If your lobby does not show up, reload the page or click "FIND LOBBY"<br>
6. Click your lobby's name in the dialog.<br>
7. Wait for player(s) to join. The game will start automatically.<br>
Expand Down
24 changes: 14 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -327,23 +327,27 @@ <h2 class="page-text">Multiplayer shooter</h2>
tippy("[data-tippy-content]");
// tippy("button")[0].show();
let Lobby = new Parse.Object.extend("Lobby");
!function(e,i){var t,n,l=(new Date).getTime();t=i.createElement("div"),n=i.createElement("div"),t.className="dialog-box",t.id="dialog-box-"+l,t.innerHTML='<h3 class="dialog-title">&nbsp;</h3><a class="dialog-minmax" title="Minimize">&ndash;</a><a class="dialog-close" title="Close">&times;</a><div class="dialog-content">&nbsp;</div><div class="dialog-action"></div>',n.className="dialog-box-overlay",i.body.appendChild(t),i.body.appendChild(n);var o=!1,a=i.getElementById("dialog-box-"+l),s=a.children[0],c=a.children[1],d=a.children[2],p=a.children[3],r=a.children[4],f=a.nextSibling;function h(){o?(a.className+=" minimize",c.innerHTML="+",c.title=s.innerHTML.replace(/<.*?>/g,""),o=!1):(a.className=a.className.replace(/(^| )minimize($| )/g,""),c.innerHTML="&ndash;",c.title="Minimize",o=!0)}e.setDialog=function(t,n,z){var l=null,m=0,g=0,v=0,x=0,u={title:s.innerHTML,content:p.innerHTML,width:300,height:150,top:!1,left:!1,buttons:{Next:function(){setDialog("close"),z()}},specialClass:"",fixed:!0,overlay:!1};for(var b in n)u[b]=(n[b],n[b]);if(a.className="dialog-box "+(u.fixed?"fixed-dialog-box ":"")+u.specialClass,a.style.visibility="open"==t?"visible":"hidden",a.style.opacity="open"==t?1:0,a.style.width=u.width+"px",a.style.height=u.height+"px",a.style.top=u.top?"0px":"50%",a.style.left=u.left?"0px":"50%",a.style.marginTop=u.top?u.top+"px":"-"+u.height/2+"px",a.style.marginLeft=u.left?u.left+"px":"-"+u.width/2+"px",s.innerHTML=u.title,p.innerHTML=u.content,r.innerHTML="",f.style.display="open"==t&&u.overlay?"block":"none",u.buttons)for(var y in u.buttons){var M=i.createElement("a");M.className="btn",M.innerHTML=y,M.onclick=u.buttons[y],r.appendChild(M)}else r.innerHTML="&nbsp;";s.onmousedown=function(){var e;return e=this.parentNode,v=m-(l=e).offsetLeft,x=g-l.offsetTop,!1},c.innerHTML="&ndash;",c.title="Minimize",c.onclick=h,d.onclick=function(){setDialog("close",{content:""})},i.onmousemove=function(t){m=i.all?e.event.clientX:t.pageX,g=i.all?e.event.clientY:t.pageY,null!==l&&(l.style.left=u.left?m-v-u.left+"px":m-v+l.offsetWidth/2+"px",l.style.top=u.top?g-x-u.top+"px":g-x+l.offsetHeight/2+"px")},i.onmouseup=function(){l=null},o="open"==t}}(window,document);
!function(e,i){var t,n,l=(new Date).getTime();t=i.createElement("div"),n=i.createElement("div"),t.className="dialog-box",t.id="dialog-box-"+l,t.innerHTML='<h3 class="dialog-title">&nbsp;</h3><a class="dialog-minmax" title="Minimize" onclick="event.preventDefault()" href="javascript:void(0)">&ndash;</a><a class="dialog-close" title="Close" onclick="event.preventDefault()" href="javascript:void(0)">&times;</a><div class="dialog-content">&nbsp;</div><div class="dialog-action"></div>',n.className="dialog-box-overlay",i.body.appendChild(t),i.body.appendChild(n);var o=!1,a=i.getElementById("dialog-box-"+l),s=a.children[0],c=a.children[1],d=a.children[2],p=a.children[3],r=a.children[4],f=a.nextSibling;function h(){o?(a.className+=" minimize",c.innerHTML="+",c.title=s.innerHTML.replace(/<.*?>/g,""),o=!1):(a.className=a.className.replace(/(^| )minimize($| )/g,""),c.innerHTML="&ndash;",c.title="Minimize",o=!0)}e.setDialog=function(t,n,z){var l=null,m=0,g=0,v=0,x=0,u={title:s.innerHTML,content:p.innerHTML,width:300,height:150,top:!1,left:!1,buttons:{Next:function(){setDialog("close"),z()}},specialClass:"",fixed:!0,overlay:!1};for(var b in n)u[b]=(n[b],n[b]);if(a.className="dialog-box "+(u.fixed?"fixed-dialog-box ":"")+u.specialClass,a.style.visibility="open"==t?"visible":"hidden",a.style.opacity="open"==t?1:0,a.style.width=u.width+"px",a.style.height=u.height+"px",a.style.top=u.top?"0px":"50%",a.style.left=u.left?"0px":"50%",a.style.marginTop=u.top?u.top+"px":"-"+u.height/2+"px",a.style.marginLeft=u.left?u.left+"px":"-"+u.width/2+"px",s.innerHTML=u.title,p.innerHTML=u.content,r.innerHTML="",f.style.display="open"==t&&u.overlay?"block":"none",u.buttons)for(var y in u.buttons){var M=i.createElement("a");M.className="btn",M.innerHTML=y,M.onclick=u.buttons[y],r.appendChild(M)}else r.innerHTML="&nbsp;";s.onmousedown=function(){var e;return e=this.parentNode,v=m-(l=e).offsetLeft,x=g-l.offsetTop,!1},c.innerHTML="&ndash;",c.title="Minimize",c.onclick=h,d.onclick=function(){setDialog("close",{content:""})},i.onmousemove=function(t){m=i.all?e.event.clientX:t.pageX,g=i.all?e.event.clientY:t.pageY,null!==l&&(l.style.left=u.left?m-v-u.left+"px":m-v+l.offsetWidth/2+"px",l.style.top=u.top?g-x-u.top+"px":g-x+l.offsetHeight/2+"px")},i.onmouseup=function(){l=null},o="open"==t}}(window,document);
function chooseMap(csf = null) {
setDialog('open', { title: 'Choose a map', content: '<button class="button" onclick="selectMap(\'Cargo\', this)">Cargo Port</button><br><!--<button class="button" onclick="selectMap(this)">Vertex</button><br><button class="button" onclick="selectMap(this)">Apex</button><br><button class="button" onclick="selectMap(this)">Everest</button><br>--><button class="button" onclick="selectMap(\'Ghost\', this)">Ghost Town</button><!--<br><button class="button" onclick="selectMap(this)">Harvest</button><br>-->' }, csf ? csf : chooseMode);
}
function chooseMode(csf = null) {
setDialog('open', { title: 'Choose a game mode', content: '<button class="button" onclick="selectMode(this)">Slayer</button><br><button class="button" onclick="selectMode(this)">Fiesta</button><br><button class="button" onclick="selectMode(this)">Snipers</button><br><button class="button" onclick="selectMode(this)">Rock N\' Rail</button><br><button class="button" onclick="location.assign(\'practice.html\')">Practice</button>' }, csf ? csf : findLobby);
setDialog('open', { title: 'Choose a game mode', content: '<button class="button" onclick="selectMode(\'Slayer\', this)">Slayer</button><br><button class="button" onclick="selectMode(\'Fiesta\', this)">Fiesta</button><br><button class="button" onclick="selectMode(\'Snipers\', this)">Snipers</button><br><button class="button" onclick="selectMode(\'RockNRail\', this)">Rock N\' Rail</button><br><button class="button" onclick="location.assign(\'practice.html\')">Practice</button>' }, csf ? csf : findLobby);
}
// function startLocalGame() {
// location.assign("./play.html?splitscreen=true&map="+els[0]);
// location.assign("./play.html?splitscreen=true&map="+selectedMap);
// }
els = [];
els1 = [];
selectedMap = "Cargo";
selectedMode = "Slayer";
function selectMap(map, el) {
!(els.indexOf(map) > -1) ? (els.push(map), el.style.outline = "2px solid #999") : (els.splice(els.indexOf(map)), el.style.outline = "none");
selectedMap = map;
el.style.outline = "2px solid #999";
for(let i=0;i<(()=>{let g=Object.values(el.parentNode.children);g.splice(Object.values(el.parentNode.children).indexOf(el),1);return(g)})().length;i++){(()=>{let g=Object.values(el.parentNode.children);g.splice(Object.values(el.parentNode.children).indexOf(el),1);return(g)})()[i].style.outline="none"}
}
function selectMode(mode) {
!(els1.indexOf(mode.textContent) > -1) ? (els1.push(mode.textContent.replace(/( |\')/gi,"")), mode.style.outline = "2px solid #999") : (els1.splice(els1.indexOf(mode.textContent)), mode.style.outline = "none");
function selectMode(mode, el) {
selectedMode = mode;
el.style.outline = "2px solid #999";
for(let i=0;i<(()=>{let g=Object.values(el.parentNode.children);g.splice(Object.values(el.parentNode.children).indexOf(el),1);return(g)})().length;i++){(()=>{let g=Object.values(el.parentNode.children);g.splice(Object.values(el.parentNode.children).indexOf(el),1);return(g)})()[i].style.outline="none"}
}
createlobbytext = "";
function createLobby(name) {
Expand All @@ -356,13 +360,13 @@ <h2 class="page-text">Multiplayer shooter</h2>
lobby.set("scoreLimit", document.getElementsByName("customScoreLimit")[0].value);
lobby.set("timeLimit", document.getElementsByName("customTimeLimit")[0].value);
lobby.set("inactve", false);
lobby.save().then(() => console.log("Lobby \"" + name.toString() + "\" saved"), findLobby(name.toString(), () => { document.querySelector(".dialog-content").innerHTML += '<div class="lobby" id="'+btoa(encodeURIComponent(name.toString())).replace(/\=/gi,"")+'">"<a onclick="location.assign(\'./play.html?lobby='+encodeURIComponent(name.toString())+("&map="+(els[0]||"Cargo"))+("&mode="+(els1[0]||"Slayer"))+'\')" style="border:2px solid #25750a">'+(name.toString().trim()==""?("(blank space)"):name.toString().trim())+'</a>" : '+(new Date).toString().split(" ").splice(1).reverse().splice(4).reverse().join(" ").split(":").reverse().splice(1).reverse().join(":")+"</div>", location.hash = btoa(encodeURIComponent(name.toString())).replace(/\=/gi,"") }));
lobby.save().then(() => console.log("Lobby \"" + name.toString() + "\" saved"), findLobby(name.toString(), () => { document.querySelector(".dialog-content").innerHTML += '<div class="lobby" id="'+btoa(encodeURIComponent(name.toString())).replace(/\=/gi,"")+'">"<a onclick="location.assign(\'./play.html?lobby='+encodeURIComponent(name.toString())+("&map="+(selectedMap||"Cargo"))+("&mode="+(selectedMode||"Slayer"))+'\')" style="border:2px solid #25750a">'+(name.toString().trim()==""?("(blank space)"):name.toString().trim())+'</a>" : '+(new Date).toString().split(" ").splice(1).reverse().splice(4).reverse().join(" ").split(":").reverse().splice(1).reverse().join(":")+"</div>", location.hash = btoa(encodeURIComponent(name.toString())).replace(/\=/gi,"") }));
});
}
function findLobby(l, addlobby = null) {
Notiflix.Notify.info("Loading lobbies...");
let islobbyadded=false;
(async()=>{let e=!1;const t=Parse.Object.extend("Lobby"),n=new Parse.Query(t),s=await n.find();for(let t=0;t<s.length;t++){const n=Parse.Object.extend("Lobby");new Parse.Query(n).get(s[t].id).then((t=>{const n={name:t.get("name"),time:t.get("createdAt")};e?(document.querySelector("#NotiflixNotifyWrap").children[0].click(),(!!addlobby&&!islobbyadded&&(islobbyadded=true,addlobby())),document.querySelector(".dialog-content").innerHTML+='<div class="lobby" id="'+btoa(encodeURIComponent(n.name)).replace(/\=/gi,"")+'">"<a onclick="location.assign(\'./play.html?lobby='+encodeURIComponent(n.name)+("&map="+(els[0]||"Cargo"))+("&mode="+(els1[0]||"Slayer"))+'\')">'+(n.name.trim()==""?("(blank space)"):n.name.trim())+'</a>" : '+n.time.toString().split(" ").reverse().splice(4).reverse().splice(1).join(" ").split(":").reverse().splice(1).reverse().join(":")+"</div>"):(document.querySelector("#NotiflixNotifyWrap").children[0].click(),setDialog("open",{title:"Choose a map",content:'<i style="color:#333">Lobbies marked <span style="text-decoration:underline">red</span> are inactive.</i><br><div class="lobby" data-inactive="'+(n.inactive)+'" id="'+btoa(encodeURIComponent(n.name)).replace(/\=/gi,"")+'">"<a onclick="location.assign(\'./play.html?lobby='+encodeURIComponent(n.name)+("&map="+(els[0]||"Cargo"))+("&mode="+(els1[0]||"Slayer"))+'\')">'+n.name+'</a>" : '+n.time.toString().split(" ").reverse().splice(4).reverse().splice(1).join(" ").split(":").reverse().splice(1).reverse().join(":")+"</div>"}, () => {})),e=!0}),(e=>{}))}})();
(async()=>{let e=!1;const t=Parse.Object.extend("Lobby"),n=new Parse.Query(t),s=await n.find();for(let t=0;t<s.length;t++){const n=Parse.Object.extend("Lobby");new Parse.Query(n).get(s[t].id).then((t=>{const n={name:t.get("name"),time:t.get("createdAt"),active:t.get("active")};e?(document.querySelector("#NotiflixNotifyWrap").children[0].click(),(!!addlobby&&!islobbyadded&&(islobbyadded=true,addlobby())),document.querySelector(".dialog-content").innerHTML+='<div class="lobby" id="'+btoa(encodeURIComponent(n.name)).replace(/\=/gi,"")+'">"<a '+(!n.active?'style="color:#ff4444!important"':'')+' onclick="location.assign(\'./play.html?lobby='+encodeURIComponent(n.name)+("&map="+(selectedMap||"Cargo"))+("&mode="+(selectedMode||"Slayer"))+'\')">'+(n.name.trim()==""?("(blank space)"):n.name.trim())+'</a>" : '+n.time.toString().split(" ").reverse().splice(4).reverse().splice(1).join(" ").split(":").reverse().splice(1).reverse().join(":")+"</div>"):(document.querySelector("#NotiflixNotifyWrap").children[0].click(),setDialog("open",{title:"Choose a map",content:'<i style="color:#333">Lobbies marked <span style="text-decoration:underline">red</span> are inactive.</i><br><div class="lobby" data-inactive="'+(n.inactive)+'" id="'+btoa(encodeURIComponent(n.name)).replace(/\=/gi,"")+'">"<a '+(!n.active?'style="color:#ff4444!important"':'')+' onclick="location.assign(\'./play.html?lobby='+encodeURIComponent(n.name)+("&map="+(selectedMap||"Cargo"))+("&mode="+(selectedMode||"Slayer"))+'\')">'+n.name+'</a>" : '+n.time.toString().split(" ").reverse().splice(4).reverse().splice(1).join(" ").split(":").reverse().splice(1).reverse().join(":")+"</div>"}, () => {})),e=!0}),(e=>{}))}})();
}
function chooseRandom() {
location.assign('./play.html?lobby='+["RandomLobby", "MyLobby", "Randomness"][Math.floor(Math.random()*3)]+'&map='+(chooseMap(()=>{}),document.querySelector(".dialog-box.fixed-dialog-box").style.display="none",(()=>{g=[];for(let i=0;i<document.querySelector(".dialog-content").innerHTML.split("<br>").length;i++){i>=5||g.push(document.querySelector(".dialog-content").innerHTML.split("<br>")[i].split("\">")[1].split("<")[0])}document.querySelector(".dialog-box.fixed-dialog-box").style.display="block";document.querySelector(".dialog-action").querySelector("a.btn").children[0].click();return g})()[Math.floor(Math.random()*document.querySelector(".dialog-content").innerHTML.split("<br>").length)]));
Expand Down
10 changes: 7 additions & 3 deletions src.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
box-shadow: 0 3px 5px #25750a;
}
</style>
<script type="text/javascript" src="https://npmcdn.com/parse/dist/parse.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Gametime.js-2.0@latest/gametime.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/gh/Parking-Master/Gametime.js@latest/js/username-generator.min.js"></script> -->
Expand Down Expand Up @@ -423,6 +424,7 @@ <h1 style="color:#25750a;font-weight:bold;font-family:monospace;position:absolut
</script> -->
<!-- <script src="https://cdn.jsdelivr.net/gh/Parking-Master/FPS@master/gametime-socket.js"></script> -->
<script>
Parse.initialize("qEK42aDtmQiBXmIoRdojDAYrKXGj5w4h2QnNRpYz","J4IK0gqf8rQS8G8Hg5LDbz0oEASJtRlUS2LPiRVg"),Parse.serverURL="https://parseapi.back4app.com/";
defaultKeys = "f,b,r, ,t,m,y,i,z,p";
keyControls = {
"shoot": (localStorage["prefsKeyControls"] || defaultKeys).split(",")[0],
Expand Down Expand Up @@ -694,9 +696,10 @@ <h1 style="color:#25750a;font-weight:bold;font-family:monospace;position:absolut
button: "Return"
}).then(() => { gametime.disconnect(), location.assign("/") });
});
window.addEventListener("beforeunload", () => {
gametime.run("leftGame");
});
window.onbeforeunload=function(e){
e.preventDefault();
return (gametime.run("leftGame"),(async()=>{let e=!1;const t=Parse.Object.extend("Lobby"),n=new Parse.Query(t),s=await n.find();for(let t=0;t<s.length;t++){const n=Parse.Object.extend("Lobby");new Parse.Query(n).get(s[t].id).then((t=>{const n={name:t.get("name"),time:t.get("createdAt"),active:t.get("active")};e?(()=>{n.name==new URLSearchParams(location.search).get("lobby")&&(t.set("active",false),t.save())})():(()=>{n.name==new URLSearchParams(location.search).get("lobby")&&(t.set("active",false),t.save())})(),e=!0}),(e=>{}))}})());
};
gametime.on("pickupWeapon", function(e) {
ordinances[e].position.y=10000;
scene.remove(ordinances[e]);
Expand Down Expand Up @@ -1289,6 +1292,7 @@ <h1 style="color:#25750a;font-weight:bold;font-family:monospace;position:absolut
clearInterval(searchingEngine);
}
});
(async()=>{let e=!1;const t=Parse.Object.extend("Lobby"),n=new Parse.Query(t),s=await n.find();for(let t=0;t<s.length;t++){const n=Parse.Object.extend("Lobby");new Parse.Query(n).get(s[t].id).then((t=>{const n={name:t.get("name"),time:t.get("createdAt"),active:t.get("active")};e?(()=>{n.name==new URLSearchParams(location.search).get("lobby")&&(t.set("active",true),t.save())})():(()=>{n.name==new URLSearchParams(location.search).get("lobby")&&(t.set("active",true),t.save())})(),e=!0}),(e=>{}))}})();
});
function crashWarthog(warthog) {
(new THREE.GLTFLoader).load("models/vehicles/obstructed/warthog.glb", (e) => {
Expand Down

0 comments on commit dee0dd3

Please sign in to comment.