README.md 2.32 KB
Newer Older
Rahix's avatar
Rahix committed
1
2
3
4
# What is this?
This will at some point be a game, written in Rust, using WebAssembly.

# Hacking
Rahix's avatar
Rahix committed
5
- [Project Structure](#project-structure)
Rahix's avatar
Rahix committed
6
7
- [Build Dependencies](#build-dependencies)
- [Development Environment](#development-environment)
Rahix's avatar
Rahix committed
8
9
10
11

## Project Structure
The project is mainly split into two parts:  The game logic, written in Rust,
living in `src/`, and the web-frontend in `www/src/` which is mainly HTML and
12
13
SCSS + a bit of JS glue code.  Additionally, some helper custom javascript
functions which are called in rust are defined in `rust-web-modules/`.
Rahix's avatar
Rahix committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#### `src/` - Rust Game Logic
- `src/main.rs`: Entry-point, world setup, and game loop
- `src/utils.rs`: Javascript-Gluecode, e.g. a `request_animation_frame()`
  wrapper.
- `src/colliders.rs`: `ncollide2d` integration
- `src/components/`: Components and closely related systems
- `src/resources/`: Game-global resources like a global clock

#### `www/src/` - Web Frontend
- `www/src/index.html`: Main HTML Document
- `www/src/styles.scss`: Stylesheet using Sass
- `www/src/_rc3-*`: Styles and Fonts for RC3

Rahix's avatar
Rahix committed
28
29
30
31
32
33
34
35
36
37
38
39
40
## Build Dependencies
Not quite sure what the dependencies really are, please add
as you find out:

- `rustc` & `cargo` (duh ... best install them via [`rustup`])
- [`wasm-pack`]
- `npm`
- (optional: [`cargo-watch`])

[`wasm-pack`]: https://github.com/rustwasm/wasm-pack
[`rustup`]: https://rustup.rs/
[`cargo-watch`]: https://github.com/passcod/cargo-watch

Rahix's avatar
Rahix committed
41
42
43
44
45
46
With those dependencies installed, run

```bash
cd www/ && npm install
```

Rahix's avatar
Rahix committed
47
48
49
50
51
52
53
54
55
## Development Environment
Open two shell sessions, one for the rust build and one for the webpack dev
server:

```bash
# For Rust:
cargo watch -s "wasm-pack build" --watch src
# or, if you don't use cargo-watch, just run
wasm-pack build
Rahix's avatar
Rahix committed
56
57
58

# For the webpack dev server:
cd www/
59
npm run rust-web-modules
Rahix's avatar
Rahix committed
60
npm run start
Rahix's avatar
Rahix committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
```

Then point your browser to `http://localhost:8080` and start hacking!  The
website will automatically reload when any changes are done to the web sources
(`www/src/`) or the Rust sources (`src/`).

---

# License
Licensed under the GNU General Public License v3.0 ([COPYING](COPYING) or
<https://www.gnu.org/licenses/gpl-3.0-standalone.html>).

## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, shall be licensed as above, without any
additional terms or conditions.