Skip to content

INDIA DARKA #1256

Open
Open

Description

  • VS Code Version:
  • OS Version:
  • Code Runner Version:

Describe the bug
Description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

Actual behavior
Description of what happened actually.

Expected behavior
Description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Activity

  1. kalpesarajaputa29-maker commented on Jan 27, 2026

    @kalpesarajaputa29-maker
    Author
    <title>હાઇવે ઈંડિયન ટ્રક - રીયલ લાઈફ ડ્રાઈવિંગ! 🗻🌊🦅🐘</title> <script src="https://cdn.jsdelivr.net/npm/phaser@3.80.1/dist/phaser.min.js"></script> <style> body { margin: 0; background: #000; font-family: Arial; } canvas { display: block; margin: auto; } #instructions { position: absolute; top: 10px; left: 10px; color: white; font-size: 14px; z-index: 100; } </style>
    ← → સ્ટીયરિંગ | ↑ આગળ | ↓ બ્રેક | Space: રીસ્ટાર્ટ
    🗻 પર્વત, 🌊 નદી/તળાવ/દરીયો, 🦅 પંખી, 🐘 પ્રાણી - રીયલ લાઈફ જેવું!
    <script> var config = { type: Phaser.AUTO, width: 800, height: 600, physics: { default: 'arcade', arcade: { gravity: { y: 0 }, debug: false } }, scene: GameScene }; var game = new Phaser.Game(config);

    class GameScene extends Phaser.Scene {
    constructor() {
    super({ key: 'GameScene' });
    }

    preload() {
        // તમે અહીં real PNG assets add કરી શકો: this.load.image('mountain', 'assets/mountain.png');
    }
    
    create() {
        this.score = 0;
        this.speed = 2;
        this.gameOver = false;
    
        // Sky gradient
        var sky = this.add.rectangle(400, 300, 800, 600, 0x87CEEB).setDepth(-10);
        var clouds = this.add.tileSprite(400, 200, 800, 200, 'clouds').setTint(0xFFFFFF).setAlpha(0.7).setDepth(-5);
    
        // Far background: Mountains 🗻 (slow parallax)
        this.mountains = this.add.tileSprite(400, 400, 1600, 400, 'mountain').setTint(0x556B2F).setScale(1.2).setDepth(-8);
        // Procedural mountains using graphics
        var graphics = this.add.graphics({ fillStyle: { color: 0x8B4513 } }).setDepth(-9);
        graphics.fillTriangle(100, 450, 200, 350, 300, 450);
        graphics.fillTriangle(500, 450, 600, 320, 700, 450);
        graphics.fillTriangle(650, 450, 750, 340, 800, 450);
        graphics.generateTexture('mountain', 800, 500);
    
        // Mid background: Sea/Lake/River 🌊 (wavy blue, random change)
        this.water = this.add.tileSprite(400, 500, 800, 200, 'water').setTint(0x4169E1).setAlpha(0.6).setDepth(-3);
        var waterGraphics = this.add.graphics({ fillStyle: { color: 0x4682B4 } }).setDepth(-4);
        waterGraphics.fillRect(0, 0, 800, 100);
        waterGraphics.lineStyle(2, 0xFFFFFF, 0.5);
        for (let i = 0; i < 20; i++) waterGraphics.lineBetween(i*40, Phaser.Math.Between(20,60), (i+1)*40, Phaser.Math.Between(20,60));
        waterGraphics.generateTexture('water', 800, 100);
    
        // Fields/Khetar (green slow)
        this.fields = this.add.tileSprite(400, 550, 800, 100, 'grass').setTint(0x228B22).setDepth(-2);
    
        // Road (fast scroll)
        this.road = this.add.tileSprite(400, 300, 800, 600, 'road').setTint(0x444444).setDepth(0);
    
        // Road texture with lanes + bridge spots
        var roadCtx = this.textures.createCanvas('road', 256, 128).getSourceImage().getContext('2d');
        roadCtx.fillStyle = '#444'; roadCtx.fillRect(0, 0, 256, 128);
        roadCtx.strokeStyle = '#FFF'; roadCtx.lineWidth = 40; roadCtx.setLineDash([40,40]); roadCtx.beginPath();
        roadCtx.moveTo(128, 0); roadCtx.lineTo(128, 128); roadCtx.stroke();
        roadCtx.lineWidth = 20; roadCtx.strokeStyle = '#DDD'; roadCtx.setLineDash([]);
        roadCtx.lineWidth = 6; roadCtx.beginPath(); roadCtx.moveTo(64,0); roadCtx.lineTo(64,128); roadCtx.moveTo(192,0); roadCtx.lineTo(192,128); roadCtx.stroke();
    
        // Grass texture
        var grassCtx = this.textures.createCanvas('grass', 128, 64).getSourceImage().getContext('2d');
        grassCtx.fillStyle = '#228B22'; grassCtx.fillRect(0,0,128,64);
        for(let i=0; i<20; i++) { grassCtx.fillStyle = '#32CD32'; grassCtx.fillRect(Math.random()*128, Math.random()*64, 3, 10); }
        grassCtx.fillStyle = '#FFD700'; for(let i=0; i<5; i++) grassCtx.fillRect(Math.random()*128, 50, 8, 14); // Crops
    
        // Cockpit: Dashboard + Steering (realistic)
        this.dashboard = this.add.rectangle(400, 550, 800, 200, 0x2F4F4F).setDepth(20);
        this.steering = this.add.circle(380, 520, 55, 0x696969).setDepth(25);
        this.steering.setInteractive();
        this.add.circle(380, 520, 35, 0x000).setDepth(26); // Steering center
        // Gauges
        this.add.circle(300, 500, 40, 0xFF0000).setDepth(22); // Speedo
        this.add.circle(500, 500, 35, 0xFFFF00).setDepth(22); // Fuel
    
        // Mirrors (with reflection sim)
        var leftMirror = this.add.rectangle(150, 450, 70, 50, 0x111).setDepth(18);
        var rightMirror = this.add.rectangle(650, 450, 70, 50, 0x111).setDepth(18);
    
        // Truck hood visible
        this.truckHood = this.add.rectangle(400, 380, 250, 120, 0xFF4500).setDepth(5); // Red Indian truck
        this.add.rectangle(400, 320, 140, 80, 0xFFD700).setDepth(6); // Cab yellow
        this.add.rectangle(450, 410, 200, 50, 0x8B4513).setDepth(4); // Cargo load (wood/sugarcane)
    
        // Groups
        this.cars = this.add.group();
        this.trees = this.add.group();
        this.birds = this.add.group();
        this.animals = this.add.group();
        this.bridges = this.add.group();
    
        // Spawners (more frequent for realism)
        this.time.addEvent({ delay: 1000, callback: this.spawnCar, callbackScope: this, loop: true });
        this.time.addEvent({ delay: 1500, callback: this.spawnTree, callbackScope: this, loop: true });
        this.time.addEvent({ delay: 2500, callback: this.spawnBird, callbackScope: this, loop: true });
        this.time.addEvent({ delay: 3000, callback: this.spawnAnimal, callbackScope: this, loop: true });
        this.time.addEvent({ delay: 8000, callback: this.spawnBridge, callbackScope: this, loop: true });
        this.time.addEvent({ delay: 12000, callback: this.changeWater, callbackScope: this, loop: true }); // River/Lake/Sea change
    
        // Controls
        this.cursors = this.input.keyboard.createCursorKeys();
    
        // UI
        this.speedText = this.add.text(260, 480, 'Speed: 0 km/h', { fontSize: '22px', fill: '#00FF00', backgroundColor: '#000', padding: {x:10,y:5} }).setDepth(30);
        this.scoreText = this.add.text(20, 20, 'Score: 0', { fontSize: '32px', fill: '#FFF', stroke: '#000', strokeThickness: 6 }).setDepth(40);
    
        this.gameOverText = this.add.text(400, 280, 'ગેમ ઓવર!\nSpace: રીસ્ટાર્ટ', { fontSize: '36px', fill: '#FF0000', align: 'center' })
            .setOrigin(0.5).setDepth(50).setVisible(false);
    
        // Physics for truck (simple)
        this.physics.add.existing(this.truckHood);
        this.truckHood.body.setSize(200, 100).setOffset(-100, -50);
    }
    
    update(time, delta) {
        if (this.gameOver) {
            if (Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE))) {
                this.scene.restart();
            }
            return;
        }
    
        // Controls & Steering
        let targetX = 400;
        if (this.cursors.left.isDown) { targetX = 250; this.steering.angle = -25; }
        else if (this.cursors.right.isDown) { targetX = 550; this.steering.angle = 25; }
        else this.steering.angle *= 0.9;
        this.truckHood.x += (targetX - this.truckHood.x) * 0.15;
    
        // Speed
        if (this.cursors.up.isDown) this.speed += 0.02;
        if (this.cursors.down.isDown) this.speed -= 0.05;
        this.speed = Phaser.Math.Clamp(this.speed, 0.5, 8);
        this.speedText.setText('Speed: ' + Math.floor(this.speed * 15) + ' km/h');
    
        // Parallax (realistic speeds)
        this.mountains.tilePositionY -= this.speed * 0.1;
        this.water.tilePositionY -= this.speed * 0.15;
        this.fields.tilePositionY -= this.speed * 0.25;
        this.road.tilePositionY -= this.speed * 0.8;
    
        // Move groups down (coming towards player)
        [this.cars, this.trees, this.birds, this.animals, this.bridges].forEach(group => {
            group.children.entries.forEach(obj => {
                obj.y += this.speed * (obj.isBird ? 0.4 : obj.isBridge ? 0.6 : 0.7);
                if (obj.y > 700) obj.destroy();
                // Collision with truck
                if (Phaser.Geom.Intersects.RectangleToRectangle(this.truckHood.getBounds(), obj.getBounds())) {
                    this.gameOverFunc();
                }
            });
        });
    
        // Score & Difficulty
        this.score += delta * this.speed * 0.005;
        this.scoreText.setText('Score: ' + Math.floor(this.score));
        this.speed += 0.0001; // Accelerate slowly
    }
    
    spawnCar() {
        let x = Phaser.Utils.Array.GetRandom([200, 400, 600]);
        let car = this.add.rectangle(x, -120, 60, 100, Phaser.Math.RND.pick([0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00]));
        this.physics.add.existing(car, true);
        car.body.setSize(55, 90);
        this.cars.add(car);
    }
    
    spawnTree() {
        let side = Phaser.Math.Between(1,2) > 1 ? 120 : 680;
        let tree = this.add.container(side, -80);
        tree.add(this.add.rectangle(0, 40, 45, 80, 0x228B22)); // Trunk/Leaves
        tree.add(this.add.ellipse(0, 0, 60, 80, 0x32CD32));
        this.trees.add(tree);
    }
    
    spawnBird() { // 🦅 Flying birds
        let bird = this.add.triangle(Phaser.Math.Between(50,750), -50, 0,0, 25,15, 0,20, 0x8B4513);
        bird.isBird = true;
        bird.setRotation(Phaser.Math.DegToRad(-10));
        this.tweens.add({ targets: bird, x: '+=100', duration: 2000, yoyo: true, repeat: -1 });
        this.birds.add(bird);
    }
    
    spawnAnimal() { // 🐘🐄 Animals roadside
        let side = Phaser.Math.Between(1,2) > 1 ? 100 : 700;
        let animal = this.add.rectangle(side, -60, 40, 35, Phaser.Math.RND.pick([0x8B4513, 0x654321])); // Cow/Elephant color
        animal.add(this.add.ellipse(0, -10, 20, 15, 0xFFF)); // Head
        this.animals.add(animal);
    }
    
    spawnBridge() { // પુલ Bridge over road
        let bridge = this.add.rectangle(400, -200, 300, 60, 0x696969);
        bridge.add(this.add.rectangle(-120, 0, 20, 80, 0x8B4513)); // Side supports
        bridge.add(this.add.rectangle(120, 0, 20, 80, 0x8B4513));
        bridge.isBridge = true;
        this.bridges.add(bridge);
    }
    
    changeWater() { // Random water: River/Lake/Sea
        this.water.setAlpha(Phaser.Math.Between(0.3, 0.8));
        this.water.setTint(Phaser.Math.RND.pick([0x4169E1, 0x00BFFF, 0x4682B4]));
    }
    
    gameOverFunc() {
        this.gameOver = true;
        this.physics.pause();
        this.gameOverText.setVisible(true);
    }
    

    }
    </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions