Skip to content

Commit cd42641

Browse files
committed
resolve conflict
2 parents 5d59a87 + f1f8152 commit cd42641

File tree

12 files changed

+180
-192
lines changed

12 files changed

+180
-192
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,18 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [macos-latest, windows-latest, ubuntu-latest]
23-
toolchain: [stable, beta, nightly]
23+
toolchain: [stable]
2424
include:
2525
- os: macos-latest
2626
MACOS: true
27-
sccache-path: /Users/runner/Library/Caches/Mozilla.sccache
28-
sccache-download-target: apple-darwin
29-
# This can be moved to the "env:" section below once sccache is also working on Windows
30-
rustc_wrapper: sccache
3127
- os: windows-latest
3228
- os: ubuntu-latest
33-
sccache-path: /home/runner/.cache/sccache
34-
sccache-download-target: unknown-linux-musl
35-
# This can be moved to the "env:" section below once sccache is also working on Windows
36-
rustc_wrapper: sccache
3729
env:
3830
RUST_BACKTRACE: full
39-
#RUSTC_WRAPPER: sccache # Can't hard-code this until we've got Windows working, too
40-
RUSTC_WRAPPER: ${{ matrix.rustc_wrapper }}
4131
RUSTV: ${{ matrix.toolchain }}
42-
SCCACHE_CACHE_SIZE: 2G
43-
SCCACHE_DIR: ${{ matrix.sccache-path }}
44-
SCCACHE_TARGET: ${{ matrix.sccache-download-target }}
45-
URL_BASE: https://github.com/mozilla/sccache/releases/download
46-
SCCACHE_VERSION: v0.2.15
47-
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out
4832
steps:
4933
- uses: actions/checkout@v2
5034

51-
- name: Install sccache
52-
run: |
53-
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-$SCCACHE_TARGET
54-
mkdir -p $HOME/.local/bin
55-
curl -L "$URL_BASE/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
56-
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
57-
chmod +x $HOME/.local/bin/sccache
58-
echo "$HOME/.local/bin" >> $GITHUB_PATH
59-
if: matrix.os != 'windows-latest'
60-
6135
- name: Install Linux deps alsa and udev
6236
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
6337
if: runner.os == 'linux'
@@ -72,31 +46,32 @@ jobs:
7246
override: true
7347

7448
- name: Fetch cargo registry cache
75-
uses: actions/cache@v2
49+
uses: actions/cache@v3
7650
continue-on-error: false
7751
with:
7852
path: |
79-
~/.cargo/registry
80-
~/.cargo/git
53+
~/.cargo/bin/
54+
~/.cargo/registry/index/
55+
~/.cargo/registry/cache/
56+
~/.cargo/git/db/
57+
target/
8158
Cargo.lock
82-
key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }}
83-
restore-keys: |
84-
${{ runner.os }}-cargo-${{ matrix.toolchain }}-
85-
if: matrix.os != 'windows-latest'
59+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
60+
if: runner.os != 'windows'
8661

87-
- name: Fetch sccache cache
88-
uses: actions/cache@v2
62+
- name: Fetch cargo registry cache (windows)
63+
uses: actions/cache@v3
8964
continue-on-error: false
9065
with:
91-
path: ${{ matrix.sccache-path }}
92-
key: ${{ runner.os }}-sccache-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }}
93-
restore-keys: |
94-
${{ runner.os }}-sccache-${{ matrix.toolchain }}-
95-
if: matrix.os != 'windows-latest'
96-
97-
- name: Start sccache server
98-
run: sccache --start-server
99-
if: matrix.os != 'windows-latest'
66+
path: |
67+
C:\Rust\.cargo\bin
68+
C:\Rust\.cargo\registry\index
69+
C:\Rust\.cargo\registry\cache
70+
C:\Rust\.cargo\git\db
71+
target
72+
Cargo.lock
73+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
74+
if: runner.os == 'windows'
10075

