Desarrollo tempranoPre-1.0: la sintaxis puede cambiar.Historial de versionesGitHub
Juego Retro Arcade

VectWorms: Purga el Campo de Hongos

Limpia la cuadrícula de hongos en este juego de arcade de Rune-Web.

Pulsa PLAY NOW, usa WASD o las flechas y dispara con Espacio. En el móvil, usa la cruceta y FIRE.

VectWorms: Purga el Campo de Hongos

Cargando juego…

Licencia del juego

Ver código fuente
vectworms.rune
#!RUNE

import "parts"

@App
name = VectWorms
version = 1.0
type = REST
port = 3000

@Frontend
type = rune-web
path = %ROOT%
page = vectworms

@Page/vectworms
title = VectWorms
style = vectworms
logic = vectworms
view:
    main .arcade-cabinet:
        header .cabinet-header:
            h1 .cabinet-title "VECTWORMS"
            div .stats-bar:
                span "SCORE: {score}"
                span "LIVES: {lives}"
                span "WORMS: {worm_count}"

        div .arena-viewport:
            div .game-arena:
                div .arena-grid
                div .player-zone

                # Mushroom field
                div .mushroom style="left: calc({m.x} * 100% / 480); top: calc({m.y} * 100% / 480); display: {m.alive ? 'flex' : 'none'}; opacity: calc({m.hp} / 3);" <- m in mushrooms:
                    "🍄"

                # Worm segments
                div .worm style="left: calc({w.x} * 100% / 480); top: calc({w.y} * 100% / 480); display: {w.alive ? 'flex' : 'none'}; background: {w.is_head ? '#ff007f' : '#39ff14'};" <- w in worms:
                    "{w.is_head ? '👀' : '🟢'}"

                # Player Blaster
                div .player style="left: calc({player.x} * 100% / 480); top: calc({player.y} * 100% / 480);":
                    div .player-cannon

                # Player Lasers
                div .bullet <- bullet in bullets:
                    style = "left: calc({bullet.x} * 100% / 480); top: calc({bullet.y} * 100% / 480);"

                # Explosions & Particles
                div .particle <- p in particles:
                    style = "left: calc({p.x} * 100% / 480); top: calc({p.y} * 100% / 480); opacity: calc({p.life} / {p.max_life}); width: {p.size}px; height: {p.size}px; background: {p.color};"

                # Game State Overlay
                if status != "playing":
                    div .overlay:
                        h2 .overlay-title "{game_message}"
                        button .start-btn click=start on_pointerdown=start "PLAY NOW"

        # Arcade Controls for Touch and Mouse
        div .arcade-controls:
            div .dpad-grid:
                div
                button .ctrl-btn on_pointerdown=startUp on_pointerup=stopMoveY on_pointerleave=stopMoveY click=moveUp "▲"
                div
                button .ctrl-btn on_pointerdown=startLeft on_pointerup=stopMoveX on_pointerleave=stopMoveX click=moveLeft "◀"
                button .ctrl-btn on_pointerdown=startDown on_pointerup=stopMoveY on_pointerleave=stopMoveY click=moveDown "▼"
                button .ctrl-btn on_pointerdown=startRight on_pointerup=stopMoveX on_pointerleave=stopMoveX click=moveRight "▶"

            button .ctrl-btn .fire-btn on_pointerdown=fire click=fire "⚡ FIRE"

        p .controls-hint "KEYBOARD: [WASD / ARROWS] MOVE  •  [SPACE] FIRE"
parts/field.rune
# Initial mushroom field and worm segment configuration for VectWorms
@Logic/vectworms
state:
    # Mushrooms placed in a tactical staggered arcade pattern
    local row_a = { "x": 60 } * 4 inc x by 110
    local row_b = { "x": 100 } * 4 inc x by 105
    local row_c = { "x": 80 } * 3 inc x by 140
    mushrooms = [
        row_a with { "y": 60 },
        row_b with { "y": 100 },
        row_c with { "y": 140 },
        row_a with { "y": 180 },
        row_b with { "y": 220 },
        row_c with { "y": 260 },
        row_a with { "y": 300 },
        row_b with { "y": 340 }
    ] all { "hp": 3, "alive": true }

    # Initial 10-segment centipede starting at the top row
    # Segment 0 is the head, followed by 9 body segments spaced 20px apart
    worms = [
        { "id": 0, "is_head": true, "x": 220, "start_x": 220 },
        { "id": i + 1, "is_head": false, "x": 200, "start_x": 200 } * 9 inc (x, start_x) by -20
    ] all { "y": 20, "start_y": 20, "dir_x": 1, "dir_y": 1, "alive": true }

