Závodní hra
by BraveHero11300 lines6.1 KB
```html
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Závodní hra</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
background: #102010;
font-family: Arial, sans-serif;
overflow: hidden;
user-select: none;
}
#game {
position: relative;
width: 500px;
height: 700px;
margin: 20px auto;
background: #333;
overflow: hidden;
border: 5px solid white;
border-radius: 10px;
}
/* Tráva */
#grass {
position: absolute;
inset: 0;
background:
repeating-linear-gradient(
45deg,
#176b25 0px,
#176b25 10px,
#1b762a 10px,
#1b762a 20px
);
}
/* Silnice */
#road {
position: absolute;
left: 75px;
top: 0;
width: 350px;
height: 100%;
background: #444;
border-left: 7px solid white;
border-right: 7px solid white;
}
/* Čáry na silnici */
.lane-line {
position: absolute;
width: 7px;
height: 70px;
background: white;
z-index: 2;
}
/* Auto */
.car {
position: absolute;
width: 60px;
height: 100px;
border-radius: 12px;
z-index: 5;
box-shadow: 0 4px 8px #000;
}
.player {
background: linear-gradient(
90deg,
#0066ff,
#00aaff,
#0066ff
);
}
.enemy {
background: linear-gradient(
90deg,
#cc0000,
#ff3333,
#cc0000
);
}
/* Okna */
.window {
position: absolute;
left: 10px;
top: 18px;
width: 40px;
height: 27px;
background: #9eeaff;
border: 2px solid #222;
border-radius: 5px;
}
.window2 {
position: absolute;
left: 10px;
top: 55px;
width: 40px;
height: 20px;
background: #9eeaff;
border: 2px solid #222;
border-radius: 5px;
}
/* Kola */
.wheel {
position: absolute;
width: 8px;
height: 25px;
background: #111;
border-radius: 3px;
}
.wheel.left1 { left: -6px; top: 15px; }
.wheel.right1 { right: -6px; top: 15px; }
.wheel.left2 { left: -6px; bottom: 15px; }
.wheel.right2 { right: -6px; bottom: 15px; }
#score {
position: absolute;
left: 15px;
top: 15px;
color: white;
font-size: 24px;
font-weight: bold;
z-index: 20;
text-shadow: 2px 2px 3px black;
}
#speed {
position: absolute;
right: 15px;
top: 15px;
color: yellow;
font-size: 18px;
font-weight: bold;
z-index: 20;
text-shadow: 2px 2px 3px black;
}
#startScreen,
#gameOver {
position: absolute;
inset: 0;
background: rgba(0,0,0,0.82);
color: white;
z-index: 50;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
#gameOver {
display: none;
}
h1 {
font-size: 48px;
color: #00aaff;
margin: 10px;
text-shadow: 3px 3px #003366;
}
h2 {
font-size: 40px;
color: #ff3333;
margin: 10px;
}
button {
padding: 15px 35px;
font-size: 22px;
font-weight: bold;
color: white;
background: #0077ff;
border: none;
border-radius: 10px;
cursor: pointer;
margin-top: 20px;
}
button:hover {
background: #0099ff;
transform: scale(1.05);
}
#controls {
font-size: 18px;
line-height: 1.7;
}
/* Mobilní ovládání */
#mobileControls {
position: fixed;
bottom: 20px;
left: 0;
width: 100%;
display: flex;
justify-content: center;
gap: 40px;
z-index: 100;
}
.controlButton {
width: 90px;
height: 70px;
margin: 0;
padding: 0;
font-size: 35px;
opacity: 0.8;
}
@media (min-width: 700px) {
#mobileControls {
display: none;
}
}
@media (max-width: 550px) {
#game {
width: 100vw;
height: 100vh;
margin: 0;
border: none;
border-radius: 0;
}
#road {
left: 15%;
width: 70%;
}
}
</style>
</head>
<body>
<div id="game">
<div id="grass"></div>
<div id="road"></div>
<div id="score">Skóre: 0</div>
<div id="speed">Rychlost: 1</div>
<!-- Start -->
<div id="startScreen">
<h1>🏎️ ZÁVOD</h1>
<div id="controls">
⬅️ ➡️ nebo A / D<br>
Vyhýbej se ostatním autům!<br>
Čím déle jedeš, tím je hra rychlejší.
</div>
<button onclick="startGame()">START</button>
</div>
<!-- Konec -->
<div id="gameOver">
<h2>💥 HAVÁRIE!</h2>
<div id="finalScore">
Skóre: 0
</div>
<button onclick="restartGame()">HRÁT ZNOVU</button>
</div>
</div>
<!-- Mobilní ovládání -->
<div id="mobileControls">
<button class="controlButton" id="leftButton">⬅️</button>
<button class="controlButton" id="rightButton">➡️</button>
</div>
<script>
const game = document.getElementById("game");
const scoreText = document.getElementById("score");
const speedText = document.getEle
```
Game Source: Závodní hra
Creator: BraveHero11
Libraries: none
Complexity: complex (300 lines, 6.1 KB)
The full source code is displayed above on this page.
Remix Instructions
To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: z-vodn-hra-bravehero11" to link back to the original. Then publish at arcadelab.ai/publish.