Skip to content

Commit 4a40e64

Browse files
authored
Merge pull request #43 from CleanCut/fixes
Fix sprite preset paths, make level_creator work when installed
2 parents 21d79cd + 123a11a commit 4a40e64

File tree

7 files changed

+72
-31
lines changed

7 files changed

+72
-31
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
tests:
1616
name: Tests
1717
runs-on: ${{ matrix.os }}
18-
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
18+
continue-on-error: ${{ matrix.toolchain == 'nightly' || matrix.toolchain == 'beta' }}
1919
strategy:
2020
fail-fast: false
2121
matrix:

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<!-- next-header -->
22
## [Unreleased] - ReleaseDate
33

4+
### New
5+
6+
- The `level_creator` example can be installed globally with `cargo install rusty_engine --example level_creator` and run in the root of your own project with `level_creator`.
7+
8+
### Fixed
9+
10+
- Fixed sprite preset paths which broke due to the changes in 5.0.2
11+
412
## [5.0.2] - 2022-04-29
513

614
### New

examples/collider.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
//! To run this code, clone the rusty_engine repository and run the command:
1+
//! To run this code in your own project, first install it:
22
//!
3-
//! cargo run --release --example collider path/to/some_image.png
3+
//! cargo install rusty_engine --example collider
44
//!
5-
//! ...where that image is somewhere under assets/
5+
//! Then run it in your own project (with the asset pack present) with an image
6+
//! placed somewhere in your `assets/` directory.
7+
//!
8+
//! collider assets/some_image.png
9+
//!
10+
//! Of course, you could also clone the rusty_engine repository, place your image
11+
//! in `assets/` somewhere, and run:
12+
//!
13+
//! cargo run --release --example collider assets/some_image.png
614
715
use std::path::PathBuf;
816

