Skip to content

Commit cd46539

Browse files
George, Anoop (CT RDA DS AA DF WINCC FH SCADA-DH2)George, Anoop (CT RDA DS AA DF WINCC FH SCADA-DH2)
authored andcommitted
Final score functionality addition and Image file addition in assets folder for Enhancement, fixes #5218
1 parent ac4ce20 commit cd46539

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

Games/Anime_Clicker/fim_de_jogo.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,37 @@
99
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
1010
<link rel="stylesheet" href="estilo.css" />
1111
<title>Document</title>
12+
<style>
13+
.score-display {
14+
position: fixed;
15+
top: 20px;
16+
left: 45%;
17+
transform: translateX(-50%);
18+
font-size: 24px;
19+
font-weight: bold;
20+
background-color: rgba(0, 0, 0, 0.7);
21+
color: white;
22+
padding: 15px 25px;
23+
border-radius: 8px;
24+
z-index: 1000;
25+
}
26+
</style>
27+
<script>
28+
function getScoreFromURL() {
29+
let params = new URLSearchParams(window.location.search)
30+
let sucessos = params.get('sucessos') || 0
31+
let tentativas = params.get('tentativas') || 0
32+
33+
document.getElementById('score').innerHTML = 'Final score = ' + sucessos + '/' + tentativas
34+
}
35+
36+
window.onload = getScoreFromURL
37+
</script>
1238
</head>
1339

1440
<body>
41+
<div class="score-display" id="score">Final score = 0/0</div>
42+
1543
<div class="container">
1644
<div class="row">
1745
<div class="col">
1.21 MB
Loading

Games/Anime_Clicker/jogo.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ let largura = 0
22
let altura = 0
33
let vidas = 1
44
let tempo = 30
5+
let sucessos = 0
6+
let totalTentativas = 0
57

68
let criaMosquitoTempo = 2000
79

@@ -47,7 +49,7 @@ let cronometro = setInterval(function() {
4749
if (tempo < 0) {
4850
clearInterval(cronometro)
4951
clearInterval(criaMosquito)
50-
window.location.href = 'vitoria.html'
52+
window.location.href = 'vitoria.html?sucessos=' + sucessos + '&tentativas=' + totalTentativas
5153
} else {
5254
document.getElementById('cronometro').innerHTML = tempo
5355
}
@@ -59,11 +61,12 @@ function posicaoRandomica() {
5961
//Remover mosquito anterior (caso exista).
6062
if (document.getElementById('mosquito')) {
6163
document.getElementById('mosquito').remove()
64+
totalTentativas++
6265

6366
//console.log('elemento selecionado foi: v' + vidas)
6467
if (vidas > 3) {
6568

66-
window.location.href = 'fim_de_jogo.html'
69+
window.location.href = 'fim_de_jogo.html?sucessos=' + sucessos + '&tentativas=' + totalTentativas
6770
} else {
6871
document.getElementById('v' + vidas).src = "img/coracao_vazio.png"
6972

@@ -81,7 +84,6 @@ function posicaoRandomica() {
8184
posicaoY = posicaoY < 0 ? 0 : posicaoY
8285

8386
console.log(posicaoX, posicaoY)
84-
8587
//Criando o elemento "mosquito" no HTML
8688
let mosquito = document.createElement('img')
8789
mosquito.src = 'img/mosca.png'
@@ -91,10 +93,13 @@ function posicaoRandomica() {
9193
mosquito.style.position = 'absolute'
9294
mosquito.id = 'mosquito'
9395
mosquito.onclick = function() {
96+
sucessos++
97+
totalTentativas++
9498
this.remove()
9599
}
96100

97101
document.body.appendChild(mosquito)
102+
document.body.appendChild(mosquito)
98103

99104
}
100105

Games/Anime_Clicker/vitoria.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,37 @@
99
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
1010
<link rel="stylesheet" href="estilo.css" />
1111
<title>Document</title>
12+
<style>
13+
.score-display {
14+
position: fixed;
15+
top: 20px;
16+
left: 45%;
17+
transform: translateX(-50%);
18+
font-size: 24px;
19+
font-weight: bold;
20+
background-color: rgba(0, 0, 0, 0.7);
21+
color: white;
22+
padding: 15px 25px;
23+
border-radius: 8px;
24+
z-index: 1000;
25+
}
26+
</style>
27+
<script>
28+
function getScoreFromURL() {
29+
let params = new URLSearchParams(window.location.search)
30+
let sucessos = params.get('sucessos') || 0
31+
let tentativas = params.get('tentativas') || 0
32+
33+
document.getElementById('score').innerHTML = 'Final score = ' + sucessos + '/' + tentativas
34+
}
35+
36+
window.onload = getScoreFromURL
37+
</script>
1238
</head>
1339

1440
<body>
41+
<div class="score-display" id="score">Final score = 0/0</div>
42+
1543
<div class="container">
1644
<div class="row">
1745
<div class="col">

0 commit comments

Comments
 (0)