Path
This readme may not be fully updated to the latest commit! DO NOT RELY ON IT!!
A simple, but exciting console-based game.
Requirements:
-
NodeJS installed
-
A terminal
Game data
NOTE: The words environments and biomes will both be used. They are the same.
Biomes
cave
plain
To access the JSON file for a biome, simply put a .json
on the end of it and that's the file. (Files located in game\\environments\\{environment}.json
)
Items
This file does not contain a list of items, see the items.json
file for the list of raw data.
Menus
options
environment JSON syntax
There are different properties in the biome JSON file.
type
{
"type": "continue"
}
On exit of the biome variant, the program will continue in the same biome type.
{
"type": "exit"
}
On exit of the biome variant, the program will continue in a differnt biome type.
action
{
"action": "go:plain"
}
This sample will take the player to a plain variant when that option is chosen. These actions are similar to commands in Minecraft.
You can also have a callback action if the action does not involve going to another biome.
{
"action": "give:wood=>go:cave"
}
A list of the commands
Action | Action description | Requires callback |
---|---|---|
go:{environment} |
Transports the player to {environment} |
false |
give:{item} |
Gives the player the item {item} |
true : give:{item}=>go:{environment} |
show:{menu} |
Shows specified {menu} |
false |
A list of items, environments, and menus is listed above.
Items JSON syntax
There are also different properties in the items JSON file.
Example
"logs": {
"dname": "Logs",
"desc": "Basically a broken tree.",
"type": "material"
}
dname
"": {
"dname": "WhatTheUserSees"
}
desc
"": {
"desc": "A quick description of the item, usually comedic."
}
type
"": {
"type": "tool"
}
List of item types
|Type|Type explanation|
|-|-|-|
|material
|An item that can be used in crafting|
|tool
|An item that can be used to complete task|
Game mechanics
Monster spawning
This occurence is chosen at random. It varies from mob to mob.
Required for a monster to spawn:
- Certain player level
- 5
- Specific biome
- Cave
Monsters will not spawn until these requirements are met.
Actions
When a monster spawns, player have two options: Run away
, or Prepare
Run away
This option is best selected when a player does not have the correct items to fight the monster.
It is decided by a small random number generator.
If the player is lucky enough, they will have successfully run away. If not, the consequences will be as if the player died.
Prepare
Using a more powerful tool gives the player more levels when the defeat the mob.
Chest spawning
This occurence is chosen at random. It depends on the type of biome.
Supported biomes:
Biome | Rarity |
---|---|
plain |
uncommon |
cave |
uncommon |
Rarity equations
common
code
Math.floor(Math.random() * 2) == 1
uncommon
code
Math.floor(Math.random() * 10) == 6
rare
code
Math.floor(Math.random() * 10) == Math.floor(Math.random() * 10)
player
object
inventory
Functions:
inventory.has(item)
if (inventory.has('logs')[0] == true) {
console.log(inventory.has('logs'))
}
Returns a boolean stating whether the player's inventory has a certain item and returns the amount in the inventory.
Result (if function completes successfully)
It returns an array.
[hasItemBool, amountNumber]
Result table
Result | Meaning |
---|---|
undefined |
The player has no inventory |
[true, Number] |
The player has that item in their inventory. Number is the amount in the inventory |
[false, 0] |
The player does not have that item in their inventory |
Souce code
Files and folders
Not here (coming soon)
Programming
Written in Node.js and JSON.
Common code
List of options in row
term.singleLineMenu(array, function(e, r) {
if (e) {
err(e)
}
if (r.selectedIndex == 0) {
//do something
}
})
Game state
enviro
['enviro', environment, environment_id]
mob
['mob', mobname, [environment, environment_id], mobtype]
Game functions
randomgen
: used for creating new games. Requires thetask
parameter.loadenviro
: used for returning to game menu. (it is usually theloadfromsaved
parameter). Requires thetask
,game
(environment), and theignorechests
bool.loadfromsaved
: used for return to the game menu. Requires thetask
,game
(environment), and theenviroid
(variant ID) parameter.
Packages
Actively used packages.
boxen
: Creates boxes.electron
: Creates browser windows.ezjason
: Reads JSON files.terminal-kit
: Does a lot of stuff, it's good.
ezjason
ezjason is a package dedicated for reading JSON files in one line of code, developed because of this project.
View on npm.
Launcher
The launcher is written in C++.
Topics
- Setting display mode
- Extras
Setting display mode
Why fullscreen?
Seriously? I shouldn't even have to say this! Most games are fullscreen. That's why. I will admit, it does make the game seem more immersive than just running it windowed.
Where'd my cursor go?
It went to X: 1920, Y: 1080 on your screen. If you are rocking an 4K or larger screen resolution, this placement will seem strange, but it worked on my screen. This was an alternative to hiding it. If you have any idea how to hide the mouse cursor in C++ for a console application, please tell me (or StackOverflow).