bouncebox-simulator / index.html
SA34764's picture
make me a program, program of a simulation in which we can choose a rectangfle or circle that we can place a tiny ball or square like the dvd player bouncing off but its a ball or a square in a rectangle, square or ball and we can choose in wich direction/angle we are going to throw it and it is going to bounce like the dvd and also make it so that there is an option to see a trail
86134e2 verified
Raw History Blame Contribute Delete
6.65 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BounceBox Simulator</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gradient-to-br from-blue-50 to-purple-50 min-h-screen">
<custom-header></custom-header>
<main class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Controls Panel -->
<div class="bg-white rounded-2xl shadow-xl p-6 lg:col-span-1">
<h2 class="text-2xl font-bold text-gray-800 mb-6 flex items-center">
<i data-feather="sliders" class="mr-3"></i>
Simulation Controls
</h2>
<div class="space-y-6">
<!-- Container Shape -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-3">Container Shape</label>
<div class="grid grid-cols-2 gap-3">
<button id="rectContainer" class="control-btn active">
<i data-feather="square" class="w-5 h-5 mr-2"></i>
Rectangle
</button>
<button id="circleContainer" class="control-btn">
<i data-feather="circle" class="w-5 h-5 mr-2"></i>
Circle
</button>
</div>
</div>
<!-- Object Shape -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-3">Object Shape</label>
<div class="grid grid-cols-2 gap-3">
<button id="ballObject" class="control-btn active">
<i data-feather="circle" class="w-5 h-5 mr-2"></i>
Ball
</button>
<button id="squareObject" class="control-btn">
<i data-feather="square" class="w-5 h-5 mr-2"></i>
Square
</button>
</div>
</div>
<!-- Angle Control -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-3">
Launch Angle: <span id="angleValue">45°</span>
</label>
<input type="range" id="angleControl" min="0" max="360" value="45"
class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer slider">
</div>
<!-- Speed Control -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-3">
Speed: <span id="speedValue">5</span>
</label>
<input type="range" id="speedControl" min="1" max="10" value="5"
class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer slider">
</div>
<!-- Trail Toggle -->
<div class="flex items-center justify-between">
<label class="flex items-center text-sm font-medium text-gray-700">
<i data-feather="wind" class="w-4 h-4 mr-2"></i>
Show Trail
</label>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="trailToggle" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
</label>
</div>
<!-- Action Buttons -->
<div class="grid grid-cols-2 gap-3">
<button id="startBtn" class="btn-primary">
<i data-feather="play" class="w-4 h-4 mr-2"></i>
Start
</button>
<button id="resetBtn" class="btn-secondary">
<i data-feather="refresh-cw" class="w-4 h-4 mr-2"></i>
Reset
</button>
</div>
</div>
</div>
<!-- Simulation Canvas -->
<div class="lg:col-span-2">
<div class="bg-white rounded-2xl shadow-xl p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-2xl font-bold text-gray-800 flex items-center">
<i data-feather="activity" class="mr-3"></i>
Simulation View
</h2>
<div class="text-sm text-gray-600">
<span id="bounceCount">Bounces: 0</span>
</div>
</div>
<div class="relative bg-gray-900 rounded-xl overflow-hidden">
<canvas id="simulationCanvas" class="w-full h-96 bg-gray-900"></canvas>
<div id="instructions" class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-50 text-white text-lg">
Click Start to begin simulation
</div>
</div>
</div>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/header.js"></script>
<script src="components/footer.js"></script>
<script src="script.js"></script>
<script>
feather.replace();
</script>
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
</body>
</html>