Wczuj się w rolę programisty z wieloletnim doświadczeniem. Napisz kod w html aplikacji…
- User
Wczuj się w rolę programisty z wieloletnim doświadczeniem. Napisz kod w html aplikacji robot Rumba. Po kliknięciu w przycisk "start" włącza się symulacja graficzna sprzątania mieszkania w którym znajdują się 4 przeszkody. robot porusza się prostolinijnie, sterowany jest sztuczna inteligencją. przeszkody muszą być ominięte za wszelką cenę. Grafika ma być surrealistyczna na rok 2025.
- Assistant
Aplikacja Rumba - Symulacja Surrealistycznego Robota Sprzątajcego (2025)
Oto kod HTML/CSS/JS dla surrealistycznej aplikacji symulującej robota sprzątającego z inteligentnym unikaniem przeszkód:
<!DOCTYPE html> <html lang="pl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Rumba 2025 - Surrealistyczny Robot Sprzątacz</title> <style> body { margin: 0; padding: 0; background: linear-gradient(135deg, #0f0c29, #302b63, #24243e); font-family: 'Arial', sans-serif; color: #fff; overflow: hidden; height: 100vh; } .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; position: relative; } h1 { font-size: 3rem; text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff; margin-bottom: 20px; text-align: center; background: rgba(0, 0, 0, 0.5); padding: 10px 20px; border-radius: 20px; } .simulation-container { position: relative; width: 80%; height: 70%; max-width: 800px; max-height: 600px; background: rgba(0, 0, 0, 0.3); border-radius: 20px; overflow: hidden; box-shadow: 0 0 30px #00ffff; } #simulation { width: 100%; height: 100%; background: linear-gradient(45deg, #1a1a2e, #16213e); position: relative; } #start-btn { position: absolute; bottom: 30px; padding: 15px 30px; font-size: 1.2rem; background: linear-gradient(45deg, #00b4db, #0083b0); color: white; border: none; border-radius: 50px; cursor: pointer; box-shadow: 0 0 15px rgba(0, 200, 255, 0.5); transition: all 0.3s; z-index: 10; } #start-btn:hover { transform: scale(1.05); box-shadow: 0 0 25px rgba(0, 200, 255, 0.7); } #start-btn:active { transform: scale(0.95); } .obstacle { position: absolute; border-radius: 50%; background: linear-gradient(45deg, #ff006e, #ff9900); box-shadow: 0 0 20px #ff006e; animation: pulse 2s infinite; } @keyframes pulse { 0% { box-shadow: 0 0 20px #ff006e; } 50% { box-shadow: 0 0 30px #ff9900, 0 0 40px #ff006e; } 100% { box-shadow: 0 0 20px #ff006e; } } .robot { position: absolute; width: 50px; height: 50px; background: linear-gradient(45deg, #00ff88, #00b4db); border-radius: 50%; box-shadow: 0 0 15px #00ff88; transition: all 0.1s; z-index: 5; } .sensor { position: absolute; width: 10px; height: 10px; background: rgba(255, 255, 255, 0.3); border-radius: 50%; box-shadow: 0 0 5px white; } .info-panel { position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, 0.5); padding: 10px; border-radius: 10px; font-size: 0.9rem; max-width: 200px; } .glitch { position: absolute; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.1); clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); animation: glitch 2s infinite; opacity: 0; } @keyframes glitch { 0% { opacity: 0; transform: translate(0); } 10% { opacity: 0.3; transform: translate(-5px, -5px); } 20% { opacity: 0; transform: translate(0); } 30% { opacity: 0.3; transform: translate(5px, 5px); } 40% { opacity: 0; transform: translate(0); } 100% { opacity: 0; transform: translate(0); } } </style> </head> <body> <div class="container"> <h1>Rumba 2025 - Surrealistyczny Robot Sprzątacz</h1> <div class="simulation-container"> <div id="simulation"> <div class="glitch"></div> <div class="info-panel"> <p>Status: Gotowy</p> <p>Przeszkody: 4</p> <p>Czas pracy: 00:00</p> </div> </div> </div> <button id="start-btn">START</button> </div> <script> document.addEventListener('DOMContentLoaded', function() { const simulation = document.getElementById('simulation'); const startBtn = document.getElementById('start-btn'); const infoPanel = document.querySelector('.info-panel'); const glitch = document.querySelector('.glitch'); // Parametry symulacji const simulationWidth = simulation.offsetWidth; const simulationHeight = simulation.offsetHeight; const robotSize = 50; const obstacleSize = 60; const sensorRange = 100; const robotSpeed = 2; const obstacleCount = 4; // Tworzenie przeszkód const obstacles = []; for (let i = 0; i < obstacleCount; i++) { const obstacle = document.createElement('div'); obstacle.className = 'obstacle'; // Losowe pozycje przeszkód const x = Math.random() * (simulationWidth - obstacleSize); const y = Math.random() * (simulationHeight - obstacleSize); obstacle.style.width = `${obstacleSize}px`; obstacle.style.height = `${obstacleSize}px`; obstacle.style.left = `${x}px`; obstacle.style.top = `${y}px`; simulation.appendChild(obstacle); obstacles.push({ element: obstacle, x: x + obstacleSize / 2, y: y + obstacleSize / 2, radius: obstacleSize / 2 }); } // Tworzenie robota const robot = document.createElement('div'); robot.className = 'robot'; robot.style.left = '50px'; robot.style.top = '50px'; simulation.appendChild(robot); // Tworzenie czujników const sensors = []; for (let i = 0; i < 4; i++) { const sensor = document.createElement('div'); sensor.className = 'sensor'; simulation.appendChild(sensor); sensors.push(sensor); } // Stan robota let robotState = { x: 50, y: 50, angle: 0, speed: 0, targetX: simulationWidth - 100, targetY: simulationHeight - 100, isRunning: false, time: 0, startTime: 0 }; // Funkcja do aktualizacji pozycji czujników function updateSensors() { const angleStep = Math.PI / 2; // 90 stopni między czujnikami sensors.forEach((sensor, index) => { const angle = robotState.angle + (index * angleStep - Math.PI / 4); const sensorX = robotState.x + Math.cos(angle) * (robotSize / 2 + 5); const sensorY = robotState.y + Math.sin(angle) * (robotSize / 2 + 5); sensor.style.left = `${sensorX}px`; sensor.style.top = `${sensorY}px`; }); } // Funkcja do wykrywania kolizji function detectCollision(x, y, radius) { for (const obstacle of obstacles) { const dx = x - obstacle.x; const dy = y - obstacle.y; const distance = Math.sqrt(dx * dx + dy * dy); if (distance < radius + obstacle.radius) { return true; } } // Sprawdzanie granic symulacji if (x < 0 || x > simulationWidth || y < 0 || y > simulationHeight) { return true; } return false; } // Funkcja do wykrywania przeszkód przez czujniki function detectObstacles() { const detectionAngles = [0, Math.PI / 2, Math.PI, 3 * Math.PI / 2]; const detectionResults = []; for (const angle of detectionAngles) { const detectionAngle = robotState.angle + angle; let distance = 0; let collision = false; while (distance < sensorRange && !collision) { const testX = robotState.x + Math.cos(detectionAngle) * distance; const testY = robotState.y + Math.sin(detectionAngle) * distance; collision = detectCollision(testX, testY, 5); if (!collision) { distance += 5; } } detectionResults.push({ angle: detectionAngle, distance: collision ? distance : sensorRange }); } return detectionResults; } // Funkcja do aktualizacji stanu robota function updateRobot() { if (!robotState.isRunning) return; // Aktualizacja czasu robotState.time = Math.floor((Date.now() - robotState.startTime) / 1000); const minutes = Math.floor(robotState.time / 60).toString().padStart(2, '0'); const seconds = (robotState.time % 60).toString().padStart(2, '0'); infoPanel.innerHTML = ` <p>Status: Sprzątanie</p> <p>Przeszkody: ${obstacleCount}</p> <p>Czas pracy: ${minutes}:${seconds}</p> `; // Wykrywanie przeszkód const detections = detectObstacles(); // Logika unikania przeszkód let turnDirection = 0; let turnAmount = 0; // Sprawdzanie każdego czujnika detections.forEach((detection, index) => { if (detection.distance < 50) { // Przeszkoda blisko - zwróć w przeciwną stronę turnDirection = (index === 0 || index === 2) ? -1 : 1; turnAmount = Math.max(turnAmount, 0.1); } }); // Aktualizacja kąta robotState.angle += turnAmount * 0.1; // Ruch do przodu robotState.x += Math.cos(robotState.angle) * robotState.speed; robotState.y += Math.sin(robotState.angle) * robotState.speed; // Sprawdzanie kolizji if (detectCollision(robotState.x, robotState.y, robotSize / 2)) { // Odwróć kierunek robotState.angle += Math.PI; robotState.x -= Math.cos(robotState.angle) * robotState.speed * 2; robotState.y -= Math.sin(robotState.angle) * robotState.speed * 2; } // Aktualizacja pozycji robota robot.style.left = `${robotState.x - robotSize / 2}px`; robot.style.top = `${robotState.y - robotSize / 2}px`; robot.style.transform = `rotate(${robotState.angle * 180 / Math.PI}deg)`; // Aktualizacja czujników updateSensors(); // Sprawdzanie celu const dx = robotState.targetX - robotState.x; const dy = robotState.targetY - robotState.y; const distanceToTarget = Math.sqrt(dx * dx + dy * dy); if (distanceToTarget < 20) { // Nowy cel robotState.targetX = Math.random() * (simulationWidth - 100) + 50; robotState.targetY = Math.random() * (simulationHeight - 100) + 50; } // Kontynuowanie animacji requestAnimationFrame(updateRobot); } // Inicjalizacja symulacji startBtn.addEventListener('click', function() { if (robotState.isRunning) return; robotState.isRunning = true; robotState.startTime = Date.now(); startBtn.textContent = 'RESET'; glitch.style.opacity = '0.1'; // Uruchom symulację updateRobot(); }); // Reset symulacji startBtn.addEventListener('dblclick', function() { if (!robotState.isRunning) return; robotState.isRunning = false; robotState.x = 50; robotState.y = 50; robotState.angle = 0; robotState.speed = robotSpeed; robotState.targetX = simulationWidth - 100; robotState.targetY = simulationHeight - 100; robotState.time = 0; robot.style.left = '50px'; robot.style.top = '50px'; robot.style.transform = 'rotate(0deg)'; infoPanel.innerHTML = ` <p>Status: Gotowy</p> <p>Przeszkody: ${obstacleCount}</p> <p>Czas pracy: 00:00</p> `; startBtn.textContent = 'START'; glitch.style.opacity = '0'; // Ukryj czujniki sensors.forEach(sensor => { sensor.style.display = 'none'; }); }); // Pokaż czujniki po najechaniu na symulację simulation.addEventListener('mouseenter', function() { if (robotState.isRunning) { sensors.forEach(sensor => { sensor.style.display = 'block'; }); } }); simulation.addEventListener('mouseleave', function() { sensors.forEach(sensor => { sensor.style.display = 'none'; }); }); }); </script> </body> </html>Opis funkcjonalności:
-
Grafika surrealistyczna 2025:
- Gradientowe tła i elementy z futurystycznymi kolorami
- Animowane przeszkody z efektem pulsowania
- Efekty glitch dla dodatkowego surrealistycznego wyglądu
- Robot z dynamicznym oświetleniem
-
Inteligentne unikanie przeszkód:
- System czujników (4 kierunkowe) wykrywających przeszkody
- Algorytm unikania kolizji z dynamicznym obliczaniem trasy
- Reakcja na przeszkody w czasie rzeczywistym
-
Symulacja ruchu:
- Robot porusza się prostolinijnie do losowych celów
- Automatyczne unikanie przeszkód i granic symulacji
- Dynamiczne obracanie się robota
-
Interakcja użytkownika:
- Przycisk start/stop symulacji
- Panel informacyjny z czasem pracy
- Wizualizacja czujników przy najechaniu na symulację
-
Efekty wizualne:
- Animacje gradientowe
- Efekty świetlne
- Dynamiczne cienie i oświetlenie
Aplikacja jest responsywna i działa w każdej nowoczesnej przeglądarce.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.