Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Eliminator game extension added #2143

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
35 changes: 35 additions & 0 deletions Bug Eliminator/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="pt-BR">

<head>
<title></title>
<meta charset="UTF-8">
<link rel="stylesheet" href="estilo.css" />
<script src="jogo.js"></script>
</head>

<body onresize="ajustaTamanhoPalcoJogo()">
<div class="painel">
<div class="vidas">
<img id="v1" src="img/coracao_cheio.png" />
<img id="v2" src="img/coracao_cheio.png" />
<img id="v3" src="img/coracao_cheio.png" />

</div>

<div class="cronometro">Start: <span id="cronometro"></span></div>

</div>

<script>
document.getElementById('cronometro').innerHTML = tempo

let criaMosquito = setInterval(function() {
posicaoRandomica()

}, criaMosquitoTempo)
</script>

</body>

</html>
64 changes: 64 additions & 0 deletions Bug Eliminator/estilo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@charset "UTF-8";


html {
cursor: url(img/mata_mosquito.png) 30 30, auto;
}

body {
background-image: url(img/bg.jpg);
background-repeat: no-repeat;
}




.mosquito1 {
width: 50px;
height: 50px;
}

.mosquito2 {
width: 70px;
height: 70px;
}

.mosquito3 {
width: 90px;
height: 90px;
}




.ladoA {
transform: scaleX(1);
}

.ladoB {
transform: scaleX(-1);
}




.painel {
position: absolute;
width: 190px;
padding: 10px;
left: 0px;
bottom: 0px;
border-top: solid 1px white;
background-color: white;
opacity: 0.7;
}

.vidas {
float: left;
}

.cronometro {
float: left;
font-size: 20px;
font-weight: bold;
}
35 changes: 35 additions & 0 deletions Bug Eliminator/fim_de_jogo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="pt-BR">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link rel="stylesheet" href="estilo.css" />
<title>Document</title>
</head>

<body>
<div class="container">
<div class="row">
<div class="col">
<div class="d-flex justify-content-center">
<img src="img/game_over.png" />
</div>
</div>
</div>

<div class="row">
<div class="col">
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-dark btn-lg" onclick="window.location.href = 'index.html' ">Replay</button>
</div>
</div>
</div>
</div>

</body>

</html>
Binary file added Bug Eliminator/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bug Eliminator/img/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bug Eliminator/img/coracao_cheio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bug Eliminator/img/coracao_vazio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bug Eliminator/img/game_over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bug Eliminator/img/mata_mosquito.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bug Eliminator/img/mosca.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions Bug Eliminator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

<!DOCTYPE html>
<html lang="pt-BR">

<head>
<title>Document</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link rel="stylesheet" href="estilo.css" />
<script>
function iniciarJogo() {
let nivel = document.getElementById('nivel').value

if (nivel === '') {
alert('Selecione um nível valido.')
return false
}

window.location.href = "app.html?" + nivel
}
</script>
</head>

<body>
<div class="container">
<div class="row">
<div class="col">
<div class="d-flex justify-content-center">
<img src="img/game.png" />
</div>
</div>
</div>

<div class="row">
<div class="col">
<div class="d-flex justify-content-center">
<div class="mb-2">
<select class="form-control" id="nivel">
<option value="">---Select level---</option>
<option value="normal">Beginner</option>
<option value="dificil">Intermediate</option>
<option value="extremo">Hard</option>
<option value="insano">Extreme</option>
</select>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col">
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-danger btn-lg" onclick="iniciarJogo()">Play Game</button>
</div>
</div>
</div>
</div>

</body>

</html>
126 changes: 126 additions & 0 deletions Bug Eliminator/jogo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
let largura = 0
let altura = 0
let vidas = 1
let tempo = 30

let criaMosquitoTempo = 2000

let nivel = window.location.search
nivel = nivel.replace('?', '')

if (nivel === 'normal') {


criaMosquitoTempo = 2000

} else if (nivel === 'dificil') {


criaMosquitoTempo = 1500

} else if (nivel === 'extremo') {


criaMosquitoTempo = 1000

} else if (nivel === 'insano') {


criaMosquitoTempo = 750

}

function ajustaTamanhoPalcoJogo() {
altura = window.innerHeight
largura = window.innerWidth

console.log(largura, altura)
}

ajustaTamanhoPalcoJogo()

let cronometro = setInterval(function() {

tempo -= 1

if (tempo < 0) {
clearInterval(cronometro)
clearInterval(criaMosquito)
window.location.href = 'vitoria.html'
} else {
document.getElementById('cronometro').innerHTML = tempo
}

}, 1000)

function posicaoRandomica() {


if (document.getElementById('mosquito')) {
document.getElementById('mosquito').remove()


if (vidas > 3) {

window.location.href = 'fim_de_jogo.html'
} else {
document.getElementById('v' + vidas).src = "img/coracao_vazio.png"

vidas++

}
}


let posicaoX = Math.floor(Math.random() * largura) - 90
let posicaoY = Math.floor(Math.random() * altura) - 90


posicaoX = posicaoX < 0 ? 0 : posicaoX
posicaoY = posicaoY < 0 ? 0 : posicaoY

console.log(posicaoX, posicaoY)

let mosquito = document.createElement('img')
mosquito.src = 'img/mosca.png'
mosquito.className = tamanhoAleatorio() + ' ' + ladoAleatorio() //Espaço em branco na concatenação para não haver problema na chamada.
mosquito.style.left = posicaoX + 'px'
mosquito.style.top = posicaoY + 'px'
mosquito.style.position = 'absolute'
mosquito.id = 'mosquito'
mosquito.onclick = function() {
this.remove()
}

document.body.appendChild(mosquito)

}


function tamanhoAleatorio() {
let classe = Math.floor(Math.random() * 3)

switch (classe) {
case 0:
return 'mosquito1'

case 1:
return 'mosquito2'

case 2:
return 'mosquito3'
}
}

function ladoAleatorio() {
let classe = Math.floor(Math.random() * 3)

switch (classe) {
case 0:
return 'ladoA'

case 1:
return 'ladoB'

}
}
30 changes: 30 additions & 0 deletions Bug Eliminator/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"manifest_version": 3,
"name": "Bug Eliminator",
"version": "1.0",
"description": "Bug Eliminator",
"icons": {
"48": "icon.png",
"64": "icon.png",
"128": "icon.png"
},
"permissions": [
"storage"
],
"optional-permissions": [
"tabs"
],
"action": {
"default_popup": "index.html"
},
"web_accessible_resources": [
{
"resources": [
"index.html"
],
"matches": [
"<all_urls>"
]
}
]
}
Loading
Loading