Adventure Game
This project is a simple browser-based text adventure game made with:
- HTML → structure
- CSS → styling
- JavaScript → game logic
for a way more in-depth tutorial please visit https://www.youtube.com/watch?v=R1S_NhKkvGA
Supplies
you will need a laptop and a code editor like Visual Studio Code
Making a Folder
Make a folder called what ever you want just make it memorable in case you have a lot of folders
after doing this open said folder in your chosen editor for my purpose I will be using VScode(Visual Studio Code)
Inside it, create these files by pressing the little page icon:
index.html
style.css
game.js
Build the HTML Structure
The HTML creates:
- The game container
- Title
- Timer
- Inventory
- Story text
- Option buttons
Example structure:
What each section does:
.container
Holds the whole game
#timer
Shows how long the player takes
#lastTime
Shows previous time
#inventory
Displays collected items
#text
Displays story text
.btn-grid
Holds the option buttons
#secret-area
Hidden clickable area for secrets
Style the Game With CSS
Your CSS handles:
- Centering the game
- Styling buttons
- Fade-in text effect
- Background images
- Inventory display
Main styling ideas:
Center the game
This keeps the game perfectly centered.
Style the container
This creates the white game box.
Create the button grid
This makes a 2-column layout for choices.
Button hover effect
This changes the border when hovering.
Fade-in story text
Add JavaScript Game Logic
The JavaScript controls:
- Story progression
- Button choices
- Inventory system
- Timer
- Background changes
- Hidden secrets
Basic setup:
Create Story Nodes
A text adventure usually uses story nodes.
Example:
Each node contains:
Property
Meaning
id
Unique story section
text
Story displayed to player
options
Buttons player can click
nextText
Next story node