diff --git a/assets/index-Do3chIt8.js b/assets/index-Do3chIt8.js deleted file mode 100644 index a64f8d8..0000000 --- a/assets/index-Do3chIt8.js +++ /dev/null @@ -1 +0,0 @@ -(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))R(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const v of n.addedNodes)v.tagName==="LINK"&&v.rel==="modulepreload"&&R(v)}).observe(document,{childList:!0,subtree:!0});function F(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function R(r){if(r.ep)return;r.ep=!0;const n=F(r);fetch(r.href,n)}})();const c=document.querySelector("#hero"),t=document.querySelector(".npc-12"),A=document.querySelector(".npc__collision-box"),g=document.querySelector(".hero__collision-box"),y=document.querySelector(".score-counter"),w=document.querySelector(".game__start-screen"),m=document.querySelector(".game__end-screen"),C=document.querySelector(".game__start-button"),M=document.querySelector(".game__instructions-button"),B=document.querySelector(".game__instructions"),l=document.querySelector(".game__background"),T=document.querySelector(".one"),$=document.querySelector(".two"),b=document.querySelector(".three");if(!c||!t||!A||!g||!y||!w||!m||!C||!l||!M||!B||!T||!$||!b)throw new Error("Issues with selector");const G=10,N=8;let O,E,f,p,a=3,d=0,h=0,x=!1,H=100,W=15,L=4,S=5,D=0,J=25;const u=["src/resources/character-sprites/npc-0.png","src/resources/character-sprites/npc-2.png","src/resources/character-sprites/npc-4.png","src/resources/character-sprites/npc-6.png","src/resources/character-sprites/npc-8.png","src/resources/character-sprites/npc-10.png","src/resources/character-sprites/npc-12.png","src/resources/images/WHAM.png"],k=["./src/resources/character-sprites/mc-run(1).png","./src/resources/character-sprites/mc-run(2).png","./src/resources/character-sprites/mc-run(3).png"],e={x:0,y:0,width:90,height:40},i={x:550,y:240,width:20,height:40},I=()=>{c.style.width=`${e.width}px`,c.style.height=`${e.height}px`,c.style.backgroundImage=`url('${k[h]}')`,h=(h+1)%k.length,g.style.width=`${e.width-30}px`,g.style.height=`${e.height}px`,E=setTimeout(I,1e3/G)},q=()=>{y.innerText=`Score: ${d.toLocaleString()}`,p||(p=performance.now());const s=performance.now(),o=Math.floor((s-p)/1e3);d+=o,y.innerText=`Score: ${d.toLocaleString()}`,O=setTimeout(q,100)};w.classList.add("hide");l.style.backgroundImage="none";m.classList.add("hide");M.addEventListener("click",()=>{B.classList.add("hide"),w.classList.add("show-flex")});C.addEventListener("click",()=>{w.classList.remove("show-flex"),l&&(l.style.backgroundImage="url('src/resources/environment/office(2).png')",l.style.animation="sceneMovement 9s linear infinite"),y.classList.add("show");const s=Math.floor(Math.random()*(u.length-1));t.style.backgroundImage=`url('${u[s]}')`,q(),I(),_()});const K=()=>{p=0,a=3,d=0,h=0,x=!1,T.classList.remove("game__life-remove"),$.classList.remove("game__life-remove"),b.classList.remove("game__life-remove"),l.style.animation="sceneMovement 9s linear infinite",q(),I(),_()};document.addEventListener("keydown",s=>{s.key==="ArrowUp"&&!x&&(x=!0,P())});const j=()=>{e.y<0?(e.y+=S,e.x+=D,c.style.top=`${e.y}px`,c.style.right=`${e.x}px`,setTimeout(j,1e3/60)):(e.y=0,e.x=0,c.style.top=`${e.y}px`,c.style.right=`${e.x}px`,x=!1)},P=()=>{e.y>=-H?(e.y-=W,e.x-=L,c.style.top=`${e.y}px`,c.style.right=`${e.x}px`,setTimeout(P,1e3/60)):j()},U=()=>{const s=g.getBoundingClientRect(),o=t.getBoundingClientRect();s.x+17o.x&&s.yo.y&&(Q(),d-=100,S=50,L=0,c.style.width="40px",c.style.height="40px",c.style.backgroundImage=`url('${u[7]}')`,t.style.width="40px",t.style.height="40px",t.style.backgroundImage=`url('${u[7]}')`,setTimeout(()=>{t.style.display="none",S=5,L=4,a>0&&(f=setTimeout(_,1e3))},500),clearTimeout(f))},z=()=>{clearTimeout(f),clearTimeout(E),clearTimeout(O),l.style.animation="none",m.classList.remove("hide")};m.addEventListener("click",()=>{m.classList.add("hide"),K()});const Q=()=>{a-=1,a===2?T.classList.add("game__life-remove"):a===1?$.classList.add("game__life-remove"):a===0&&(b.classList.add("game__life-remove"),console.log("last life is gone"),z())},_=()=>{const s=t.getBoundingClientRect();if(t.style.position="absolute",t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.left=`${i.x}px`,t.style.top=`${i.y}px`,s.x<=0){const o=Math.floor(Math.random()*(u.length-1));t.style.backgroundImage=`url('${u[o]}')`,t.style.display="block",i.x=window.innerWidth}i.x-=J,t.style.left=`${i.x}px`,f=setTimeout(_,1e3/N),U()}; diff --git a/assets/index-Dre7EbrV.js b/assets/index-Dre7EbrV.js new file mode 100644 index 0000000..fb2f7fb --- /dev/null +++ b/assets/index-Dre7EbrV.js @@ -0,0 +1 @@ +(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))R(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const v of n.addedNodes)v.tagName==="LINK"&&v.rel==="modulepreload"&&R(v)}).observe(document,{childList:!0,subtree:!0});function F(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function R(r){if(r.ep)return;r.ep=!0;const n=F(r);fetch(r.href,n)}})();const c=document.querySelector("#hero"),t=document.querySelector(".npc-12"),A=document.querySelector(".npc__collision-box"),g=document.querySelector(".hero__collision-box"),y=document.querySelector(".score-counter"),w=document.querySelector(".game__start-screen"),m=document.querySelector(".game__end-screen"),C=document.querySelector(".game__start-button"),M=document.querySelector(".game__instructions-button"),B=document.querySelector(".game__instructions"),l=document.querySelector(".game__background"),T=document.querySelector(".one"),$=document.querySelector(".two"),b=document.querySelector(".three");if(!c||!t||!A||!g||!y||!w||!m||!C||!l||!M||!B||!T||!$||!b)throw new Error("Issues with selector");const G=10,N=8;let O,E,f,p,a=3,d=0,h=0,x=!1,H=100,W=15,L=4,S=5,D=0,J=25;const u=["src/resources/character-sprites/npc-0.png","src/resources/character-sprites/npc-2.png","src/resources/character-sprites/npc-4.png","src/resources/character-sprites/npc-6.png","src/resources/character-sprites/npc-8.png","src/resources/character-sprites/npc-10.png","src/resources/character-sprites/npc-12.png","src/resources/images/WHAM.png"],k=["src/resources/character-sprites/mc-run(1).png","src/resources/character-sprites/mc-run(2).png","src/resources/character-sprites/mc-run(3).png"],e={x:0,y:0,width:90,height:40},i={x:550,y:240,width:20,height:40},I=()=>{c.style.width=`${e.width}px`,c.style.height=`${e.height}px`,c.style.backgroundImage=`url('${k[h]}')`,h=(h+1)%k.length,g.style.width=`${e.width-30}px`,g.style.height=`${e.height}px`,E=setTimeout(I,1e3/G)},q=()=>{y.innerText=`Score: ${d.toLocaleString()}`,p||(p=performance.now());const s=performance.now(),o=Math.floor((s-p)/1e3);d+=o,y.innerText=`Score: ${d.toLocaleString()}`,O=setTimeout(q,100)};w.classList.add("hide");l.style.backgroundImage="none";m.classList.add("hide");M.addEventListener("click",()=>{B.classList.add("hide"),w.classList.add("show-flex")});C.addEventListener("click",()=>{w.classList.remove("show-flex"),l&&(l.style.backgroundImage="url('src/resources/environment/office(2).png')",l.style.animation="sceneMovement 9s linear infinite"),y.classList.add("show");const s=Math.floor(Math.random()*(u.length-1));t.style.backgroundImage=`url('${u[s]}')`,q(),I(),_()});const K=()=>{p=0,a=3,d=0,h=0,x=!1,T.classList.remove("game__life-remove"),$.classList.remove("game__life-remove"),b.classList.remove("game__life-remove"),l.style.animation="sceneMovement 9s linear infinite",q(),I(),_()};document.addEventListener("keydown",s=>{s.key==="ArrowUp"&&!x&&(x=!0,P())});const j=()=>{e.y<0?(e.y+=S,e.x+=D,c.style.top=`${e.y}px`,c.style.right=`${e.x}px`,setTimeout(j,1e3/60)):(e.y=0,e.x=0,c.style.top=`${e.y}px`,c.style.right=`${e.x}px`,x=!1)},P=()=>{e.y>=-H?(e.y-=W,e.x-=L,c.style.top=`${e.y}px`,c.style.right=`${e.x}px`,setTimeout(P,1e3/60)):j()},U=()=>{const s=g.getBoundingClientRect(),o=t.getBoundingClientRect();s.x+17o.x&&s.yo.y&&(Q(),d-=100,S=50,L=0,c.style.width="40px",c.style.height="40px",c.style.backgroundImage=`url('${u[7]}')`,t.style.width="40px",t.style.height="40px",t.style.backgroundImage=`url('${u[7]}')`,setTimeout(()=>{t.style.display="none",S=5,L=4,a>0&&(f=setTimeout(_,1e3))},500),clearTimeout(f))},z=()=>{clearTimeout(f),clearTimeout(E),clearTimeout(O),l.style.animation="none",m.classList.remove("hide")};m.addEventListener("click",()=>{m.classList.add("hide"),K()});const Q=()=>{a-=1,a===2?T.classList.add("game__life-remove"):a===1?$.classList.add("game__life-remove"):a===0&&(b.classList.add("game__life-remove"),console.log("last life is gone"),z())},_=()=>{const s=t.getBoundingClientRect();if(t.style.position="absolute",t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.left=`${i.x}px`,t.style.top=`${i.y}px`,s.x<=0){const o=Math.floor(Math.random()*(u.length-1));t.style.backgroundImage=`url('${u[o]}')`,t.style.display="block",i.x=window.innerWidth}i.x-=J,t.style.left=`${i.x}px`,f=setTimeout(_,1e3/N),U()}; diff --git a/index.html b/index.html index 55994c1..3c8c6c4 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ href="/assets/personal-space-invaders_dodging-small-talk_LOGO-DVKqBW6Y.png"/> Personal-Space Invaders - +