{"id":2266,"date":"2025-10-11T15:49:38","date_gmt":"2025-10-11T15:49:38","guid":{"rendered":"https:\/\/carbonlife.fun\/?page_id=2266"},"modified":"2026-04-23T11:59:49","modified_gmt":"2026-04-23T11:59:49","slug":"game","status":"publish","type":"page","link":"https:\/\/carbonlife.fun\/?page_id=2266","title":{"rendered":"Game"},"content":{"rendered":"\n<div id=\"text-adventure-game\">\n    <h2>Escape from Chernobyl<\/h2>\n\n    <div id=\"game-intro\">\n        <input type=\"text\" id=\"player-name\" placeholder=\"Enter your name\">\n        <br>\n        <button id=\"start-game-btn\">Start Game<\/button>\n    <\/div>\n\n    <div id=\"game-output\"><\/div>\n    <div id=\"game-buttons\"><\/div>\n\n    <div id=\"player-status\">\n        <div>Health:<\/div>\n        <div id=\"health-bar\">\n            <div id=\"health-fill\"><\/div>\n        <\/div>\n        <div>Inventory: <span id=\"inventory-list\">None<\/span><\/div>\n    <\/div>\n<\/div>\n\n<style>\n    \/* Container styling *\/\n    #text-adventure-game {\n        font-family: monospace;\n        color: #eee;\n        background-color: #222;\n        padding: 30px;\n        max-width: 600px;\n        margin: 50px auto;\n        border-radius: 10px;\n        box-shadow: 0 0 20px rgba(0,0,0,0.7);\n        text-align: center;\n    }\n\n    \/* Intro and input *\/\n    #game-intro input {\n        padding: 8px 10px;\n        border-radius: 5px;\n        border: none;\n        width: 60%;\n        margin-bottom: 10px;\n    }\n\n    #game-intro button {\n        padding: 8px 16px;\n        border-radius: 5px;\n        border: none;\n        background-color: #444;\n        color: #eee;\n        cursor: pointer;\n        margin-top: 5px;\n    }\n\n    #game-intro button:hover {\n        background-color: #666;\n    }\n\n    \/* Output area *\/\n    #game-output {\n        white-space: pre-line;\n        margin-top: 5px;\n        min-height: 100px;\n    }\n\n    \/* Buttons area *\/\n    #game-buttons button {\n        margin: 5px;\n        padding: 8px 16px;\n        background-color: #444;\n        color: #eee;\n        border: none;\n        border-radius: 5px;\n        cursor: pointer;\n    }\n\n    #game-buttons button:hover {\n        background-color: #666;\n    }\n\n    \/* Player status *\/\n    #player-status {\n        margin-top: 20px;\n        display: none;\n    }\n\n    #health-bar {\n        height: 20px;\n        background-color: 1125FF;    \n        border-radius: 10px;\n        overflow: hidden;\n        width: 100%;\n        margin-top: 15px;\n    }\n\n    #health-fill {\n        height: 100%;\n        width: 100%;\n        background-color: #1125FF;\n    }\n<\/style>\n\n<script>\ndocument.addEventListener('DOMContentLoaded', function() {\n    const gameState = {\n        playerName: \"\",\n        playerHealth: 100,\n        inventory: [],\n        location: \"start\",\n    };\n\nconst locations = {\n    start: {\n        description: \"You wake up before your alarm clock and make a decision\",\n        image: \"https:\/\/carbonlife.fun\/wp-content\/uploads\/2026\/04\/1-2.webp\",\n        video: \"\",\n        options: [\n            { text: \"work\", action: () => moveTo(\"work\") },\n            { text: \"home\", action: () => moveTo(\"home\") },\n        ],\n    },\n\n    work: {\n        description: \"A spooky cave. You hear a growl echoing inside.\",\n        image: \"https:\/\/images.unsplash.com\/photo-1520962922320-2038eebab146\",\n        video: \"https:\/\/www.w3schools.com\/html\/mov_bbb.mp4\",\n        options: [\n            { text: \"Fight the monster\", action: () => fightMonster() },\n            { text: \"Run back\", action: () => moveTo(\"start\") },\n        ],\n    },\n\n    home: {\n        description: \"A calm river flows here. Fish swim beneath the surface.\",\n        image: \"https:\/\/images.unsplash.com\/photo-1500375592092-40eb2168fd21\",\n        video: \"\",\n        options: [\n            { text: \"Fish\", action: () => fish() },\n            { text: \"Go back\", action: () => moveTo(\"start\") },\n        ],\n    },\n};\n\n    function updateStatus() {\n        document.getElementById(\"player-status\").style.display = \"block\";\n        document.getElementById(\"health-fill\").style.width = gameState.playerHealth + \"%\";\n        document.getElementById(\"inventory-list\").textContent = gameState.inventory.length > 0 ? gameState.inventory.join(\", \") : \"None\";\n    }\n\n    function moveTo(location) {\n        gameState.location = location;\n        showLocation();\n        updateStatus();\n    }\n\nfunction showLocation() {\n    const loc = locations[gameState.location];\n    const output = document.getElementById(\"game-output\");\n    const buttonsDiv = document.getElementById(\"game-buttons\");\n\n    output.innerHTML = \"\";\n    buttonsDiv.innerHTML = \"\";\n\n    \/\/ TEXT\n    const text = document.createElement(\"div\");\n    text.textContent = loc.description;\n    output.appendChild(text);\n\n    \/\/ IMAGE (online)\n    if (loc.image) {\n        const img = document.createElement(\"img\");\n        img.src = loc.image;\n        img.style.maxWidth = \"100%\";\n        img.style.marginTop = \"10px\";\n        img.style.borderRadius = \"10px\";\n        output.appendChild(img);\n    }\n\n    \/\/ VIDEO (online)\n    if (loc.video) {\n        const video = document.createElement(\"video\");\n        video.src = loc.video;\n        video.controls = true;\n        video.autoplay = true;\n        video.style.maxWidth = \"100%\";\n        video.style.marginTop = \"10px\";\n        video.style.borderRadius = \"10px\";\n        output.appendChild(video);\n    }\n\n    \/\/ OPTIONS\n    loc.options.forEach(option => {\n        const btn = document.createElement(\"button\");\n        btn.textContent = option.text;\n        btn.onclick = option.action;\n        buttonsDiv.appendChild(btn);\n    });\n}   \n function fightMonster() {\n        const damage = Math.floor(Math.random() * 10) + 1;\n        gameState.playerHealth -= damage;\n\n        const output = document.getElementById(\"game-output\");\n        output.textContent = `You fought bravely but lost ${damage} health! Current health: ${gameState.playerHealth}`;\n        updateStatus();\n\n        if (gameState.playerHealth <= 0) {\n            output.textContent += \"\\n\\nYou have died. Game over.\";\n            document.getElementById(\"game-buttons\").innerHTML = \"\";\n            return;\n        }\n\n        setTimeout(() => moveTo(\"start\"), 1500);\n    }\n\n    function fish() {\n        const caught = Math.random() > 0.5 ? \"a fish\" : \"nothing\";\n        if (caught !== \"nothing\") gameState.inventory.push(caught);\n\n        const output = document.getElementById(\"game-output\");\n        output.textContent = `You caught ${caught}.`;\n        updateStatus();\n        setTimeout(() => moveTo(\"start\"), 1500);\n    }\n\n    document.getElementById(\"start-game-btn\").addEventListener(\"click\", function() {\n        const nameInput = document.getElementById(\"player-name\").value.trim();\n        if(nameInput === \"\") {\n            alert(\"Please enter your name to start!\");\n            return;\n        }\n        gameState.playerName = nameInput;\n        document.getElementById(\"game-intro\").style.display = \"none\";\n        document.getElementById(\"game-output\").textContent = `Welcome, ${gameState.playerName}!\\n\\n`;\n        updateStatus();\n        showLocation();\n    });\n});\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Escape from Chernobyl Start Game Health: Inventory: None<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2266","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/carbonlife.fun\/index.php?rest_route=\/wp\/v2\/pages\/2266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/carbonlife.fun\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/carbonlife.fun\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/carbonlife.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/carbonlife.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2266"}],"version-history":[{"count":42,"href":"https:\/\/carbonlife.fun\/index.php?rest_route=\/wp\/v2\/pages\/2266\/revisions"}],"predecessor-version":[{"id":2997,"href":"https:\/\/carbonlife.fun\/index.php?rest_route=\/wp\/v2\/pages\/2266\/revisions\/2997"}],"wp:attachment":[{"href":"https:\/\/carbonlife.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}