Oto kompletna aplikacja symulująca robota Rumba z surrealistyczną grafiką:
<!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 Odkurzacz AI</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
body {
margin: 0;
padding: 0;
background: linear-gradient(135deg, #0a0a0a 0%, #1a0033 50%, #330066 100%);
font-family: 'Orbitron', monospace;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
overflow: hidden;
}
h1 {
text-align: center;
font-size: 3em;
margin: 20px 0;
text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff;
animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow {
from { text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff; }
to { text-shadow: 0 0 30px #ff00ff, 0 0 60px #ff00ff; }
}
#gameContainer {
position: relative;
border: 3px solid #00ffff;
border-radius: 20px;
box-shadow: 0 0 50px #00ffff, inset 0 0 50px rgba(0, 255, 255, 0.2);
background: rgba(0, 0, 0, 0.8);
}
canvas {
border-radius: 17px;
}
#controls {
margin-top: 30px;
text-align: center;
}
button {
background: linear-gradient(45deg, #ff006e, #8338ec);
border: none;
color: white;
padding: 15px 40px;
font-size: 1.2em;
font-family: 'Orbitron', monospace;
cursor: pointer;
border-radius: 50px;
text-transform: uppercase;
letter-spacing: 2px;
transition: all 0.3s;
box-shadow: 0 5px 20px rgba(255, 0, 110, 0.5);
}
button:hover {
transform: translateY(-3px);
box-shadow: 0 8px 30px rgba(255, 0, 110, 0.8);
}
button:active {
transform: translateY(0);
}
#status {
margin-top: 20px;
font-size: 1.1em;
text-align: center;
color: #00ffff;
text-shadow: 0 0 10px currentColor;
}
.particle {
position: absolute;
width: 4px;
height: 4px;
background: #00ffff;
border-radius: 50%;
pointer-events: none;
}
</style>
</head>
<body>
<h1>RUMBA 2025</h1>
<div id="gameContainer">
<canvas id="gameCanvas" width="800" height="600"></canvas>
</div>
<div id="controls">
<button id="startBtn">START</button>
</div>
<div id="status">System gotowy do inicjalizacji</div>
<script>
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const startBtn = document.getElementById('startBtn');
const status = document.getElementById('status');
let isRunning = false;
let animationId = null;
let cleanedTiles = new Set();
let particles = [];
// Robot Rumba
class Robot {
constructor(x, y) {
this.x = x;
this.y = y;
this.radius = 25;
this.angle = 0;
this.speed = 2;
this.targetAngle = 0;
this.sensors = [];
this.trail = [];
this.maxTrailLength = 50;
this.glow = 0;
this.scanning = false;
}
updateSensors(obstacles) {
this.sensors = [];
const sensorCount = 8;
const sensorRange = 100;
for (let i = 0; i < sensorCount; i++) {
const angle = (i / sensorCount) * Math.PI * 2;
const endX = this.x + Math.cos(angle) * sensorRange;
const endY = this.y + Math.sin(angle) * sensorRange;
let distance = sensorRange;
let detected = false;
// Sprawdź kolizje z przeszkodami
for (let obstacle of obstacles) {
const dist = this.getDistanceToObstacle(angle, obstacle, sensorRange);
if (dist < distance) {
distance = dist;
detected = true;
}
}
// Sprawdź ściany
const wallDist = this.getDistanceToWalls(angle, sensorRange);
if (wallDist < distance) {
distance = wallDist;
detected = true;
}
this.sensors.push({ angle, distance, detected });
}
}
getDistanceToObstacle(angle, obstacle, maxRange) {
const steps = 50;
const stepSize = maxRange / steps;
for (let i = 0; i < steps; i++) {
const dist = i * stepSize;
const checkX = this.x + Math.cos(angle) * dist;
const checkY = this.y + Math.sin(angle) * dist;
if (obstacle.contains(checkX, checkY)) {
return dist;
}
}
return maxRange;
}
getDistanceToWalls(angle, maxRange) {
const dx = Math.cos(angle);
const dy = Math.sin(angle);
let distance = maxRange;
if (dx > 0) distance = Math.min(distance, (canvas.width - this.x - this.radius) / dx);
if (dx < 0) distance = Math.min(distance, (this.x - this.radius) / -dx);
if (dy > 0) distance = Math.min(distance, (canvas.height - this.y - this.radius) / dy);
if (dy < 0) distance = Math.min(distance, (this.y - this.radius) / -dy);
return Math.max(0, distance);
}
makeDecision() {
// AI - wybór najlepszego kierunku
let bestAngle = this.angle;
let maxClearDistance = 0;
for (let sensor of this.sensors) {
if (!sensor.detected || sensor.distance > 60) {
const clearDistance = sensor.distance;
// Preferuj kierunki prowadzące do nieoczyszczonych obszarów
const futureX = this.x + Math.cos(sensor.angle) * 50;
const futureY = this.y + Math.sin(sensor.angle) * 50;
const tileKey = `${Math.floor(futureX/30)},${Math.floor(futureY/30)}`;
const bonus = cleanedTiles.has(tileKey) ? 0 : 50;
const totalScore = clearDistance + bonus;
if (totalScore > maxClearDistance) {
maxClearDistance = totalScore;
bestAngle = sensor.angle;
}
}
}
// Jeśli wszystkie kierunki zablokowane, obróć się
if (maxClearDistance < 30) {
bestAngle = this.angle + Math.PI / 2;
this.scanning = true;
} else {
this.scanning = false;
}
this.targetAngle = bestAngle;
}
move() {
// Płynna zmiana kierunku
const angleDiff = this.targetAngle - this.angle;
const normalizedDiff = ((angleDiff + Math.PI) % (2 * Math.PI)) - Math.PI;
this.angle += normalizedDiff * 0.1;
// Ruch do przodu
const newX = this.x + Math.cos(this.angle) * this.speed;
const newY = this.y + Math.sin(this.angle) * this.speed;
// Sprawdź granice
if (newX - this.radius > 0 && newX + this.radius < canvas.width &&
newY - this.radius > 0 && newY + this.radius < canvas.height) {
this.x = newX;
this.y = newY;
}
// Zapisz ślad
this.trail.push({ x: this.x, y: this.y });
if (this.trail.length > this.maxTrailLength) {
this.trail.shift();
}
// Oznacz oczyszczoną powierzchnię
const tileX = Math.floor(this.x / 30);
const tileY = Math.floor(this.y / 30);
cleanedTiles.add(`${tileX},${tileY}`);
// Aktualizuj efekt świecenia
this.glow = (this.glow + 0.1) % (Math.PI * 2);
}
draw() {
// Rysuj ślad
ctx.strokeStyle = 'rgba(0, 255, 255, 0.3)';
ctx.lineWidth = 2;
ctx.beginPath();
for (let i = 0; i < this.trail.length; i++) {
const point = this.trail[i];
const opacity = i / this.trail.length;
if (i === 0) {
ctx.moveTo(point.x, point.y);
} else {
ctx.lineTo(point.x, point.y);
}
}
ctx.stroke();
// Rysuj sensory
for (let sensor of this.sensors) {
const endX = this.x + Math.cos(sensor.angle) * sensor.distance;
const endY = this.y + Math.sin(sensor.angle) * sensor.distance;
ctx.strokeStyle = sensor.detected ? 'rgba(255, 0, 100, 0.3)' : 'rgba(0, 255, 100, 0.2)';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(this.x, this.y);
ctx.lineTo(endX, endY);
ctx.stroke();
}
// Rysuj robota z efektem świecenia
const glowSize = 5 + Math.sin(this.glow) * 3;
// Zewnętrzna poświata
const gradient = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.radius + glowSize);
gradient.addColorStop(0, 'rgba(255, 0, 255, 0.8)');
gradient.addColorStop(0.5, 'rgba(0, 255, 255, 0.5)');
gradient.addColorStop(1, 'rgba(0, 255, 255, 0)');
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius + glowSize, 0, Math.PI * 2);
ctx.fill();
// Główne ciało robota
ctx.fillStyle = '#000';
ctx.strokeStyle = '#00ffff';
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
// Kierunek
ctx.strokeStyle = '#ff00ff';
ctx.lineWidth = 4;
ctx.beginPath();
ctx.moveTo(this.x, this.y);
ctx.lineTo(
this.x + Math.cos(this.angle) * this.radius,
this.y + Math.sin(this.angle) * this.radius
);
ctx.stroke();
// Symbol AI
ctx.fillStyle = this.scanning ? '#ff0066' : '#00ffff';
ctx.font = 'bold 16px Orbitron';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText('AI', this.x, this.y);
}
}
// Przeszkoda
class Obstacle {
constructor(x, y, width, height, type) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.type = type;
this.rotation = 0;
this.pulse = 0;
}
contains(x, y) {
return x >= this.x && x <= this.x + this.width &&
y >= this.y && y <= this.y + this.height;
}
draw() {
this.pulse += 0.05;
this.rotation += 0.01;
ctx.save();
ctx.translate(this.x + this.width/2, this.y + this.height/2);
if (this.type === 'crystal') {
ctx.rotate(this.rotation);
const scale = 1 + Math.sin(this.pulse) * 0.1;
ctx.scale(scale, scale);
// Kryształ
ctx.fillStyle = 'rgba(138, 56, 236, 0.8)';
ctx.strokeStyle = '#ff00ff';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(0, -this.height/2);
ctx.lineTo(this.width/2, 0);
ctx.lineTo(0, this.height/2);
ctx.lineTo(-this.width/2, 0);
ctx.closePath();
ctx.fill();
ctx.stroke();
} else if (this.type === 'sphere') {
// Kula energetyczna
const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, this.width/2);
gradient.addColorStop(0, 'rgba(255, 0, 110, 0.9)');
gradient.addColorStop(0.5, 'rgba(131, 56, 236, 0.6)');
gradient.addColorStop(1, 'rgba(58, 134, 255, 0.2)');
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(0, 0, this.width/2, 0, Math.PI * 2);
ctx.fill();
// Orbity
ctx.strokeStyle = 'rgba(0, 255, 255, 0.5)';
ctx.lineWidth = 1;
for (let i = 0; i < 3; i++) {
ctx.save();
ctx.rotate(this.rotation * (i + 1));
ctx.scale(1, 0.3);
ctx.beginPath();
ctx.arc(0, 0, this.width/2 + i * 10, 0, Math.PI * 2);
ctx.stroke();
ctx.restore();
}
} else if (this.type === 'portal') {
// Portal
const portalGradient = ctx.createRadialGradient(0, 0, 0, 0, 0, this.width/2);
portalGradient.addColorStop(0, 'rgba(0, 0, 0, 1)');
portalGradient.addColorStop(0.5, 'rgba(138, 56, 236, 0.8)');
portalGradient.addColorStop(1, 'rgba(0, 255, 255, 0.3)');
ctx.fillStyle = portalGradient;
ctx.beginPath();
ctx.arc(0, 0, this.width/2, 0, Math.PI * 2);
ctx.fill();
// Spirala
ctx.strokeStyle = '#00ffff';
ctx.lineWidth = 2;
ctx.beginPath();
for (let t = 0; t < Math.PI * 4; t += 0.1) {
const r = t * 5;
const x = Math.cos(t + this.rotation * 2) * r;
const y = Math.sin(t + this.rotation * 2) * r;
if (r < this.width/2) {
ctx.lineTo(x, y);
}
}
ctx.stroke();
} else {
// Geometryczna struktura
ctx.rotate(this.rotation);
// Zewnętrzna ramka
ctx.strokeStyle = '#00ffff';
ctx.lineWidth = 3;
ctx.strokeRect(-this.width/2, -this.height/2, this.width, this.height);
// Wewnętrzny wzór
ctx.fillStyle = 'rgba(0, 255, 255, 0.2)';
ctx.fillRect(-this.width/2, -this.height/2, this.width, this.height);
// Linie energii
ctx.strokeStyle = 'rgba(255, 0, 255, 0.6)';
ctx.lineWidth = 1;
for (let i = 0; i < 4; i++) {
ctx.beginPath();
ctx.moveTo(-this.width/2 + i * this.width/3, -this.height/2);
ctx.lineTo(-this.width/2 + i * this.width/3, this.height/2);
ctx.stroke();
}
}
ctx.restore();
}
}
// Cząsteczka efektu
class Particle {
constructor(x, y) {
this.x = x;
this.y = y;
this.vx = (Math.random() - 0.5) * 2;
this.vy = (Math.random() - 0.5) * 2;
this.life = 1;
this.decay = 0.02;
this.size = Math.random() * 3 + 1;
}
update() {
this.x += this.vx;
this.y += this.vy;
this.life -= this.decay;
this.vy += 0.05; // grawitacja
}
draw() {
ctx.save();
ctx.globalAlpha = this.life;
ctx.fillStyle = '#00ffff';
ctx.shadowBlur = 10;
ctx.shadowColor = '#00ffff';
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
}
}
// Inicjalizacja
const robot = new Robot(400, 300);
const obstacles = [
new Obstacle(150, 100, 80, 80, 'crystal'),
new Obstacle(600, 150, 60, 60, 'sphere'),
new Obstacle(200, 400, 100, 50, 'portal'),
new Obstacle(500, 350, 70, 90, 'geometric')
];
// Funkcja rysowania tła
function drawBackground() {
// Gradient tła
const bgGradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
bgGradient.addColorStop(0, 'rgba(10, 10, 10, 0.95)');
bgGradient.addColorStop(0.5, 'rgba(26, 0, 51, 0.95)');
bgGradient.addColorStop(1, 'rgba(51, 0, 102, 0.95)');
ctx.fillStyle = bgGradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Siatka
ctx.strokeStyle = 'rgba(0, 255, 255, 0.1)';
ctx.lineWidth = 1;
const gridSize = 30;
for (let x = 0; x < canvas.width; x += gridSize) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, canvas.height);
ctx.stroke();
}
for (let y = 0; y < canvas.height; y += gridSize) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(canvas.width, y);
ctx.stroke();
}
// Oczyszczone obszary
cleanedTiles.forEach(tile => {
const [tileX, tileY] = tile.split(',').map(Number);
ctx.fillStyle = 'rgba(0, 255, 100, 0.1)';
ctx.fillRect(tileX * gridSize, tileY * gridSize, gridSize, gridSize);
});
}
// Główna pętla gry
function gameLoop() {
if (!isRunning) return;
// Czyść ekran i rysuj tło
drawBackground();
// Rysuj przeszkody
obstacles.forEach(obstacle => obstacle.draw());
// Aktualizuj AI robota
robot.updateSensors(obstacles);
robot.makeDecision();
robot.move();
robot.draw();
// Generuj cząsteczki
if (Math.random() < 0.1) {
particles.push(new Particle(robot.x, robot.y));
}
// Aktualizuj i rysuj cząsteczki
particles = particles.filter(particle => {
particle.update();
particle.draw();
return particle.life > 0;
});
// Aktualizuj status
const coverage = (cleanedTiles.size / ((canvas.width/30) * (canvas.height/30)) * 100).toFixed(1);
status.textContent = `Pokrycie: ${coverage}% | Tryb: ${robot.scanning ? 'SKANOWANIE' : 'CZYSZCZENIE'} | Cząsteczki: ${particles.length}`;
animationId = requestAnimationFrame(gameLoop);
}
// Obsługa przycisku start
startBtn.addEventListener('click', () => {
if (!isRunning) {
isRunning = true;
startBtn.textContent = 'STOP';
status.textContent = 'System aktywny - AI uruchomione';
gameLoop();
} else {
isRunning = false;
startBtn.textContent = 'START';
status.textContent = 'System wstrzymany';
if (animationId) {
cancelAnimationFrame(animationId);
}
}
});
// Początkowe rysowanie
drawBackground();
obstacles.forEach(obstacle => obstacle.draw());
robot.draw();
// Efekt cząsteczek w tle
setInterval(() => {
if (!isRunning && Math.random() < 0.3) {
const div = document.createElement('div');
div.className = 'particle';
div.style.left = Math.random() * window.innerWidth + 'px';
div.style.top = Math.random() * window.innerHeight + 'px';
div.style.animation = `float ${3 + Math.random() * 2}s linear`;
document.body.appendChild(div);
setTimeout(() => div.remove(), 5000);
}
}, 500);
// Animacja cząsteczek
const style = document.createElement('style');
style.textContent = `
@keyframes float {
from {
transform: translateY(0) scale(1);
opacity: 1;
}
to {
transform: translateY(-100px) scale(0);
opacity: 0;
}
}
`;
document.head.appendChild(style);
</script>
</body>
</html>
Aplikacja zawiera następujące elementy:
-
Sztuczna inteligencja robota:
- System 8 sensorów wykrywających przeszkody
- Algorytm decyzyjny wybierający najlepszą ścieżkę
- Preferencja nieoczyszczonych obszarów
- Tryb skanowania gdy robot jest zablokowany
-
Surrealistyczna grafika 2025:
- Neonowe kolory i efekty świetlne
- Animowane przeszkody (kryształy, sfery energetyczne, portale)
- Efekty cząsteczkowe i ślady świetlne
- Futurystyczna czcionka Orbitron
- Gradientowe tło z siatką
-
Mechanika gry:
- Robot porusza się prostolinijnie
- Automatyczne omijanie przeszkód
- Wizualizacja oczyszczonych obszarów
- Licznik pokrycia powierzchni
-
Interakcja:
- Przycisk START/STOP do kontroli symulacji
- Wyświetlanie statusu i statystyk
- Płynne animacje 60 FPS
Robot wykorzystuje zaawansowane algorytmy AI do nawigacji, a surrealistyczna oprawa graficzna oddaje futurystyczny charakter roku 2025.