parts/logic.rune
@Logic/vectworms
timer = tick 35ms

keys:
    ArrowLeft -> moveLeft
    ArrowRight -> moveRight
    ArrowUp -> moveUp
    ArrowDown -> moveDown
    Space -> fire
    KeyA -> moveLeft
    KeyD -> moveRight
    KeyW -> moveUp
    KeyS -> moveDown

state:
    player = { "x": 220, "y": 440 }
    bullets = []
    particles = emitter { "life": 16, "friction": 0.90, "size": [3, 6] }
    worm_speed = 4
    worm_count = 10
    move_dir_x = 0
    move_dir_y = 0
    score = 0
    lives = 3
    status = "ready"
    game_message = "VECTWORMS"

action startLeft:
    stop when status != "playing"
    move_dir_x = -1
    player.x = clamp(player.x - 16, 10, 450)

action startRight:
    stop when status != "playing"
    move_dir_x = 1
    player.x = clamp(player.x + 16, 10, 450)

action startUp:
    stop when status != "playing"
    move_dir_y = -1
    player.y = clamp(player.y - 14, 360, 455)

action startDown:
    stop when status != "playing"
    move_dir_y = 1
    player.y = clamp(player.y + 14, 360, 455)

action stopMoveX:
    move_dir_x = 0

action stopMoveY:
    move_dir_y = 0

action moveLeft:
    stop when status != "playing"
    player.x = clamp(player.x - 18, 10, 450)

action moveRight:
    stop when status != "playing"
    player.x = clamp(player.x + 18, 10, 450)

action moveUp:
    stop when status != "playing"
    player.y = clamp(player.y - 16, 360, 455)

action moveDown:
    stop when status != "playing"
    player.y = clamp(player.y + 16, 360, 455)

action fire:
    stop when status != "playing"
    stop when bullets.length >= 4
    bullets.push({ "x": player.x, "y": player.y - 12, "alive": true })
    sound "laser"

action start:
    score = 0
    lives = 3
    worm_count = 10
    move_dir_x = 0
    move_dir_y = 0
    player.x = 220
    player.y = 440
    bullets = []
    particles = []
    restore worms
    restore mushrooms
    status = "playing"
    game_message = ""
    music.play "vectworms"

action tick:
    particles.step()
    stop when status != "playing"

    # 1. Smooth player motion
    if move_dir_x < 0:
        player.x = clamp(player.x - 10, 10, 450)
    if move_dir_x > 0:
        player.x = clamp(player.x + 10, 10, 450)
    if move_dir_y < 0:
        player.y = clamp(player.y - 10, 360, 455)
    if move_dir_y > 0:
        player.y = clamp(player.y + 10, 360, 455)

    # 2. Update player bullets
    for b in bullets:
        b.y -= 14
    bullets = bullets.filter it.y > 0 and it.alive

    # 3. Bullets hit mushrooms
    for b in bullets:
        for m in mushrooms:
            if b.alive and m.alive:
                if collide(b, m, 18, 18):
                    b.alive = false
                    m.hp -= 1
                    sound "hit"
                    if m.hp <= 0:
                        m.alive = false
                        score += 5
                        particles.burst(m.x, m.y, 8, "#00ff88", 6)

    # 4. Move worm segments
    for w in worms:
        if w.alive:
            next_x = w.x + w.dir_x * worm_speed
            hit_obstacle = false

            # Check screen boundaries
            if next_x > 450 or next_x < 10:
                hit_obstacle = true

            # Check mushroom collisions
            for m in mushrooms:
                if m.alive and collide({ "x": next_x, "y": w.y }, m, 18, 18):
                    hit_obstacle = true

            if hit_obstacle:
                w.y += 20
                w.dir_x = -w.dir_x
                if w.y >= 460:
                    w.y = 360
            if !hit_obstacle:
                w.x = next_x

    # 5. Check bullet collisions with worm segments
    for b in bullets:
        for w in worms:
            if b.alive and w.alive:
                if collide(b, w, 20, 20):
                    b.alive = false
                    w.alive = false
                    score += 100
                    worm_count -= 1
                    sound "explosion"
                    particles.burst(w.x, w.y, 12, "#39ff14", 8)
                    mushrooms.push({ "x": w.x, "y": w.y, "hp": 3, "alive": true })
                    # Splitting: trailing segment becomes a new independent head
                    for s in worms:
                        if s.alive and s.id == w.id + 1:
                            s.is_head = true

    # 6. Check worm collision with player
    for w in worms:
        if w.alive:
            if collide(player, w, 22, 20):
                lives -= 1
                sound "hit"
                particles.burst(player.x, player.y, 16, "#00e5ff", 9)
                player.x = 220
                player.y = 440
                for seg in worms:
                    if seg.alive:
                        seg.x = seg.start_x
                        seg.y = seg.start_y
                        seg.dir_x = 1
                if lives <= 0:
                    sound "gameover"
                    music.stop
                    status = "game_over"
                    game_message = "GRID OVERRUN! GAME OVER"
                    stop

    # 7. Check victory condition
    if worm_count <= 0:
        sound "victory"
        music.stop
        status = "victory"
        game_message = "SECTOR PURGED! YOU WIN!"
        stop
