Skip to content

Commit 78700de

Browse files
committed
Placeholder for C74.
1 parent 73590f0 commit 78700de

File tree

132 files changed

+15579
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+15579
-1
lines changed

Cargo.lock

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ members = [
8282
"chapter-70-missiles",
8383
"chapter-71-logging",
8484
"chapter-72-textlayers",
85-
"chapter-73-systems"
85+
"chapter-73-systems",
86+
"chapter-74-darkcity"
8687
]
8788

8889
[profile.dev]

book/src/chapter_74.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# One Night in the City
2+
3+
---
4+
5+
***About this tutorial***
6+
7+
*This tutorial is free and open source, and all code uses the MIT license - so you are free to do with it as you like. My hope is that you will enjoy the tutorial, and make great games!*
8+
9+
*If you enjoy this and would like me to keep writing, please consider supporting [my Patreon](https://www.patreon.com/blackfuture).*
10+
11+
---
12+
13+
The next level of the game is a dark elven city. The design document is a bit sparse on details, but here's what we know:
14+
15+
* It eventually leads to a portal to the Abyss.
16+
* Dark elves are infighty, back-stabbing maniacs and should behave as such.
17+
* Dark elven cities are surprisingly city-like, just deep underground.
18+
* Lighting will be important.
19+
20+
## Generating a basic city
21+
22+
The `level_builder` function in `map_builder/mod.rs` controls which map algorithm is called for a given level. Add a placeholder entry for a new map type:
23+
24+
```rust
25+
pub fn level_builder(new_depth: i32, width: i32, height: i32) -> BuilderChain {
26+
rltk::console::log(format!("Depth: {}", new_depth));
27+
match new_depth {
28+
1 => town_builder(new_depth, width, height),
29+
2 => forest_builder(new_depth, width, height),
30+
3 => limestone_cavern_builder(new_depth, width, height),
31+
4 => limestone_deep_cavern_builder(new_depth, width, height),
32+
5 => limestone_transition_builder(new_depth, width, height),
33+
6 => dwarf_fort_builder(new_depth, width, height),
34+
7 => mushroom_entrance(new_depth, width, height),
35+
8 => mushroom_builder(new_depth, width, height),
36+
9 => mushroom_exit(new_depth, width, height),
37+
10 => dark_elf_city(new_depth, width, height),
38+
_ => random_builder(new_depth, width, height)
39+
}
40+
}
41+
```
42+
43+
At the top of the same file, add imports for a new builder module:
44+
45+
```rust
46+
mod dark_elves;
47+
use dark_elves::*;
48+
```
49+
50+
And create the new `map_builders/dark_elves.rs` file with a placeholder builder in it:
51+
52+
```rust
53+
use super::{BuilderChain, XStart, YStart, AreaStartingPosition,
54+
CullUnreachable, VoronoiSpawning,
55+
AreaEndingPosition, XEnd, YEnd, BspInteriorBuilder };
56+
57+
pub fn dark_elf_city(new_depth: i32, width: i32, height: i32) -> BuilderChain {
58+
println!("Dark elf builder");
59+
let mut chain = BuilderChain::new(new_depth, width, height, "Dark Elven City");
60+
chain.start_with(BspInteriorBuilder::new());
61+
chain.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER));
62+
chain.with(CullUnreachable::new());
63+
chain.with(AreaStartingPosition::new(XStart::RIGHT, YStart::CENTER));
64+
chain.with(AreaEndingPosition::new(XEnd::LEFT, YEnd::CENTER));
65+
chain.with(VoronoiSpawning::new());
66+
chain
67+
}
68+
```
69+
70+
That makes a not-at-all city like map (just a bsp interiors map) - but it's a good start. I chose this as the base builder because it doesn't waste any space. I like to imagine that the city is a big warren of interconnected rooms, with the poorer-elf housing in the dangerous spot (at the top). So we'll populate this level with relatively "normal" dark elves, and their slaves.
71+
72+
## Adding some dark elves
73+
74+
75+
76+
---
77+
78+
**The source code for this chapter may be found [here](https://github.com/thebracket/rustrogueliketutorial/tree/master/chapter-74-darkcity)**
79+
80+
81+
[Run this chapter's example with web assembly, in your browser (WebGL2 required)](https://bfnightly.bracketproductions.com/rustbook/wasm/chapter-74-darkcity)
82+
---
83+
84+
Copyright (C) 2019, Herbert Wolverson.
85+
86+
---

chapter-74-darkcity/Cargo.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "chapter-74-darkcity"
3+
version = "0.1.0"
4+
authors = ["Herbert Wolverson <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
rltk = { version = "0.8.0", features = ["serde"] }
11+
specs = { version = "0.16.1", features = ["serde"] }
12+
specs-derive = "0.4.1"
13+
serde= { version = "^1.0.44", features = ["derive"] }
14+
serde_json = "^1.0.44"
15+
lazy_static = "1.4.0"
16+
regex = "1.3.6"

0 commit comments

Comments
 (0)