Games by Bea

Bea Anything โœจ

๐Ÿงช Code Lab: Pong

Use ๐Ÿ”ผ and ๐Ÿ”ฝ arrows or W and S to move your paddle!

๐Ÿ’ป Code Snippet โ€” How It Works โ–ผ
// Pong โ€” key concepts shown below (not the full file)
// Modern Pong - Editable Code Example
let ball = {
    x: 350,
    y: 225,
    vx: 5,
    vy: 5,
    radius: 12,
    color: "#aee9ff",
    glow: true
};

let player = {
    x: 20,
    score: 0,
    height: 100
};

function updateGame() {
    // Update ball position
    ball.x += ball.vx;
    ball.y += ball.vy;

    // Bounce off walls
    if (ball.y <= 0 || ball.y >= canvas.height) {
        ball.vy *= -1;
    }
}

๐Ÿงช Code Lab: Snake

Use Arrow Keys or WASD to control the snake!

๐Ÿ’ป Code Snippet โ€” How It Works โ–ผ
// Snake โ€” key concepts shown below (not the full file)
// Modern Snake - Editable Code Example
let snake = {
    speed: 10,
    color: "#10b981",
    body: [{x: 10, y: 10}],
    dx: 1, 
    dy: 0
};

let food = {
    color: "#f43f5e",
    x: 15,
    y: 15
};

function moveSnake() {
    const head = {
        x: snake.body[0].x + snake.dx,
        y: snake.body[0].y + snake.dy
    };
    snake.body.unshift(head);
    
    if (head.x === food.x && head.y === food.y) {
        spawnFood(); // Grow!
    } else {
        snake.body.pop(); // Remove tail
    }
}

๐Ÿงช Code Lab: Minesweeper

Left click to reveal, Right click to flag!

๐Ÿ’ป Code Snippet โ€” How It Works โ–ผ
// Minesweeper โ€” key concepts shown below (not the full file)
// Minesweeper - The Flood Fill (Coolest Part!)
function reveal(i, j) {
    let cell = grid[i][j];
    if (cell.isRevealed || cell.isFlagged) return;

    cell.isRevealed = true;

    // If no mines nearby, reveal all 8 neighbors too!
    if (cell.neighborMines === 0 && !cell.isMine) {
        for (let xoff = -1; xoff <= 1; xoff++) {
            for (let yoff = -1; yoff <= 1; yoff++) {
                reveal(i + xoff, j + yoff); // Calls itself! (Recursion)
            }
        }
    }
}

// Count mines around each cell
for (let xoff = -1; xoff <= 1; xoff++) {
    for (let yoff = -1; yoff <= 1; yoff++) {
        let neighbor = grid[i + xoff][j + yoff];
        if (neighbor.isMine) total++;
    }
}
Made by Bea โœจ