Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions Appteste
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>WS Battle Royale</title>
<style>
html,body{margin:0;padding:0;overflow:hidden;background:black;font-family:Arial}
canvas{display:block;width:100vw;height:100vh}
@media screen and (orientation:portrait){
body{transform:rotate(90deg);transform-origin:center;width:100vh;height:100vw;position:absolute;top:0;left:0;}
}

/* MENU */
#menu{position:fixed;inset:0;z-index:10;background:radial-gradient(circle,#111,#000);display:flex;align-items:center;justify-content:center;flex-direction:column}
#menu h1{font-size:64px;letter-spacing:6px;color:#fff;opacity:.12;position:absolute;top:50%;transform:translateY(-50%)}
#menu .panel{z-index:2;background:rgba(0,0,0,.6);padding:20px 26px;border-radius:14px}
#menu button{width:220px;margin:8px 0;padding:14px;border-radius:10px;border:none;font-size:18px;color:#fff;background:linear-gradient(#ff3b3b,#c0392b);cursor:pointer}

/* CONTROLES */
#joystick{position:fixed;left:30px;bottom:40px;width:120px;height:120px;border-radius:50%;background:rgba(255,255,255,.15);touch-action:none}
#stick{position:absolute;left:40px;top:40px;width:40px;height:40px;border-radius:50%;background:white}
.btn{position:fixed;width:80px;height:80px;border-radius:50%;border:none;font-size:20px;color:white;cursor:pointer}
#shoot{right:30px;bottom:50px;background:#c0392b}
#weapon{right:130px;bottom:50px;background:#21618c}
#hudbtn{right:230px;bottom:50px;background:#1e8449}
</style>
</head>
<body>

<div id="menu">
<h1>WS</h1>
<div class="panel">
<button onclick="startGame()">JOGAR</button>
<button onclick="cycleSkin()">SKIN</button>
<button onclick="toggleSound()">SOM</button>
</div>
</div>

<canvas id="game"></canvas>
<div id="joystick"><div id="stick"></div></div>
<button id="shoot" class="btn">🔫</button>
<button id="weapon" class="btn">🔁</button>
<button id="hudbtn" class="btn">⚙️</button>

<script>
const canvas=document.getElementById("game"),ctx=canvas.getContext("2d");
function resize(){canvas.width=innerWidth;canvas.height=innerHeight}
resize();addEventListener('resize',resize);

/* MENU */
let soundOn=true;
function startGame(){
document.getElementById('menu').style.display='none';
if(document.documentElement.requestFullscreen){document.documentElement.requestFullscreen();}
}
function toggleSound(){soundOn=!soundOn}
function cycleSkin(){skin=(skin+1)%skins.length}

/* PLAYER */
let player={x:canvas.width/2,y:canvas.height/2,angle:0,speed:3,life:100}

/* SKINS */
const skins=[{body:'#2980b9',head:'#f1c27d'},{body:'#e67e22',head:'#f5d7b2'},{body:'#2ecc71',head:'#f1c27d'}]
let skin=0

/* ARMAS */
const weapons=[{name:"Pistol",dmg:25,spd:7,rate:20},{name:"Rifle",dmg:40,spd:9,rate:10},{name:"SMG",dmg:18,spd:10,rate:5}]
let weaponIndex=1,fireCD=0

/* SCORE */
let kills=0,rank="Bronze",hsFx=0

/* MAP */
function drawMap(){ctx.fillStyle="#7f8c8d";ctx.fillRect(0,0,canvas.width,canvas.height)}

/* JOYSTICK */
const joy=document.getElementById("joystick"),stick=document.getElementById("stick")
let joyData={x:0,y:0},joyActive=false
joy.addEventListener("touchstart",e=>{joyActive=true;e.preventDefault()},{passive:false})
joy.addEventListener("touchmove",e=>{
if(!joyActive)return;e.preventDefault()
let r=joy.getBoundingClientRect()
let x=e.touches[0].clientX-r.left-60
let y=e.touches[0].clientY-r.top-60
let d=Math.hypot(x,y)
if(d>40){x*=40/d;y*=40/d}
stick.style.left=(x+40)+"px";stick.style.top=(y+40)+"px"
joyData.x=x/40;joyData.y=y/40
},{passive:false})
joy.addEventListener("touchend",()=>{joyActive=false;joyData={x:0,y:0};stick.style.left="40px";stick.style.top="40px"})