examples/level_creator.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
//! To run this code, clone the rusty_engine repository and run the command:
1+
//! To run this code in your own project, first install it:
2+
//!
3+
//! cargo install rusty_engine --example level_creator
4+
//!
5+
//! Then run it in your own project (with the asset pack present).
6+
//!
7+
//! level_creator
8+
//!
9+
//! Alterantely, clone the rusty_engine repository and run the command:
210
//!
311
//! cargo run --release --example level_creator
412
@@ -27,6 +35,17 @@ impl Default for GameState {
2735
const MAX_LAYER: f32 = 900.0;
2836

2937
fn main() {
38+
// Some trickiness to make assets load relative to the current working directory, which
39+
// makes using it from `cargo install rusty_engine --example collider` possible.
40+
// This takes advantage of bevy's hard-coded asset loading behavior, and may break in future
41+
// bevy versions.
42+
std::env::set_var(
43+
"CARGO_MANIFEST_DIR",
44+
std::env::var("PWD").unwrap_or_default(),
45+
);
46+
// Make engine logging a bit quieter since we've got console instructions we want folks to see.
47+
std::env::set_var("RUST_LOG", "error");
48+
3049
let mut game = Game::new();
3150

3251
println!(

scenarios/extreme_drivers_ed.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ Navigate a driving course full of obstacles. Carefully avoid the obstacles while
1212

1313
## Level Setup
1414

15-
It can be _really_ tedious to set up dozens of obstacles via code and guessing coordinates. Instead, clone the `rusty_engine` repository and use the `level_creator` example to place several dozen obstacles and emit the level code for you to copy-and-paste into your own project.
15+
It can be _really_ tedious to set up dozens of obstacles via code and guessing coordinates. Instead, use `rusty_engine`'s `level_creator` example to place several dozen obstacles and emit the level code for you to copy-and-paste into your own project.
1616

1717
The sprite preset `SpritePreset::RollingHoleStart` are the goals for collecting (you _want_ to run into them). All other sprites will be obstacles.
1818

1919
```
20-
git clone https://github.com/CleanCut/rusty_engine.git
21-
cd rusty_engine
22-
cargo run --release --example level_creator
20+
# You only need to install the level creator once
21+
cargo install rusty_engine --example level_creator
22+
23+
# Then use it to create a level
24+
level_creator
2325
```
2426

2527
## Engine Initialization

src/sprite.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,26 @@ impl SpritePreset {
217217
/// `impl From<SpritePreset> for PathBuf` implementation.
218218
pub fn filepath(&self) -> PathBuf {
219219
match self {
220-
SpritePreset::RacingBarrelBlue => "racing/barrel_blue.png",
221-
SpritePreset::RacingBarrelRed => "racing/barrel_red.png",
222-
SpritePreset::RacingBarrierRed => "racing/barrier_red.png",
223-
SpritePreset::RacingBarrierWhite => "racing/barrier_white.png",
224-
SpritePreset::RacingCarBlack => "racing/car_black.png",
225-
SpritePreset::RacingCarBlue => "racing/car_blue.png",
226-
SpritePreset::RacingCarGreen => "racing/car_green.png",
227-
SpritePreset::RacingCarRed => "racing/car_red.png",
228-
SpritePreset::RacingCarYellow => "racing/car_yellow.png",
229-
SpritePreset::RacingConeStraight => "racing/cone_straight.png",
230-
SpritePreset::RollingBallBlue => "rolling/ball_blue.png",
231-
SpritePreset::RollingBallBlueAlt => "rolling/ball_blue_alt.png",
232-
SpritePreset::RollingBallRed => "rolling/ball_red.png",
233-
SpritePreset::RollingBallRedAlt => "rolling/ball_red_alt.png",
234-
SpritePreset::RollingBlockCorner => "rolling/block_corner.png",
235-
SpritePreset::RollingBlockNarrow => "rolling/block_narrow.png",
236-
SpritePreset::RollingBlockSmall => "rolling/block_small.png",
237-
SpritePreset::RollingBlockSquare => "rolling/block_square.png",
238-
SpritePreset::RollingHoleEnd => "rolling/hole_end.png",
239-
SpritePreset::RollingHoleStart => "rolling/hole_start.png",
220+
SpritePreset::RacingBarrelBlue => "sprite/racing/barrel_blue.png",
221+
SpritePreset::RacingBarrelRed => "sprite/racing/barrel_red.png",
222+
SpritePreset::RacingBarrierRed => "sprite/racing/barrier_red.png",
223+
SpritePreset::RacingBarrierWhite => "sprite/racing/barrier_white.png",
224+
SpritePreset::RacingCarBlack => "sprite/racing/car_black.png",
225+
SpritePreset::RacingCarBlue => "sprite/racing/car_blue.png",
226+
SpritePreset::RacingCarGreen => "sprite/racing/car_green.png",
227+
SpritePreset::RacingCarRed => "sprite/racing/car_red.png",
228+
SpritePreset::RacingCarYellow => "sprite/racing/car_yellow.png",
229+
SpritePreset::RacingConeStraight => "sprite/racing/cone_straight.png",
230+
SpritePreset::RollingBallBlue => "sprite/rolling/ball_blue.png",
231+
SpritePreset::RollingBallBlueAlt => "sprite/rolling/ball_blue_alt.png",
232+
SpritePreset::RollingBallRed => "sprite/rolling/ball_red.png",
233+
SpritePreset::RollingBallRedAlt => "sprite/rolling/ball_red_alt.png",
234+
SpritePreset::RollingBlockCorner => "sprite/rolling/block_corner.png",
235+
SpritePreset::RollingBlockNarrow => "sprite/rolling/block_narrow.png",
236+
SpritePreset::RollingBlockSmall => "sprite/rolling/block_small.png",
237+
SpritePreset::RollingBlockSquare => "sprite/rolling/block_square.png",
238+
SpritePreset::RollingHoleEnd => "sprite/rolling/hole_end.png",
239+
SpritePreset::RollingHoleStart => "sprite/rolling/hole_start.png",
240240
}
241241
.into()
242242
}

tutorial/src/65-sprite-collider.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ If you create a new sprite using your own image, and you want it to produce `Col
3737
Creating colliders from scratch is quite tedius, so there is an "example" program called `collider` that you can use to create a collider! To run `collider`, clone the [`rusty_engine`](https://github.com/CleanCut/rusty_engine/) repository, place your image file in the `assets` directory (let's call it `db.png`), and then run:
3838

3939
```text
40-
$ cargo run --release --example collider assets/db.png
40+
# Install the collider example (you only need to do this once)
41+
$ cargo install rusty_engine --example collider
42+
43+
# Inside your project, run the collider example
44+
$ collider assets/db.png
4145
```
4246

43-
Then follow the directions to create (or re-create) a collider and write it to a file.
47+
Then follow the example's console instructions to create (or re-create) a collider and write it to a file.
4448

4549
<img width="1392" alt="Screen Shot 2021-12-26 at 10 45 40 PM" src="https://user-images.githubusercontent.com/5838512/147438683-c8af2db7-66dd-463c-a269-d03f37869496.png">
4650

0 commit comments

Comments
 (0)