gamee / index.html
Amarefwef's picture
freefire game coding - Initial Deployment
ca90c6a verified
Raw History Blame Contribute Delete
15.4 kB
<!DOCTYPE html>
<html>
<head>
<title>Simple Shooter Game</title>
<style>
canvas {
border: 1px solid black;
background: #222;
}
</style>
</head>
<body>
<canvas id="gameCanvas" width="800" height="600"></canvas>
<script>
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
// Player object
const player = {
x: canvas.width/2,
y: canvas.height-50,
width: 50,
height: 50,
color: 'blue',
speed: 5
};
// Game loop
function gameLoop() {
// Clear canvas
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw player
ctx.fillStyle = player.color;
ctx.fillRect(player.x, player.y, player.width, player.height);
requestAnimationFrame(gameLoop);
}
// Keyboard controls
const keys = {};
window.addEventListener('keydown', (e) => {
keys[e.key] = true;
});
window.addEventListener('keyup', (e) => {
keys[e.key] = false;
});
function handleInput() {
if (keys['ArrowLeft'] && player.x > 0) {
player.x -= player.speed;
}
if (keys['ArrowRight'] && player.x < canvas.width - player.width) {
player.x += player.speed;
}
}
// Start game
function init() {
setInterval(handleInput, 20);
gameLoop();
}
init();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Amarefwef/gamee" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Serene Drives - Relaxing Driving Simulator</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body, html {
margin: 0;
padding: 0;
overflow: hidden;
touch-action: none;
}
canvas {
display: block;
}
.loading-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #1a202c;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 100;
transition: opacity 1s ease-out;
}
.progress-bar {
width: 80%;
max-width: 400px;
height: 20px;
background-color: #2d3748;
border-radius: 10px;
overflow: hidden;
margin-top: 20px;
}
.progress {
height: 100%;
background-color: #4299e1;
width: 0%;
transition: width 0.3s ease;
}
.ui-container {
position: fixed;
bottom: 20px;
left: 0;
width: 100%;
display: flex;
justify-content: center;
z-index: 10;
}
.controls {
background-color: rgba(26, 32, 44, 0.7);
padding: 15px;
border-radius: 20px;
display: flex;
gap: 15px;
}
.control-btn {
width: 60px;
height: 60px;
background-color: rgba(66, 153, 225, 0.8);
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 24px;
user-select: none;
cursor: pointer;
}
.control-btn:active {
transform: scale(0.95);
background-color: rgba(56, 133, 205, 0.8);
}
.menu-btn {
position: fixed;
top: 20px;
right: 20px;
background-color: rgba(26, 32, 44, 0.7);
width: 50px;
height: 50px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 20px;
z-index: 10;
cursor: pointer;
}
.menu {
position: fixed;
top: 0;
right: -300px;
width: 300px;
height: 100%;
background-color: rgba(26, 32, 44, 0.9);
z-index: 20;
transition: right 0.3s ease;
padding: 20px;
color: white;
overflow-y: auto;
}
.menu.open {
right: 0;
}
.close-btn {
position: absolute;
top: 15px;
right: 15px;
font-size: 24px;
cursor: pointer;
}
.settings-option {
margin-bottom: 15px;
}
.settings-option label {
display: block;
margin-bottom: 5px;
}
.speed-display {
position: fixed;
top: 20px;
left: 20px;
background-color: rgba(26, 32, 44, 0.7);
padding: 10px 15px;
border-radius: 20px;
color: white;
font-size: 18px;
z-index: 10;
}
</style>
</head>
<body>
<div class="loading-screen">
<h1 class="text-3xl font-bold text-blue-400 mb-4">Serene Drives</h1>
<p class="text-gray-300 mb-8">Loading relaxing driving experience...</p>
<div class="progress-bar">
<div class="progress"></div>
</div>
</div>
<canvas id="gameCanvas"></canvas>
<div class="speed-display">
Speed: <span id="speedValue">0</span> km/h
</div>
<div class="menu-btn" id="menuBtn">
☰
</div>
<div class="menu" id="menu">
<div class="close-btn" id="closeMenuBtn">×</div>
<h2 class="text-2xl font-bold mb-6 text-blue-400">Settings</h2>
<div class="settings-option">
<label for="landscapeSelect" class="text-gray-300">Landscape</label>
<select id="landscapeSelect" class="w-full bg-gray-800 text-white p-2 rounded">
<option value="countryside">Countryside</option>
<option value="desert">Desert</option>
<option value="forest">Forest</option>
<option value="mountains">Mountains</option>
</select>
</div>
<div class="settings-option">
<label for="timeOfDay" class="text-gray-300">Time of Day</label>
<select id="timeOfDay" class="w-full bg-gray-800 text-white p-2 rounded">
<option value="morning">Morning</option>
<option value="day">Day</option>
<option value="evening">Evening</option>
<option value="night">Night</option>
</select>
</div>
<div class="settings-option">
<label for="vehicleSelect" class="text-gray-300">Vehicle</label>
<select id="vehicleSelect" class="w-full bg-gray-800 text-white p-2 rounded">
<option value="sedan">Sedan</option>
<option value="suv">SUV</option>
<option value="sports">Sports Car</option>
<option value="truck">Truck</option>
</select>
</div>
<div class="settings-option">
<label for="volumeControl" class="text-gray-300">Volume</label>
<input type="range" id="volumeControl" min="0" max="1" step="0.1" value="0.5" class="w-full">
</div>
<button id="resetBtn" class="bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded w-full mt-8">
Reset Vehicle Position
</button>
</div>
<div class="ui-container">
<div class="controls">
<div class="control-btn" id="leftBtn">←</div>
<div class="control-btn" id="brakeBtn">⏸</div>
<div class="control-btn" id="rightBtn">→</div>
</div>
</div>
<script>
// Loading screen
const loadingScreen = document.querySelector('.loading-screen');
const progressBar = document.querySelector('.progress');
// Simulate loading
let progress = 0;
const loadingInterval = setInterval(() => {
progress += Math.random() * 10;
if (progress >= 100) {
progress = 100;
clearInterval(loadingInterval);
setTimeout(() => {
loadingScreen.style.opacity = '0';
setTimeout(() => {
loadingScreen.style.display = 'none';
}, 1000);
}, 500);
}
progressBar.style.width = `${progress}%`;
}, 200);
// Game setup
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Game variables
let carX = canvas.width / 2;
let carY = canvas.height - 100;
let carWidth = 40;
let carHeight = 70;
let carSpeed = 0;
let maxSpeed = 120;
let acceleration = 0.2;
let deceleration = 0.1;
let steering = 0;
let roadWidth = 300;
let roadX = canvas.width / 2 - roadWidth / 2;
let segments = [];
let currentSegment = 0;
let cameraDepth = 0;
let drawDistance = 300;
let skyColor = '#87CEEB';
let roadColor = '#808080';
let grassColor = '#4CAF50';
// Generate road segments
function generateRoad() {
segments = [];
for (let i = 0; i < 1000; i++) {
segments.push({
curve: Math.sin(i / 30) * 2,
y: i * 100,
color: i % 2 ? '#808080' : '#888888'
});
}
}
generateRoad();
// Controls
const leftBtn = document.getElementById('leftBtn');
const rightBtn = document.getElementById('rightBtn');
const brakeBtn = document.getElementById('brakeBtn');
const speedValue = document.getElementById('speedValue');
leftBtn.addEventListener('touchstart', () => steering = -3);
leftBtn.addEventListener('touchend', () => steering = 0);
leftBtn.addEventListener('mousedown', () => steering = -3);
leftBtn.addEventListener('mouseup', () => steering = 0);
leftBtn.addEventListener('mouseleave', () => steering = 0);
rightBtn.addEventListener('touchstart', () => steering = 3);
rightBtn.addEventListener('touchend', () => steering = 0);
rightBtn.addEventListener('mousedown', () => steering = 3);
rightBtn.addEventListener('mouseup', () => steering = 0);
rightBtn.addEventListener('mouseleave', () => steering = 0);
brakeBtn.addEventListener('touchstart', () => {
if (carSpeed > 0) {
deceleration = 0.5;
}
});
brakeBtn.addEventListener('touchend', () => deceleration = 0.1);
brakeBtn.addEventListener('mousedown', () => {
if (carSpeed > 0) {
deceleration = 0.5;
}
});
brakeBtn.addEventListener('mouseup', () => deceleration = 0.1);
brakeBtn.addEventListener('mouseleave', () => deceleration = 0.1);
// Keyboard controls
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft') steering = -3;
if (e.key === 'ArrowRight') steering = 3;
if (e.key === 'ArrowDown') {
if (carSpeed > 0) deceleration = 0.5;
}
if (e.key === 'ArrowUp') acceleration = 0.3;
});
document.addEventListener('keyup', (e) => {
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') steering = 0;
if (e.key === 'ArrowDown') deceleration = 0.1;
if (e.key === 'ArrowUp') acceleration = 0.2;
});
// Menu controls
const menuBtn = document.getElementById('menuBtn');
const closeMenuBtn = document.getElementById('closeMenuBtn');
const menu = document.getElementById('menu');
menuBtn.addEventListener('click', () => {
menu.classList.add('open');
});
closeMenuBtn.addEventListener('click', () => {
menu.classList.remove('open');
});
// Settings
const landscapeSelect = document.getElementById('landscapeSelect');
const timeOfDay = document.getElementById('timeOfDay');
landscapeSelect.addEventListener('change', (e) => {
// Change environment colors based on landscape
switch(e.target.value) {
case 'countryside':
skyColor = '#87CEEB';
grassColor = '#4CAF50';
break;
case 'desert':
skyColor = '#F4A460';
grassColor = '#D2B48C';
break;
case 'forest':
skyColor = '#4682B4';
grassColor = '#2E8B57';
break;
case 'mountains':
skyColor = '#B0C4DE';
grassColor = '#6B8E23';
break;
}
});
timeOfDay.addEventListener('change', (e) => {
// Change lighting based on time of day
switch(e.target.value) {
case 'morning':
skyColor = lightenColor(skyColor, 20);
break;
case 'day':
// Default colors
break;
case 'evening':
skyColor = darkenColor(skyColor, 30);
break;
case 'night':
skyColor = '#191970';
break;
}
});
function lightenColor(color, percent) {
const num = parseInt(color.replace('#', ''), 16);
const amt = Math.round(2.55 * percent);
const R = (num >>
</body>
</html>