parts/sound.rune
# VectWorms Arcade Sound & Chiptune Music Engine

@Sound/laser
wave = sawtooth
freq = 740 -> 180
duration = 100ms
volume = 0.22
curve = exponential

@Sound/hit
wave = square
freq = 240 -> 60
duration = 80ms
volume = 0.3

@Sound/explosion
wave = noise
filter = lowpass 950 -> 70
duration = 300ms
volume = 0.4

@Sound/gameover
wave = sawtooth
sequence = D4:140ms, C#4:140ms, C4:220ms, F#3:400ms
duration = 550ms
volume = 0.3

@Sound/victory
wave = triangle
sequence = G4:100ms, B4:100ms, D5:100ms, G5:250ms
duration = 550ms
volume = 0.3

@Music/vectworms
type = 8bit
tempo = 136
loop = true
volume = 0.18

lead:
    C4:8 E4:8 G4:8 A4:8 G4:8 E4:8 C4:8 D4:8       # Bar 1: Bouncy opening
    E4:8 G4:8 A4:8 C5:8 B4:4 G4:4                 # Bar 2: Peak melody
    A4:8 G4:8 E4:8 C4:8 D4:8 E4:8 D4:4           # Bar 3: Playful turn
    C4:2 -:2                                      # Bar 4: Rest & resolve

bass:
    C2:4 G2:4 C2:4 G2:4                           # Bar 1: Walking groove
    E2:4 B2:4 E2:4 B2:4                           # Bar 2
    F2:4 C3:4 G2:4 D3:4                           # Bar 3
    C2:4 G2:4 C2:2 -:4                            # Bar 4

drums:
    kick:4 snare:4 kick:8 kick:8 snare:4          # Bar 1: Syncopated beat
    kick:4 snare:4 kick:8 hihat:8 snare:4         # Bar 2
    kick:4 snare:4 kick:8 kick:8 snare:4          # Bar 3
    kick:4 snare:4 kick:2                         # Bar 4
parts/style.rune
@Style/vectworms
tokens:
    neon_lime = #39ff14
    neon_cyan = #00e5ff
    neon_magenta = #ff007f
    neon_amber = #ffaa00
    cabinet_bg = #060812
    card_bg = #0c1022
    arena_bg = #02040a
    grid_border = #1c2742
    text_muted = #7e8c9f
    btn_bg = #161e36

presets:
    game-entity:
        abs = true
        pointer-events = none

    arcade-btn:
        position = relative
        pointer-events = auto
        cursor = pointer
        touch-action = manipulation
        user-select = none
        weight = bold
        center = xy
        transition = all 0.1s ease

