Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.1 kB
1
Indexable
Never
// HTML: <canvas id="gameCanvas" width="800" height="600"></canvas>

// JavaScript
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');

let fishingLineLength = 0;
let isCasting = false;

canvas.addEventListener('mousedown', function(event) {
    if (!isCasting) {
        isCasting = true;
        let startY = event.clientY;
        
        const castInterval = setInterval(function() {
            fishingLineLength += 10;
            if (fishingLineLength >= canvas.height - startY) {
                clearInterval(castInterval);
                isCasting = false;
                fishingLineLength = 0;
                // Check if fish are caught
                checkFishCaught();
            }
        }, 50);
    }
});

function checkFishCaught() {
    // Implement fish detection and catching logic here
}

function draw() {
    // Clear canvas
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    // Draw water
    ctx.fillStyle = 'blue';
    ctx.fillRect(0, 0, canvas.width, canvas.height);

    // Draw fishing
Leave a Comment