function movePlayer(){
player.x+=joyData.x*player.speed
player.y+=joyData.y*player.speed
if(joyData.x||joyData.y)player.angle=Math.atan2(joyData.y,joyData.x)
}

/* DRAW PLAYER */
function drawPlayer(){
ctx.save();ctx.translate(player.x,player.y);ctx.rotate(player.angle)
ctx.fillStyle=skins[skin].body;ctx.beginPath();ctx.arc(0,0,14,0,Math.PI*2);ctx.fill()
ctx.fillStyle=skins[skin].head;ctx.beginPath();ctx.arc(0,-18,8,0,Math.PI*2);ctx.fill()
ctx.strokeStyle="black";ctx.lineWidth=4;ctx.beginPath();ctx.moveTo(0,0);ctx.lineTo(30,0);ctx.stroke()
ctx.restore()
}

/* ENEMIES */
let enemies=[],bullets=[],loot=[]
function spawnEnemy(){enemies.push({x:Math.random()*canvas.width,y:Math.random()*canvas.height,life:90})}
setInterval(spawnEnemy,1300)

function drawEnemies(){
enemies.forEach((e,ei)=>{
let a=Math.atan2(player.y-e.y,player.x-e.x)
e.x+=Math.cos(a)*0.4; e.y+=Math.sin(a)*0.4
ctx.fillStyle="#8e44ad"; ctx.beginPath(); ctx.arc(e.x,e.y,14,0,Math.PI*2); ctx.fill()
ctx.fillStyle="#f1c27d"; ctx.beginPath(); ctx.arc(e.x,e.y-18,8,0,Math.PI*2); ctx.fill()
})
}

/* SHOOT */
document.getElementById("shoot").addEventListener("touchstart",()=>{
if(fireCD>0)return
let w=weapons[weaponIndex]
bullets.push({x:player.x,y:player.y,dx:Math.cos(player.angle)*w.spd,dy:Math.sin(player.angle)*w.spd,dmg:w.dmg})
fireCD=w.rate
})
document.getElementById("weapon").onclick=()=>weaponIndex=(weaponIndex+1)%weapons.length

function drawBullets(){
if(fireCD>0)fireCD--
ctx.fillStyle="yellow"
bullets.forEach((b,bi)=>{
b.x+=b.dx;b.y+=b.dy;ctx.fillRect(b.x,b.y,4,4)
enemies.forEach((e,ei)=>{
if(Math.hypot(b.x-e.x,b.y-(e.y-18))<10){
e.life-=weapons[weaponIndex].dmg // dano normal
bullets.splice(bi,1)
if(e.life<=0){kills++;loot.push({x:e.x,y:e.y});enemies.splice(ei,1)}
}
})
})
}

/* LOOT */
function drawLoot(){
ctx.fillStyle="gold"
loot.forEach(l=>{
ctx.fillRect(l.x-6,l.y-6,12,12)
if(Math.hypot(player.x-l.x,player.y-l.y)<20)player.life=100
})
}

/* HUD */
function hud(){
ctx.fillStyle="white"
ctx.fillText("Kills: "+kills,20,40)
ctx.fillText("Rank: "+rank,20,60)
if(hsFx>0){ctx.fillStyle="rgba(255,0,0,0.4)";ctx.fillRect(0,0,canvas.width,canvas.height);hsFx--}
}
function updateRank(){if(kills>25)rank="Master";else if(kills>15)rank="Diamond";else if(kills>8)rank="Gold"}

/* LOOP */
function loop(){
ctx.clearRect(0,0,canvas.width,canvas.height)
drawMap();movePlayer();drawPlayer();drawEnemies();drawBullets();drawLoot();updateRank();hud()
requestAnimationFrame(loop)
}
loop()
</script>
</body>
</html>
28 changes: 0 additions & 28 deletions docs/plugins.mdx

This file was deleted.