rules:
    body:
        margin = 0
        padding = 8px
        box-sizing = border-box
        background = {cabinet_bg}

    .arcade-cabinet:
        max-width = min(540px, calc((100svh - 272px) * 480 / 480 + 32px))
        width = 100%
        box-sizing = border-box
        margin = 0 auto
        background = {card_bg}
        border = 3px solid {neon_lime}
        round = 16px
        padding = 0.75rem
        box-shadow = 0 0 35px {neon_lime / 25%}, inset 0 0 20px rgba(0, 0, 0, 0.8)
        font-family = "Courier New", monospace, sans-serif
        color = #ffffff
        user-select = none
        touch-action = manipulation

    # Embedded cabinets size from available width; the host fits their height.
    .rune-embedded-game .arcade-cabinet:
        max-width = 540px

    .cabinet-header:
        text-align = center
        margin-bottom = 0.75rem
        border-bottom = 2px solid {neon_lime / 30%}
        padding-bottom = 0.6rem

    .cabinet-title:
        font-size = 1.75rem
        weight = 900
        letter-spacing = 4px
        color = {neon_lime}
        text-glow = {neon_lime} 10px 20px
        margin = 0 0 0.5rem 0

    .stats-bar:
        display = flex
        justify-content = space-between
        font-size = 0.95rem
        weight = bold
        letter-spacing = 2px
        color = {neon_cyan}

    .stat-label:
        color = {text_muted}

    .arena-viewport:
        position = relative
        container-type = inline-size
        display = block
        width = 100%
        height = auto
        aspect = 480 / 480
        margin = 0 auto
        overflow = hidden

    .game-arena:
        abs = inset
        size = 100%
        box-sizing = border-box
        background = {arena_bg}
        border = 2px solid {grid_border}
        round = 8px
        overflow = hidden
        box-shadow = inset 0 0 40px rgba(0, 0, 0, 0.95)
        pointer-events = none

    .arena-grid:
        use = (game-entity)
        abs = 0 0
        size = 100%
        background-image = radial-gradient({grid_border / 40%} 1px, transparent 1px)
        background-size = 20px 20px
        opacity = 0.45

    .player-zone:
        use = (game-entity)
        left = 0
        right = 0
        top = 75%
        bottom = 0
        border-top = 1px dashed {neon_cyan / 25%}
        background = {neon_cyan / 3%}

    .player:
        use = (game-entity)
        size = 6.25% 4.166667%
        transform = translate(-50%, -50%)
        center = xy
        transition = transform 0.05s linear
        z-index = 10

    .player-cannon:
        size = 100%
        background = {neon_cyan}
        round = 4px
        box-shadow = 0 0 14px {neon_cyan}, inset 0 0 4px #ffffff

    .bullet:
        use = (game-entity)
        size = 0.833333% 2.5%
        transform = translate(-50%, -50%)
        background = #ffffff
        round = 2px
        box-shadow = 0 0 8px {neon_cyan}, 0 0 14px #ffffff
        z-index = 8

    .mushroom:
        use = (game-entity)
        size = 3.75% 3.75%
        round = 50%
        transform = translate(-50%, -50%)
        background = {neon_amber}
        box-shadow = 0 0 10px {neon_amber / 60%}
        center = xy
        font-size = 0.65rem
        font-weight = bold
        color = #000000
        z-index = 5

    .mushroom.damaged:
        opacity = 0.6
        box-shadow = 0 0 4px {neon_amber / 30%}

    .worm:
        use = (game-entity)
        size = 4.166667% 4.166667%
        round = 50%
        transform = translate(-50%, -50%)
        background = {neon_lime}
        box-shadow = 0 0 12px {neon_lime}
        center = xy
        z-index = 6
        transition = all 0.04s linear

    .worm.is-head:
        background = {neon_magenta}
        box-shadow = 0 0 16px {neon_magenta}, inset 0 0 6px #ffffff
        z-index = 7

    .particle:
        use = (game-entity)
        round = 50%
        transform = translate(-50%, -50%)
        pointer-events = none
        z-index = 15
        will-change = transform, opacity

    .overlay:
        abs = inset
        size = 100%
        background = {arena_bg / 88%}
        center = xy
        flex-direction = column
        z-index = 20
        pointer-events = auto

    .overlay-title:
        font-size = 1.6rem
        weight = 900
        letter-spacing = 3px
        margin-bottom = 1rem
        text-align = center
        color = {neon_lime}
        text-glow = {neon_lime} 15px
        padding = 0 1rem

    .start-btn:
        use = (arcade-btn)
        background = {neon_lime}
        color = {arena_bg}
        border = none
        padding = 0.85rem 2.25rem
        font-size = 1.15rem
        letter-spacing = 2px
        round = 8px
        glow = {neon_lime / 60%} 20px
        transition = all 0.15s ease
        &:hover:
            background = #5aff38
            glow = {neon_lime / 90%} 30px
            transform = scale(1.05)
        &:active:
            transform = scale(0.97)

    .arcade-controls:
        position = relative
        z-index = 100
        display = flex
        justify-content = space-between
        align-items = center
        width = 100%
        gap = 0.75rem
        margin-top = 1.1rem
        box-sizing = border-box
        pointer-events = auto

    .dpad-grid:
        display = grid
        grid-template-columns = repeat(3, 44px)
        grid-template-rows = repeat(2, 44px)
        gap = 4px

    .ctrl-btn:
        use = (arcade-btn)
        min-height = 44px
        background = {btn_bg}
        color = {neon_lime}
        border = 2px solid {grid_border}
        font-size = 0.95rem
        round = 8px
        &:hover:
            border-color = {neon_lime}
            glow = {neon_lime / 30%} 12px
        &:active:
            background = {neon_lime}
            color = {arena_bg}
            transform = scale(0.95)

    .fire-btn:
        use = (arcade-btn)
        flex = 1
        max-width = 160px
        min-height = 92px
        background = {neon_magenta}
        color = #ffffff
        border-color = {neon_magenta}
        glow = {neon_magenta / 40%} 15px
        font-size = 1.25rem
        round = 12px
        letter-spacing = 2px
        &:hover:
            background = #ff3399
            glow = {neon_magenta / 70%} 25px
        &:active:
            background = #e60073
            transform = scale(0.95)

    .controls-hint:
        text-align = center
        margin-top = 0.75rem
        font-size = 0.8rem
        color = #64748b
        letter-spacing = 1px