10176
- name: rustfmt & clippy
10277
run: |
@@ -108,7 +83,3 @@ jobs:
10883
- run: cargo test --workspace --all-targets --all-features
10984
env:
11085
MACOS: ${{ matrix.MACOS }} # Used by some tests
111-
112-
- name: Stop sccache server
113-
run: sccache --stop-server || true
114-
if: matrix.os != 'windows-latest'

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
<!-- next-header -->
22
## [Unreleased] - ReleaseDate
33

4+
## Improved
5+
6+
- Updated to `bevy 0.8` and `bevy_prototype_lyon 0.6` under the hood, which resolves the occasional stuttering problem.
7+
8+
9+
## [5.1.0] - 2022-06-18
10+
11+
### Improved
12+
13+
- Fixed `CollisionPair::either_contains` to use `.contains` instead of `==`, contributed by [@etnt](https://github.com/etnt) in [#51](https://github.com/CleanCut/rusty_engine/pull/51)
14+
- Added `CollisionPair::either_equals_to` which uses `==`, contributed by [@etnt](https://github.com/etnt) in [#51](https://github.com/CleanCut/rusty_engine/pull/51)
15+
- Fixed documentation for a few fields of the `Engine` struct which were in the wrong place.
16+
- Improved CI caching. Builds should now generally complete in under 3 minutes.
17+
18+
## [5.0.6] - 2022-05-19
19+
420
### Improved
521

622
- Made a pass through the API documentation and Tutorials, clarifying, correcting, and filling in blanks.
7-
- Updated to `bevy 0.8` and `bevy_prototype_lyon 0.6` under the hood, which resolves the occasional stuttering problem.
23+
- Reduced the debug level of logging the window dimension resizing from info to debug
824

925
## [5.0.5] - 2022-05-10
1026

@@ -256,7 +272,9 @@ specifying a path to a sound file relative to `assets/audio`.
256272

257273
[Bevy]: https://bevyengine.org
258274
<!-- next-url -->
259-
[Unreleased]: https://github.com/CleanCut/rusty_engine/compare/v5.0.5...HEAD
275+
[Unreleased]: https://github.com/CleanCut/rusty_engine/compare/v5.1.0...HEAD
276+
[5.1.0]: https://github.com/CleanCut/rusty_engine/compare/v5.0.6...v5.1.0
277+
[5.0.6]: https://github.com/CleanCut/rusty_engine/compare/v5.0.5...v5.0.6
260278
[5.0.5]: https://github.com/CleanCut/rusty_engine/compare/v5.0.4...v5.0.5
261279
[5.0.4]: https://github.com/CleanCut/rusty_engine/compare/v5.0.3...v5.0.4
262280
[5.0.3]: https://github.com/CleanCut/rusty_engine/compare/v5.0.2...v5.0.3

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rusty_engine"
3-
version = "5.0.5"
3+
version = "5.1.0"
44
description = "Learn Rust with a simple, cross-platform, 2D game engine."
55
edition = "2021"
66
homepage = "https://github.com/CleanCut/rusty_engine"

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Add `rusty_engine` as a dependency
5858

5959
```toml
6060
# In your [dependencies] section of Cargo.toml
61-
rusty_engine = "5.0.5"
61+
rusty_engine = "5.1.0"
6262
```
6363

6464
Write your game!
@@ -112,6 +112,13 @@ Run your game with `cargo run --release`!
112112

113113
See also the [tutorial](https://cleancut.github.io/rusty_engine/), [game scenarios](https://github.com/CleanCut/rusty_engine/tree/main/scenarios), [code examples](https://github.com/CleanCut/rusty_engine/tree/main/examples) and the [API documentation](https://docs.rs/rusty_engine/latest/rusty_engine/)
114114

115+
## Student Showcase
116+
117+
Show off the project you made with Rusty Engine! Learning Rust can be fun. 😄 Just [send me a link](https://agileperception.com/contact) and I'll add it to the list!
118+
119+
- [Rusty Asteroids](https://github.com/etnt/rusty-asteroids) by [@etnt](https://github.com/etnt)
120+
- [Rusty Breakout](https://github.com/etnt/rusty-breakout) by [@etnt](https://github.com/etnt)
121+
115122
## Contribution
116123

117124
All software contributions are assumed to be dual-licensed under MIT/Apache-2. All asset contributions must be under licenses compatible with the software license, and explain their license(s) in a `README.md` file in the same directory as the source files.

examples/scenarios/car_shoot.rs

Lines changed: 48 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,46 @@
44
55
use rand::prelude::*;
66
use rusty_engine::prelude::*;
7-
use SpritePreset::*; // The SpritePreset enum was imported from rusty_engine::prelude
87

9-
#[derive(Default)]
108
struct GameState {
11-
marbles_left: Vec<String>,
9+
marble_labels: Vec<String>,
1210
cars_left: i32,
1311
spawn_timer: Timer,
1412
}
1513

1614
fn main() {
1715
let mut game = Game::new();
1816

19-
// Set the title of the window to be Car Shooter
17+
// Initial game state
18+
let game_state = GameState {
19+
marble_labels: vec!["marble1".into(), "marble2".into(), "marble3".into()],
20+
cars_left: 25,
21+
spawn_timer: Timer::from_seconds(0.0, false),
22+
};
23+
24+
// Set the title of the window
2025
game.window_settings(WindowDescriptor {
2126
title: "Car Shoot".into(),
2227
..Default::default()
2328
});
2429

25-
// Create the player
26-
let player = game.add_sprite("player", RacingBarrierRed);
30+
// Start the music
31+
game.audio_manager.play_music(MusicPreset::Classy8Bit, 0.1);
32+
33+
//
34+
let player = game.add_sprite("player", SpritePreset::RacingBarrierRed);
2735
player.rotation = UP;
2836
player.scale = 0.5;
2937
player.translation.y = -325.0;
3038
player.layer = 10.0;
3139

32-
// Start the music
33-
game.audio_manager.play_music(MusicPreset::Classy8Bit, 0.1);
34-
35-
let mut game_state = GameState::default();
36-
37-
// Marbles left. We'll use these strings as labels for sprites. If they are present in the
38-
// vector, then they are available to be shot out of the marble gun. If they are not present,
39-
// then they are currently in play.
40-
game_state.marbles_left = vec!["marble1".into(), "marble2".into(), "marble3".into()];
41-
42-
// Cars left in level - each integer represents a car that will be spawned
43-
game_state.cars_left = 25;
44-
let cars_left = game.add_text("cars left", "Cars left: 25");
40+
let cars_left = game.add_text("cars left", format!("Cars left: {}", game_state.cars_left));
4541
cars_left.translation = Vec2::new(540.0, -320.0);
4642

4743
game.add_logic(game_logic);
4844
game.run(game_state);
4945
}
5046

51-
const MARBLE_SPEED: f32 = 600.0;
52-
const CAR_SPEED: f32 = 300.0;
53-
5447
fn game_logic(engine: &mut Engine, game_state: &mut GameState) {
5548
// Handle marble gun movement
5649
let player = engine.sprites.get_mut("player").unwrap();
@@ -61,96 +54,90 @@ fn game_logic(engine: &mut Engine, game_state: &mut GameState) {
6154

6255
// Shoot marbles!
6356
if engine.mouse_state.just_pressed(MouseButton::Left) {
64-
// Create the marble
65-
if let Some(label) = game_state.marbles_left.pop() {
66-
let marble = engine.add_sprite(label, RollingBallBlue);
67-
marble.translation.y = -275.0;
57+
if let Some(label) = game_state.marble_labels.pop() {
58+
let marble = engine.add_sprite(label, SpritePreset::RollingBallBlue);
6859
marble.translation.x = player_x;
60+
marble.translation.y = -275.0;
6961
marble.layer = 5.0;
7062
marble.collision = true;
71-
engine.audio_manager.play_sfx(SfxPreset::Impact2, 0.7);
63+
engine.audio_manager.play_sfx(SfxPreset::Impact2, 0.4);
7264
}
7365
}
7466

7567
// Move marbles
76-
for marble in engine
68+
const MARBLE_SPEED: f32 = 600.0;
69+
engine
7770
.sprites
7871
.values_mut()
79-
.filter(|marble| marble.label.starts_with("marble"))
80-
{
81-
marble.translation.y += MARBLE_SPEED * engine.delta_f32;
82-
}
72+
.filter(|sprite| sprite.label.starts_with("marble"))
73+
.for_each(|marble| marble.translation.y += MARBLE_SPEED * engine.delta_f32);
8374

8475
// Move cars across the screen
85-
for car in engine
76+
const CAR_SPEED: f32 = 250.0;
77+
engine
8678
.sprites
8779
.values_mut()
88-
.filter(|car| car.label.starts_with("car"))
89-
{
90-
car.translation.x += CAR_SPEED * engine.delta_f32;
91-
}
80+
.filter(|sprite| sprite.label.starts_with("car"))
81+
.for_each(|car| car.translation.x += CAR_SPEED * engine.delta_f32);
9282

9383
// Clean up sprites that have gone off the screen
94-
let mut labels_to_delete = vec![];
95-
for sprite in engine.sprites.values() {
84+
let mut labels_to_delete = Vec::new();
85+
for (label, sprite) in engine.sprites.iter() {
9686
if sprite.translation.y > 400.0 || sprite.translation.x > 750.0 {
97-
labels_to_delete.push(sprite.label.clone());
87+
labels_to_delete.push(label.clone());
9888
}
9989
}
10090
for label in labels_to_delete {
10191
engine.sprites.remove(&label);
10292
if label.starts_with("marble") {
103-
game_state.marbles_left.push(label);
93+
game_state.marble_labels.push(label);
10494
}
10595
}
10696

10797
// Spawn cars
10898
if game_state.spawn_timer.tick(engine.delta).just_finished() {
10999
// Reset the timer to a new value
110100
game_state.spawn_timer = Timer::from_seconds(thread_rng().gen_range(0.1..1.25), false);
111-
// Get the next car
101+
// Get the new car
112102
if game_state.cars_left > 0 {
113103
game_state.cars_left -= 1;
104+
let text = engine.texts.get_mut("cars left").unwrap();
105+
text.value = format!("Cars left: {}", game_state.cars_left);
114106
let label = format!("car{}", game_state.cars_left);
115-
let cars_left_text = engine.texts.get_mut("cars left").unwrap();
116-
cars_left_text.value = format!("Cars left: {}", game_state.cars_left);
107+
use SpritePreset::*;
117108
let car_choices = vec![
118109
RacingCarBlack,
119110
RacingCarBlue,
120111
RacingCarGreen,
121112
RacingCarRed,
122113
RacingCarYellow,
123114
];
124-
let car = engine.add_sprite(
125-
label,
126-
car_choices
127-
.iter()
128-
.choose(&mut thread_rng())
129-
.unwrap()
130-
.clone(),
131-
);
115+
let sprite_preset = car_choices
116+
.iter()
117+
.choose(&mut thread_rng())
118+
.unwrap()
119+
.clone();
120+
let car = engine.add_sprite(label, sprite_preset);
132121
car.translation.x = -740.0;
133122
car.translation.y = thread_rng().gen_range(-100.0..325.0);
134123
car.collision = true;
135124
}
136125
}
137126

138-
// Collide with things
127+
// Handle collisions
139128
for event in engine.collision_events.drain(..) {
140129
if event.state.is_end() {
141130
continue;
142131
}
143132
if !event.pair.one_starts_with("marble") {
144133
continue;
145134
}
146-
engine.sprites.remove(&event.pair.0);
147-
engine.sprites.remove(&event.pair.1);
148-
if event.pair.0.starts_with("marble") {
149-
game_state.marbles_left.push(event.pair.0);
150-
}
151-
if event.pair.1.starts_with("marble") {
152-
game_state.marbles_left.push(event.pair.1);
135+
for label in [event.pair.0, event.pair.1] {
136+
engine.sprites.remove(&label);
137+
if label.starts_with("marble") {
138+
game_state.marble_labels.push(label);
139+
}
140+
engine.audio_manager.play_sfx(SfxPreset::Confirmation1, 0.2);
153141
}
154-
engine.audio_manager.play_sfx(SfxPreset::Confirmation1, 0.5);
155142
}
156143
}

0 commit comments

Comments
 (0)