- commit
- c5ce2692a4d7ec156f920aa1a9910f4114ba47a7
- parent
- 624409170c5b5a7eac9c772b07bd6916a8901187
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-02-22 21:56
README: tour of the code
Diffstat
| M | README.md | 22 | ++++++++++++++++++++++ |
1 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
@@ -74,6 +74,28 @@ there is a good chance that it will improve if you reduce the window size. 74 74 The aspect ratio of pixels depends on the font. You can adjust 75 75 `win::ASPECT_RATIO` to compensate for that. 76 76 -1 77 ## Brief tour of the code -1 78 -1 79 - `src/main.rs` contains the main loop. -1 80 - `src/game.rs` contains most of the game logic. -1 81 - `src/input.rs`, `src/random.rs`, and `src/term,rs` wrap unsafe libc functions -1 82 for low level functionality. -1 83 - `src/enemies.rs` contains all the enemy types as well as the waves in which -1 84 they appear. -1 85 - `src/sprites.rs` contains all graphics. The sprites are stored in -1 86 [ppm](https://en.wikipedia.org/wiki/Netpbm_format) files and converted to -1 87 rust arrays by the `include_ppm!()` macro. That way all graphics are included -1 88 in the binary. The color of the first pixel in a sprite is considered -1 89 transparent. -1 90 - `src/win.rs` contains some drawing primitives as well as the conversion -1 91 between logical positions and screen pixels. -1 92 -1 93 Most game logic is expressed as `f32`. Positions represet the logical center of -1 94 objects. When drawing to the screen, the `f32` positions are converted to -1 95 `usize` pixels. Game logic is mostly independent of pixels though. The only -1 96 exceptions are that enemy spawn and despawn outside of the screen, so they -1 97 depend on the screen size. -1 98 77 99 ## TODO (patches welcome) 78 100 79 101 - Add more weapons