I'm a JS beginner. I want to make a visual novel type game. Kinda like the game Ace Attorney when you are in court. In this game you meet people and instead of fighting, you talk to them. In encounters, at the top is an image. This image will change depending on your response. There is a text box below it that shows the current text. And 2 (or possibly more) options boxes below. You have a Patience meter (just like a Health meter) that has like 100 points. Depending on the option you choose, you will lose or gain patience. You run out you lose. The goal is to use the correct responses and reach the end of the dialog without losing all patience. Depending on the choice you make, there will be different dialogs. So I'm preparing a dialog tree.
Any ideas on how to code this? I'm having a really hard time figuring out where to store all the text and options. And how to access the text and options.
Here is a sample of the text and options. At first I tried putting the text in objects. sales1 is the intro text. If you selection opt1, sales2 text will show on the screen. If you select opt2, sales3 text will show on the screen.
const sales1 = { action: "Salesman Chad wants to talk!", opt1: "Tell him you're not interested", opt2: "Hear him out" };
const sales2 = { action: "He has a rebuttal for that! "Sir, a classy man like you needs this car!"", opt1: ""We're not even at a dealership!"", opt2: ""Ooo a new car"" };
const sales3 = { action: ""Ssssoooooooo, what kind of TV service do you have?"", opt1: "Tell him your landlord pays for it", opt2: "Tell him you don't watch much TV" };
@font-face {
font-family: "Game Over Cre";
src: url(fonts/gameovercre1.ttf);
font-style: normal;
font-weight: 300;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Game Over Cre", sans-serif;
font-size: 40px;
}
body {
background: black;
color: white;
}
#image-box {
border: 4px solid white;
height: 500px;
width: 60%;
margin: 10px auto;
align-items: center;
display: flex;
justify-content: center;
}
#opponent {
height: 400px;
}
#text-box {
border: 4px solid white;
height: 150px;
width: 60%;
margin: 10px auto;
padding: 20px;
}
#options {
display: flex;
width: 60%;
/* background: gray; */
margin: auto;
flex-wrap: wrap;
justify-content: space-between;
}
#option-1, #option-2, #option-3, #option-4 {
height: 100px;
width: 49.5%;
border: 4px solid white;
margin-bottom: 10px;
font-size: 35px;
padding: 10px;
}
#option-1:hover, #option-2:hover, #option-3:hover, #option-4:hover {
background: white;
color: black;
}
<body>
<section class="main-hub">
<div id="image-box">
<img id="opponent" src="img/salesman-chad.png">
</div>
<div id="text-box">
<h1 id="action-text">Salesman Chad wants to talk!</h1>
</div>
<div id="options">
<div id="option-1">Tell him you're not interested</div>
<div id="option-2">Hear him out</div>
<!-- <div id="option-3"></div>
<div id="option-4"></div> -->
</div>
</section>
<script src="main.js"></script>
</body>