responsive:
    (max-width: 520px):
        .arcade-cabinet:
            padding = 0.5rem
            margin = 0 auto
            border-width = 2px
            border-radius = 12px
        .cabinet-title:
            font-size = 1.35rem
            letter-spacing = 2px
        .stats-bar:
            font-size = 0.8rem
            letter-spacing = 1px
        .arcade-controls:
            gap = 0.4rem
            margin-top = 0.6rem
            position = relative
            z-index = 100
        .fire-btn:
            min-height = 80px
            font-size = 1.1rem
        .controls-hint:
            font-size = 0.7rem
Cómo funciona este ejemplo

🐛 División de Cadenas

Destruir un segmento genera un nuevo hongo y convierte al segmento siguiente en una nueva cabeza independiente.

🍄 Generadores de Estado

Las filas de hongos y los 10 segmentos se generan declarativamente usando plantillas locales, inc y modificadores all.

🔊 Partículas y Audio Sintetizado

Las declaraciones emitter y acciones sound activan explosiones de partículas y efectos Web Audio en tiempo real.

🕹️ Zona 2D y Cruceta Arcade

Movimiento en 4 direcciones dentro de la zona del jugador con teclado WASD/Flechas o cruceta táctil en pantalla.

Controles

⌨️ WASD / Flechas: Mover en 4 direcciones • Espacio: Disparar

📱 Usa la cruceta táctil y el botón de disparo en móviles o tabletas.

Ejecutar localmente

Para ejecutar el ejemplo completo, instala Vectrune y Git. Clona el repositorio una vez y conserva la carpeta parts junto al archivo principal.

Inicio rápido
git clone https://github.com/davethomas11/vectrune.git
cd vectrune

Ejecuta estos comandos desde la raíz del repositorio. Si ya tienes una copia, abre una terminal en su raíz y omite la clonación.

vectrune examples/games/vectworms/vectworms.rune
vectrune examples/games/vectworms/vectworms.rune -o html > vectworms.html
Sitio creado íntegramente con Rune-Web