Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async () => {
- const sleep = ms => new Promise(r=>setTimeout(r,ms));
- const rand=(a,b)=>Math.floor(Math.random()*(b-a+1))+a;
- const chars="█▓▒░@#*+=:.~".split("");
- let mouseX=0;
- let mouseY=0;
- document.addEventListener("mousemove",e=>{
- mouseX=e.clientX;
- mouseY=e.clientY;
- });
- function randChar(){
- return chars[rand(0,chars.length-1)];
- }
- function writeCharAt(c,col,x,y){
- w.changeColor(col);
- w.tp(Math.round(x),Math.round(y));
- writeChar(c,1);
- }
- function createParticles(x,y,count,speed,life){
- const parts=[];
- for(let i=0;i<count;i++){
- const a=Math.random()*Math.PI*2;
- parts.push({
- x,
- y,
- vx:Math.cos(a)*Math.random()*speed,
- vy:Math.sin(a)*Math.random()*speed,
- life,
- char:randChar(),
- color:rand(2,29)
- });
- }
- return parts;
- }
- async function runParticles(parts,gravity,delay){
- while(parts.length){
- for(let i=parts.length-1;i>=0;i--){
- let p=parts[i];
- p.x+=p.vx;
- p.y+=p.vy;
- p.vy+=gravity;
- writeCharAt(p.char,p.color,p.x,p.y);
- p.life--;
- if(p.life<=0) parts.splice(i,1);
- }
- await sleep(delay);
- }
- }
- async function lava(cx,cy,r){
- for(let i=0;i<r*40;i++){
- let dx=rand(-r,r);
- let dy=rand(-r,r);
- if(dx*dx+dy*dy<=r*r){
- writeCharAt("~",rand(9,14),cx+dx,cy+dy);
- }
- await sleep(5);
- }
- }
- async function lightning(cx,cy){
- let x=cx;
- let y=cy;
- for(let i=0;i<150;i++){
- x+=rand(-2,2);
- y+=rand(-1,1);
- writeCharAt("⚡",11,x,y);
- await sleep(20);
- }
- }
- async function gravityCollapse(cx,cy,r){
- for(let d=r;d>0;d--){
- for(let dx=-d;dx<=d;dx++)
- for(let dy=-d;dy<=d;dy++){
- if(dx*dx+dy*dy<=d*d){
- writeCharAt(".",0,cx+dx,cy+dy);
- }
- }
- await sleep(30);
- }
- }
- async function fractal(cx,cy,r,depth,particles,power,gravity,delay,duration){
- if(depth<=0) return;
- const p=createParticles(cx,cy,particles/4,power,duration);
- await runParticles(p,gravity,delay);
- await fractal(cx+r/2,cy,r/2,depth-1,particles,power,gravity,delay,duration);
- await fractal(cx-r/2,cy,r/2,depth-1,particles,power,gravity,delay,duration);
- await fractal(cx,cy+r/2,r/2,depth-1,particles,power,gravity,delay,duration);
- }
- async function meteor(cx,cy,r,particles,power,gravity,delay,duration){
- let mx=cx+rand(-r*2,r*2);
- let my=cy-r*5;
- for(let i=0;i<r*6;i++){
- mx+=(cx-mx)*0.05;
- my+=1.5;
- writeCharAt("☄",rand(9,15),mx,my);
- await sleep(delay);
- }
- const p=createParticles(cx,cy,particles,power*3,duration);
- await runParticles(p,gravity,delay);
- }
- async function vortex(cx,cy,particles,gravity,delay,duration){
- const parts=createParticles(cx,cy,particles,2,duration);
- while(parts.length){
- for(let i=parts.length-1;i>=0;i--){
- let p=parts[i];
- let dx=cx-p.x;
- let dy=cy-p.y;
- p.vx+=dx*0.002;
- p.vy+=dy*0.002;
- p.x+=p.vx;
- p.y+=p.vy;
- writeCharAt("•",rand(2,29),p.x,p.y);
- p.life--;
- if(p.life<=0) parts.splice(i,1);
- }
- await sleep(delay);
- }
- }
- async function chain(cx,cy,r,particles,power,gravity,delay,duration){
- for(let i=0;i<8;i++){
- let nx=cx+rand(-r*2,r*2);
- let ny=cy+rand(-r*2,r*2);
- const p=createParticles(nx,ny,particles/2,power*2,duration);
- runParticles(p,gravity,delay);
- await sleep(300);
- }
- }
- async function shockwave(cx,cy,particles,gravity,delay,duration){
- const parts=createParticles(cx,cy,particles,1,duration);
- let wave=0;
- while(parts.length){
- wave+=0.5;
- for(let i=parts.length-1;i>=0;i--){
- let p=parts[i];
- let dx=p.x-cx;
- let dy=p.y-cy;
- let dist=Math.sqrt(dx*dx+dy*dy);
- if(dist<wave){
- p.vx+=dx*0.2;
- p.vy+=dy*0.2;
- }
- p.x+=p.vx;
- p.y+=p.vy;
- writeCharAt(randChar(),rand(2,29),p.x,p.y);
- p.life--;
- if(p.life<=0) parts.splice(i,1);
- }
- await sleep(delay);
- }
- }
- const settings = await new Promise(resolve=>{
- const hud=document.createElement("div");
- Object.assign(hud.style,{
- position:"fixed",
- top:"50%",
- left:"50%",
- transform:"translate(-50%,-50%)",
- background:"#120000",
- color:"#ff9933",
- padding:"25px",
- border:"2px solid #ff3333",
- fontFamily:"monospace",
- zIndex:999999
- });
- hud.innerHTML=`
- <h2>VAPORIZER v4</h2>
- Radius
- <input id="r" type="number" value="20" style="width:100%">
- X
- <input id="x" type="number" style="width:100%">
- Y
- <input id="y" type="number" style="width:100%">
- Mode
- <select id="mode" style="width:100%">
- <option value="particle">Particle Explosion</option>
- <option value="lava">Lava Flood</option>
- <option value="lightning">Lightning</option>
- <option value="gravity">Gravity Collapse</option>
- <option value="fractal">Fractal Explosion</option>
- <option value="meteor">Meteor Strike</option>
- <option value="vortex">Black Hole</option>
- <option value="chain">Chain Reaction</option>
- <option value="shockwave">Shockwave</option>
- </select>
- Speed
- <input id="speed" type="range" min="1" max="100" value="50" style="width:100%">
- Duration
- <input id="duration" type="range" min="10" max="200" value="80" style="width:100%">
- Particles
- <input id="particles" type="range" min="50" max="2000" value="500" style="width:100%">
- Power
- <input id="power" type="range" min="1" max="10" value="3" style="width:100%">
- Gravity
- <input id="gravity" type="range" min="0" max="10" value="3" style="width:100%">
- Auto Target Cursor
- <input id="cursorTarget" type="checkbox">
- <br><br>
- <button id="go" style="width:100%;padding:10px;background:#8b0000;color:white;font-weight:bold">
- ARM & DETONATE
- </button>
- `;
- document.body.appendChild(hud);
- document.getElementById("go").onclick=()=>{
- resolve({
- radius:+document.getElementById("r").value,
- x:+document.getElementById("x").value,
- y:-+document.getElementById("y").value,
- mode:document.getElementById("mode").value,
- speed:+document.getElementById("speed").value,
- duration:+document.getElementById("duration").value,
- particles:+document.getElementById("particles").value,
- power:+document.getElementById("power").value,
- gravity:+document.getElementById("gravity").value,
- cursorTarget:document.getElementById("cursorTarget").checked
- });
- hud.remove();
- };
- });
- let {radius,x,y,mode,speed,duration,particles,power,gravity,cursorTarget}=settings;
- const delay=Math.max(1,60-speed);
- gravity=gravity*0.02;
- if(cursorTarget){
- x=Math.floor(mouseX/10);
- y=-Math.floor(mouseY/18);
- }
- for(let i=5;i>=1;i--){
- console.log("Detonation in",i);
- await sleep(1000);
- }
- if(mode==="particle"){
- const p=createParticles(x,y,particles,power,duration);
- await runParticles(p,gravity,delay);
- }
- if(mode==="lava") await lava(x,y,radius);
- if(mode==="lightning") await lightning(x,y);
- if(mode==="gravity") await gravityCollapse(x,y,radius);
- if(mode==="fractal") await fractal(x,y,radius,3,particles,power,gravity,delay,duration);
- if(mode==="meteor") await meteor(x,y,radius,particles,power,gravity,delay,duration);
- if(mode==="vortex") await vortex(x,y,particles,gravity,delay,duration);
- if(mode==="chain") await chain(x,y,radius,particles,power,gravity,delay,duration);
- if(mode==="shockwave") await shockwave(x,y,particles,gravity,delay,duration);
- })();
Advertisement
Add Comment
Please, Sign In to add comment