fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }
Success #stdin #stdout 0.07s 54532KB
stdin
‎<!DOCTYPE html>
‎<html>
‎<head>
‎    <title>Desi Drive: India Explorer 🚗🇮🇳</title>
‎    <style>body{margin:0;background:#000;overflow:hidden;}canvas{border:2px solid #ffd700;}</style>
‎</head>
‎<body>
‎    <canvas id="canvas" width="800" height="600"></canvas>
‎    <script>
‎        const canvas = document.getElementById('canvas');
‎        const ctx = canvas.getContext('2d');
‎        const worldW = 10000;
‎        const worldH = 10000;
‎
‎        // Player/Car
‎        const player = {
‎            x: 5000, y: 7500, vx: 0, vy: 0, angle: 0,
‎            accel: 0.3, friction: 0.95, maxSpeed: 8,
‎            zoom: 1, carType: 0, score: 0
‎        };
‎
‎        // Camera
‎        let camX = 0, camY = 0, camOffsetX = 0, camOffsetY = 0;
‎
‎        // Input
‎        const keys = {};
‎        let mouseDown = false, prevMX = 0, prevMY = 0;
‎        let joystick = {active: false, sx: 0, sy: 0, dx: 0, dy: 0};
‎        let panning = false, panSX = 0, panSY = 0;
‎
‎        // Levels - Add more easy!
‎        const levels = [
‎            {
‎                name: 'Level 1: Udaipur 🏔️',
‎                bgColor: '#e8d5b7', // Sandy
‎                landmarks: [
‎                    {name: 'Pichola Lake', x: 4500, y: 4500, w: 1500, h: 1000, color: '#4a90e2'},
‎                    {name: 'City Palace', x: 4800, y: 4300, w: 400, h: 500, color: '#d4af37'},
‎                    {name: 'Jagdish Temple', x: 4200, y: 4600, w: 200, h: 200, color: '#8b4513'}
‎                ],
‎                roads: [
‎                    // Border & main roads
‎                    {x1:1500, y1:1500, x2:8500, y2:1500}, {x1:1500, y1:1500, x2:1500, y2:8500},
‎                    {x1:8500, y1:1500, x2:8500, y2:8500}, {x1:1500, y1:8500, x2:8500, y2:8500},
‎                    // City grid around lake
‎                    {x1:3000, y1:3000, x2:6000, y2:3000}, {x1:6000, y1:3000, x2:6000, y2:6000},
‎                    {x1:6000, y1:6000, x2:3000, y2:6000}, {x1:3000, y1:6000, x2:3000, y2:3000},
‎                    // Spokes to landmarks
‎                    {x1:4500, y1:2000, x2:4500, y2:4000}, {x1:2000, y1:4500, x2:3500, y2:4500},
‎                    {x1:6500, y1:4500, x2:8000, y2:4500}
‎                ]
‎            },
‎            {
‎                name: 'Level 2: Jodhpur 🏰',
‎                bgColor: '#d2b48c', // Desert
‎                landmarks: [
‎                    {name: 'Mehrangarh Fort', x: 2500, y: 2500, w: 800, h: 1000, color: '#a0522d'},
‎                    {name: 'Umaid Bhawan Palace', x: 4500, y: 3500, w: 500, h: 400, color: '#ffd700'},
‎                    {name: 'Clock Tower', x: 5500, y: 4500, w: 150, h: 150, color: '#ff4500'}
‎                ],
‎                roads: [
‎                    // Border
‎                    {x1:1500, y1:1500, x2:8500, y2:1500}, {x1:1500, y1:1500, x2:1500, y2:8500},
‎                    {x1:8500, y1:1500, x2:8500, y2:8500}, {x1:1500, y1:8500, x2:8500, y2:8500},
‎                    // Fort roads
‎                    {x1:2000, y1:2000, x2:5000, y2:2000}, {x1:2000, y1:2000, x2:2000, y2:5000},
‎                    {x1:5000, y1:2000, x2:5000, y2:5000},
‎                    // City
‎                    {x1:3000, y1:4000, x2:7000, y2:4000}, {x1:5000, y1:3000, x2:5000, y2:7000}
‎                ]
‎            }
‎        ];
‎        let currentLevel = 0;
‎
‎        // Events
‎        window.addEventListener('keydown', (e) => { keys[e.code] = true; });
‎        window.addEventListener('keyup', (e) => { keys[e.code] = false; });
‎
‎        canvas.addEventListener('mousedown', (e) => {
‎            mouseDown = true;
‎            prevMX = e.offsetX;
‎            prevMY = e.offsetY;
‎        });
‎        canvas.addEventListener('mousemove', (e) => {
‎            if (mouseDown) {
‎                const dx = (e.offsetX - prevMX) / player.zoom;
‎                const dy = (e.offsetY - prevMY) / player.zoom;
‎                camOffsetX += dx;
‎                camOffsetY += dy;
‎            }
‎            prevMX = e.offsetX;
‎            prevMY = e.offsetY;
‎        });
‎        canvas.addEventListener('mouseup', () => { mouseDown = false; });
‎        canvas.addEventListener('wheel', (e) => {
‎            e.preventDefault();
‎            player.zoom *= e.deltaY > 0 ? 0.9 : 1.1;
‎            player.zoom = Math.max(0.1, Math.min(5, player.zoom));
‎        });
‎
‎        // Touch Mobile
‎        canvas.addEventListener('touchstart', (e) => {
‎            e.preventDefault();
‎            const rect = canvas.getBoundingClientRect();
‎            const tx = (e.touches[0].clientX - rect.left) / rect.width * canvas.width;
‎            const ty = (e.touches[0].clientY - rect.top) / rect.height * canvas.height;
‎            if (tx < canvas.width / 2) {
‎                // Left: Joystick drive
‎                joystick.active = true;
‎                joystick.sx = tx;
‎                joystick.sy = ty;
‎            } else {
‎                // Right: Pan
‎                panning = true;
‎                panSX = tx;
‎                panSY = ty;
‎            }
‎        });
‎        canvas.addEventListener('touchmove', (e) => {
‎            e.preventDefault();
‎            const rect = canvas.getBoundingClientRect();
‎            const tx = (e.touches[0].clientX - rect.left) / rect.width * canvas.width;
‎            const ty = (e.touches[0].clientY - rect.top) / rect.height * canvas.height;
‎            if (joystick.active) {
‎                joystick.dx = (tx - joystick.sx) / canvas.width * 20;
‎                joystick.dy = (ty - joystick.sy) / canvas.height * 20;
‎            } else if (panning) {
‎                const dx = (tx - panSX) / player.zoom;
‎                const dy = (ty - panSY) / player.zoom;
‎                camOffsetX += dx;
‎                camOffsetY += dy;
‎                panSX = tx;
‎                panSY = ty;
‎            }
‎        });
‎        canvas.addEventListener('touchend', (e) => {
‎            e.preventDefault();
‎            joystick.active = false;
‎            panning = false;
‎        });
‎
‎        function update() {
‎            // Drive Input
‎            if (keys['ArrowLeft'] || keys['KeyA']) player.angle -= 0.08;
‎            if (keys['ArrowRight'] || keys['KeyD']) player.angle += 0.08;
‎            if (keys['ArrowUp'] || keys['KeyW']) {
‎                player.vx += Math.cos(player.angle) * player.accel;
‎                player.vy += Math.sin(player.angle) * player.accel;
‎            }
‎            if (keys['ArrowDown'] || keys['KeyS']) {
‎                player.vx -= Math.cos(player.angle) * player.accel * 0.5;
‎                player.vy -= Math.sin(player.angle) * player.accel * 0.5;
‎            }
‎            // Touch joystick
‎            if (joystick.active) {
‎                player.angle += joystick.dx * 0.1;
‎                if (joystick.dy < 0) {
‎                    player.vx += Math.cos(player.angle) * player.accel;
‎                    player.vy += Math.sin(player.angle) * player.accel;
‎                }
‎                if (joystick.dy > 0) {
‎                    player.vx -= Math.cos(player.angle) * player.accel * 0.3;
‎                    player.vy -= Math.sin(player.angle) * player.accel * 0.3;
‎                }
‎            }
‎            // Physics
‎            const speed = Math.sqrt(player.vx * player.vx + player.vy * player.vy);
‎            if (speed > player.maxSpeed) {
‎                player.vx = (player.vx / speed) * player.maxSpeed;
‎                player.vy = (player.vy / speed) * player.maxSpeed;
‎            }
‎            player.vx *= player.friction;
‎            player.vy *= player.friction;
‎            player.x += player.vx;
‎            player.y += player.vy;
‎            // Bounds
‎            player.x = Math.max(50, Math.min(worldW - 50, player.x));
‎            player.y = Math.max(50, Math.min(worldH - 50, player.y));
‎
‎            // Collision & Visit Landmarks
‎            const lm = levels[currentLevel].landmarks;
‎            for (let i = 0; i < lm.length; i++) {
‎                const l = lm[i];
‎                const dx = player.x - l.x;
‎                const dy = player.y - l.y;
‎                if (Math.abs(dx) < l.w / 2 + 50 && Math.abs(dy) < l.h / 2 + 50) {
‎                    // Bounce
‎                    const bounceAngle = Math.atan2(dy, dx);
‎                    player.vx = Math.cos(bounceAngle) * 3;
‎                    player.vy = Math.sin(bounceAngle) * 3;
‎                    // Visit!
‎                    player.score += 100;
‎                    alert(`🏆 Visited ${l.name}! Score: ${player.score} 🔥`);
‎                }
‎            }
‎
‎            // Level switch
‎            if (keys['Digit1']) { currentLevel = 0; player.x = 5000; player.y = 7500; }
‎            if (keys['Digit2']) { currentLevel = 1; player.x = 5000; player.y = 7500; }
‎            if (keys['KeyC']) { player.carType = (player.carType + 1) % 3; }
‎            // Zoom
‎            if (keys['Equal'] || keys['NumpadAdd']) player.zoom *= 1.1;
‎            if (keys['Minus'] || keys['NumpadSubtract']) player.zoom *= 0.9;
‎            player.zoom = Math.max(0.2, Math.min(4, player.zoom));
‎
‎            // Camera follow + offset
‎            camX = player.x - canvas.width / 2 / player.zoom + camOffsetX;
‎            camY = player.y - canvas.height / 2 / player.zoom + camOffsetY;
‎        }
‎
‎        function draw() {
‎            ctx.save();
‎            ctx.scale(player.zoom, player.zoom);
‎            ctx.translate(-camX, -camY);
‎
‎            // World BG
‎            ctx.fillStyle = levels[currentLevel].bgColor;
‎            ctx.fillRect(0, 0, worldW, worldH);
‎
‎            // Roads (thick lines)
‎            ctx.strokeStyle = '#666';
‎            ctx.lineWidth = 80 / player.zoom;
‎            ctx.lineCap = 'round';
‎            const roads = levels[currentLevel].roads;
‎            for (let r of roads) {
‎                ctx.beginPath();
‎                ctx.moveTo(r.x1, r.y1);
‎                ctx.lineTo(r.x2, r.y2);
‎                ctx.stroke();
‎            }
‎
‎            // Landmarks
‎            const lm = levels[currentLevel].landmarks;
‎            for (let l of lm) {
‎                ctx.fillStyle = l.color;
‎                ctx.shadowColor = 'rgba(0,0,0,0.3)';
‎                ctx.shadowBlur = 20 / player.zoom;
‎                ctx.fillRect(l.x - l.w / 2, l.y - l.h / 2, l.w, l.h);
‎                ctx.shadowBlur = 0;
‎                ctx.strokeStyle = '#000';
‎                ctx.lineWidth = 4 / player.zoom;
‎                ctx.strokeRect(l.x - l.w / 2, l.y - l.h / 2, l.w, l.h);
‎                // Name
‎                ctx.fillStyle = 'white';
‎                ctx.font = `bold ${40 / player.zoom}px Arial`;
‎                ctx.textAlign = 'center';
‎                ctx.textBaseline = 'middle';
‎                ctx.fillText(l.name, l.x, l.y - l.h / 2 - 30 / player.zoom);
‎            }
‎
‎            // Car (Luxury shapes)
‎            ctx.save();
‎            ctx.translate(player.x, player.y);
‎            ctx.rotate(player.angle);
‎            const carColors = ['#ff0000', '#0000ff', '#800080']; // Red Merc, Blue BMW, Purple Audi
‎            ctx.fillStyle = carColors[player.carType];
‎            ctx.shadowColor = 'rgba(0,0,0,0.5)';
‎            ctx.shadowBlur = 15 / player.zoom;
‎            // Body (luxury coupe shape)
‎            ctx.beginPath();
‎            ctx.moveTo(-45, -20);
‎            ctx.lineTo(50, -20);
‎            ctx.lineTo(50, 15);
‎            ctx.lineTo(20, 25);
‎            ctx.lineTo(-45, 25);
‎            ctx.closePath();
‎            ctx.fill();
‎            // Windows
‎            ctx.fillStyle = '#add8e6';
‎            ctx.fillRect(-30, -10, 50, 15);
‎            ctx.shadowBlur = 0;
‎            // Wheels
‎            ctx.fillStyle = '#333';
‎            ctx.beginPath();
‎            ctx.arc(-35, -15, 12 / player.zoom * player.zoom, 0, Math.PI * 2); ctx.fill(); // Scale fix
‎            ctx.arc(-35, 20, 12, 0, Math.PI * 2); ctx.fill();
‎            ctx.arc(40, -15, 12, 0, Math.PI * 2); ctx.fill();
‎            ctx.arc(40, 20, 12, 0, Math.PI * 2); ctx.fill();
‎            ctx.restore();
‎
‎            ctx.restore();
‎
‎            // UI Overlay
‎            ctx.fillStyle = 'rgba(0,0,0,0.5)';
‎            ctx.fillRect(0, 0, canvas.width, 120);
‎            ctx.fillStyle = '#ffd700';
‎            ctx.font = 'bold 28px Arial';
‎            ctx.textAlign = 'left';
‎            ctx.fillText(levels[currentLevel].name, 20, 40);
‎            ctx.fillText(`Car: ${['Mercedes', 'BMW', 'Audi'][player.carType]}`, 20, 70);
‎            ctx.fillText(`Score: ${player.score}`, 20, 100);
‎            ctx.font = '20px Arial';
‎            ctx.fillText('1:Udaipur 2:Jodhpur | C:Car | +/- Zoom | Drag Pan', 20, canvas.height - 30);
‎            ctx.textAlign = 'right';
‎            ctx.fillText('Touch Left:Drive | Right:Pan', canvas.width - 20, canvas.height - 30);
‎        }
‎
‎        // Game Loop
‎        function loop() {
‎            update();
‎            draw();
‎            requestAnimationFrame(loop);
‎        }
‎        loop();
‎    </script>
‎</body>
‎</html>
‎
stdout
Standard output is empty