<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jogo de Pular Degraus</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="game-container">
<button id="player"></button>
<div id="goal">🎁</div>
<div class="message" id="message">Sonhei com você hoje, acredita?kkkkkk</div>
</div>
<script src="script.js"></script>
</body>
</html>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.game-container {
position: relative;
width: 300px;
height: 600px;
background-color: #fff;
border: 2px solid #000;
}
#player {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 50px;
height: 50px;
background-color: #ff0000;
}
#goal {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
font-size: 2em;
}
.message {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1.5em;
text-align: center;
color: #000;
}
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #ffc0cb; /* Cor de fundo rosa */
}
.game-container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #ffc0cb; /* Cor de fundo rosa */
}
#player {
position: absolute;
width: 50px;
height: 50px;
background-color: red; /* Cor do jogador */
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
#goal {
position: absolute;
width: 80px; /* Tamanho aumentado do presente */
height: 80px; /* Tamanho aumentado do presente */
font-size: 60px;
background-color: pink; /* Cor de fundo rosa */
border-radius: 50%;
top: 10px;
left: 50%;
transform: translateX(-50%);
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.message {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(255, 255, 255, 0.8); /* Fundo da mensagem com transparência */
color: #333; /* Cor do texto */
padding: 10px;
display: none;
text-align: center;
border-radius: 10px;
font-size: 18px;
width: 250px; /* Largura da mensagem */
}
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jogo de Pular Degraus</title>
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #ffc0cb; /* Cor de fundo rosa */
}
.game-container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #ffc0cb;
document.addEventListener('keydown', jump);
function jump(event) {
const player = document.getElementById('player');
const goal = document.getElementById('goal');
const message = document.getElementById('message');
if (event.code === 'Space') {
const currentBottom = parseInt(window.getComputedStyle(player).bottom);
if (currentBottom < 550) {
player.style.bottom = (currentBottom + 50) + 'px';
}
// Check if player reached the goal
if (currentBottom + 50 >= 550) {
message.style.display = 'block';
}
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.