]> git.lizzy.rs Git - nothing.git/blob - README.md
Merge pull request #451 from tsoding/python-svg2rects
[nothing.git] / README.md
1 [![Build Status](https://travis-ci.org/tsoding/nothing.svg?branch=master)](https://travis-ci.org/tsoding/nothing)
2
3 # Nothing
4
5 ![](https://i.imgur.com/7mECYKU.gif)
6 ![](https://i.imgur.com/ABcJqB5.gif)
7
8 ## Dependencies
9
10 <!-- TODO: README deps are outdated -->
11
12 - [gcc]
13 - [cmake]
14 - [python3]
15 - [libsdl2-dev]
16 - [libsdl2-mixer-dev]
17 - [inotify-tools]
18
19 ### Ubuntu
20
21 ```console
22 $ sudo apt-get install gcc cmake libsdl2-dev libsdl2-mixer-dev python3 inotify-tools
23 ```
24
25 ### NixOS
26
27 For [NixOS] we have a development environment defined in [default.nix]
28 with all of the required dependencies. You can enter the environment
29 `nix-shell` command:
30
31 ```console
32 $ nix-shell
33 ```
34
35 ### Windows
36
37 See [Build on Windows][build-on-windows] section.
38
39 ## Quick Start
40
41 ```console
42 $ mkdir build
43 $ cd build/
44 $ cmake ..
45 $ make
46 $ ./nothing ../levels/level-01.txt
47 $ ./nothing_test
48 ```
49
50 ## Controls
51
52 ### Game
53
54 #### Keyboard
55
56 | Key     | Action                                                      |
57 |---------|-------------------------------------------------------------|
58 | `d`     | Move to the right                                           |
59 | `a`     | Move to the left                                            |
60 | `SPACE` | Jump                                                        |
61 | `c`     | Open debug console                                          |
62 | `r`     | Reload the current level including the Player's position    |
63 | `q`     | Reload the current level preserving the Player's position   |
64 | `p`     | Toggle game pause                                           |
65 | `l`     | Toggle transparency on objects. Useful for debugging levels |
66
67 #### Gamepad
68
69 | Button       | Action                 |
70 |--------------|------------------------|
71 | `Left Stick` | Movement of the Player |
72 | `1`          | Jump                   |
73
74 ### ConsolĂ©
75
76 | Key       | Action                   |
77 |-----------|--------------------------|
78 | `ESC`     | Exit console             |
79 | `Enter`   | Evaluate the expression  |
80 | `Up/Down` | Traverse console history |
81
82 ## Editing Levels
83
84 Generally creating a level looks like:
85
86 ```
87 SVG File -> Custom Level File -> Game
88 ```
89
90 To convert SVG to the level file and run [svg2rects.py] script:
91
92 ```console
93 $ python3 ./devtools/svg2rects.py -i <svg-file> -o <level-file>
94 ```
95
96 All of the levels reside in the [./levels/] folder. Use
97 [./levels/Makefile] to automatically rebuild all levels.
98
99 ### Level Editing Workflow
100
101 1. `$ inkscape ./levels/level.svg &`
102 2. `$ ./build/nothing ./levels/level.txt &`
103 3. `$ cd ./levels/`
104 4. `$ make watch`
105 5. Edit Level in Inkscape and Save
106 6. Switch to the Game and reload level by pressing Q
107 7. Go to 5
108
109 ### Objects Reference
110
111 #### SVG rect node
112
113 | Regex of id  | Description                                                                                                       |
114 |--------------|-------------------------------------------------------------------------------------------------------------------|
115 | `player`     | Defines the **position** of the Player. **Size is ignored**.                                                      |
116 | `rect.*`     | Defines the **size** and **position** of an impenetrable platform block                                           |
117 | `box.*`      | Defines the **size** and **position** of a rigid box that obeys the physics of the game                           |
118 | `region(.*)` | Defines the **size** and **position** of a region that hides the Goals. `\1` defines the id of the Goal to hide.  |
119 | `goal(.*)`   | Defines the **position** of the goal. **Size is ignored**. `\1` defines the id of the region that hides the goal. |
120 | `lava.*`     | Defines the **position** and **size** of a lava block.                                                            |
121 | `background` | Defines the **color** of the background. **Position and size are ignored**.                                       |
122 | `backrect.*` | Defines the **size** and **position** of a solid block in the background.                                         |
123
124 #### SVG text node
125
126 | Regex of id | Description                                                                |
127 |-------------|----------------------------------------------------------------------------|
128 | `label.*`   | Defines **position** and **text** of a in-game label. **Size is ignored**. |
129
130 ## Build on Windows
131
132 You need to install [conan][] and [Visual Studio 2017][visual-studio].
133
134 ### Dependencies
135
136 Current version of [SDL2/2.0.5@lasote/stable][conan-sdl2] in the conan-transit
137 repository is not compatible with the latest conan, so you'll need to install
138 it locally from the git repository:
139
140 ```console
141 $ git clone https://github.com/lasote/conan-sdl2.git # temporary, I hope hope hope
142 $ cd conan-sdl2
143 $ conan export SDL2/2.0.5@lasote/stable
144 ```
145
146 ### Building
147
148 Execute the following commands inside of the `nothing` directory:
149
150 ```console
151 $ conan install --build missing --install-folder build
152 $ cd build
153 $ cmake .. -G "Visual Studio 15 2017 Win64"
154 ```
155
156 After that, build the `build/nothing.sln` file with Visual Studio.
157
158 ## Support
159
160 You can support my work via
161
162 - Twitch channel: https://www.twitch.tv/subs/tsoding
163 - Patreon: https://www.patreon.com/tsoding
164
165 [conan]: https://www.conan.io/
166 [conan-sdl2]: https://bintray.com/conan/conan-transit/SDL2%3Alasote/2.0.5%3Astable
167 [visual-studio]: https://www.visualstudio.com/
168 [svg2rects.py]: ./devtools/svg2rects.py
169 [./levels/]: ./levels/
170 [./levels/Makefile]: ./levels/Makefile
171 [gcc]: https://gcc.gnu.org/
172 [cmake]: https://cmake.org/
173 [libsdl2-dev]: https://www.libsdl.org/
174 [libsdl2-mixer-dev]: https://www.libsdl.org/projects/SDL_mixer/
175 [python3]: https://www.python.org/
176 [NixOS]: https://nixos.org/
177 [default.nix]: ./default.nix
178 [build-on-windows]: #build-on-windows
179 [inotify-tools]: https://github.com/rvoicilas/inotify-tools