Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Text Adventure game not showing text elements

I am a beginner programmer and am attempting to create a Text Adventure with javascript, however, the text will not show and I couldn't find any obvious errors. could someone plaese help.

js const textElement = document.getElementById('text') const optionButtonsElement = document.getElementById('option-buttons')

let state = {}

function startGame() {
    state = {}
    showTextNode(1)
}

function showTextNode(textNodeIndex) {
    const textNode = textNodes.find(textNode.id === textNodeIndex)
    textElement.innerText = textNode.text
    while (optionButtonsElement.firstChild) {
        optionButtonsElement.removeChild(optionButtonsElement.firstChild)
}

function selectOption(option) {
    
}
    
    

const textNodes = [
    {
        id: 1,
        text: "You wake up in a room you've never seen before. Getting out of bed, you note the silver, almost royal, color scheme of the room.",
        option: [
        {
        text: 'Examine the Room',
        setState: { RoomKnowledge: true },
        nextText: 2
        }
        ]
    }
    {
    id: 2
    }
]

startGame()

html

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Test</title>
        <link rel="stylesheet" href="style.css">
        <script src="game.js"></script>
    </head>
    <body>
        <div class="container">
            <div id="text"></div>
            <div id="option-buttons" class="btn-grid">
                <button class="btn">Option 1</button>
                <button class="btn">Option 2</button>
                <button class="btn">Option 3</button>
                <button class="btn">Option 4</button>
            </div>
        </div>
    </body>
</html>
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!