summaryrefslogtreecommitdiff
path: root/README.md
blob: 81582793b51d1394f81f68da9904276c290edcd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# dng

dng is a maze/puzzle game + engine! Design and work your way through your own maze avoiding enemies and finding
treasure!

## How to run

To run the game you can just launch `dng` or `dng.exe` on windows.

Follow the onscreen prompts to load a level and play!

### Configurations

By default the game will look for its configuration file in a few OS specific places.
The default config is bundled along side the executable: `config.toml`

## Create your own level!

Levels use the following directory structure:

```shell
level-name/
  dng.map # required -the map file
  proc.lua # optional - custom lua overrides
```

### Map Format

The map format is just a text file with the following key tokens:

| Token | Description              |
|:------|:-------------------------|
| w     | Wall                     |
| p     | The player (must have 1) |
| e     | Enemies (0 or more)      |
| t     | Treasure (0 or more)     |
| 0     | Empty space              |

Doors and Keys: 

Doors and keys are single use and map to specific doors.
Each key (1-4) maps to a door type (a-d)

| Token | Description              |
|:------|:-------------------------|
| 1     | Key 1, for Door a        |
| 2     | Key 2, for Door b        |
| 3     | Key 3, for Door c        |
| 4     | Key 4, for Door d        |
| a     | Door a, opened by key 1  |
| a     | Door b, opened by key 2  |
| a     | Door c, opened by key 3  |
| d     | Door d, opened by key 4  |


#### Tips

Space your map out using whitespace between every token (`w w w w` instead of `wwww`) for better readability.
Use a monospace font to help things align

### Custom Lua Code

Create a `proc.lua` in your level folder.
You can override anything found in `dnglib` using standard lua scoping rules.
If you wish to call the original defaults you can include `dnglib.defaults` in your file:
`local defaults = require('dnglib.defaults')` and call the functions:

```lua
package.path = '['
function onKeyPress(key)
    -- Set your own overrides
    defaults.onKeyPress(key)
end
```

## Develop

dng uses git-submodules:

```shell
git clone https://github.com/s3nd3r5/dng
git submodules init
git submodules update
```

### Dependencies

Current build process is setup for a *nix like environment.

| Dependency | Version |
|:-----------|:--------|
| c++        | 20+     |
| g++        | 8+      |
| CMake      | 3.16+   |
| Lua        | 5.4.*   |
| SFML       | 2.5.*   |

_Note: with some CMake modifications we could probably leverage lower versions_

### Build

dng uses CMake

```shell
# use a build dir to ensure we ignore build props
cmake -B cmake-build
```

_Developed with CLion using CMake and g++ on Linux_

### Enforcing local lua files

To ensure you're always loading the local files make sure you include:

`package.path = "./?.lua;" .. package.path` at the top of your `proc.lua`

If you're experiencing issues loading the proper files you can always set in your local development environment:

`export LUA_PATH=/path/to/dng/?.lua;` (replacing `/path/to/dng` with your actual local development path)

this will allow you to run `dng` from anywhere

### Licensing in files

You can find a copy of the notice in `.copyright_headers`.

Note `dnglib/constants.lua` and `src/lua.hpp` which have custom licensing information.

## Run

Once you build the project you can execute it by:

```shell
# use your build dir and select a map!
./cmake-build/dng
```

Note: You need to use the working directory containing the `include` folder!

## MacOS

MacOS support is not functional at the moment, but I merged the generic changes in since if I do want to get OSX support for older MacOS systems
then I need something that isn't dependent on their librarys not including some modern C++ features.

I lack a proper test machine at the moment and struggled to get [Darling](https://www.darlinghq.org/) working properly.

The _biggest_ issue is the fact that I was also unable to pull in a minimum amount of boost libs that I needed, so I had to submodule the entire
system. Which results in quite a bit of filesize for this tiny project. The executable and shared libs would be much smaller, but the source is hefty.
Sorry. I'm sure you could get away with /not/ initializing boost and being just fine since Windows and Linux codepaths shouldn't ever call it.

## External Libraries and Resources used by dng

* [SFML](https://github.com/SFML/SFML) licensed
  under [zlib/png license](https://www.sfml-dev.org/license.php)
* [Lua](https://github.com/lua/lua) licensed under [MIT license](https://www.lua.org/license.html)
* [Boost](https://github.com/boostorg/boost) licensed under [Boost Software License](https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt)
* [Press Start 2P Font](https://fonts.google.com/specimen/Press+Start+2P#glyphs) licensed
  under [SIL Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL)
* [Liberation Fonts](https://github.com/liberationfonts/liberation-fonts) licensed
  under [SIL Open Font License](https://github.com/liberationfonts/liberation-fonts/blob/main/LICENSE)