You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scenarios/car_shoot.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ In your `// game setup goes here` section of `main`...
49
49
In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-game-logic-function.html)...
50
50
51
51
1. Have the "gun barrel" follow the mouse on the X axis by set the `translation.x` of the player sprite to the `x` value of the mouse location.
52
-
- Get a [mutable reference to the player sprite](https://cleancut.github.io/rusty_engine/60-sprite-transform.html#adjusting-an-existing-sprite)
52
+
- Get a [mutable reference to the player sprite](https://cleancut.github.io/rusty_engine/60-sprite-placement.html#adjusting-an-existing-sprite)
53
53
- Get the mouse location via the [mouse state's `location` method](https://cleancut.github.io/rusty_engine/115-mouse-state.html#location)
54
54
- Make a variable `player_x` and set it to the player's current `translation.x` so we can use it later on: `let player_x = player.translation.x;`
55
55
@@ -79,7 +79,7 @@ In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-
79
79
1. For every sprite [value in the hash map](https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.values):
80
80
- check to see if either the `translation.y > 400.0` or the `translation.x > 750.0`. If either of those conditions are true, push a clone of the label onto the `labels_to_delete` vector.
81
81
1. For every label in `labels_to_delete`:
82
-
-[Remove the sprite entry.](https://cleancut.github.io/rusty_engine/60-sprite-transform.html#deleting-a-sprite) The hash map's `remove` method takes an immutable reference to the key type, so if you are looping through the label strings by value, you may need to add a `&` in front of your label variable: `engine.sprites.remove(&label)`
82
+
-[Remove the sprite entry.](https://cleancut.github.io/rusty_engine/60-sprite-placement.html#deleting-a-sprite) The hash map's `remove` method takes an immutable reference to the key type, so if you are looping through the label strings by value, you may need to add a `&` in front of your label variable: `engine.sprites.remove(&label)`
83
83
1. Spawn a car if the `game_state.spawn_timer` just finished! So [tick the spawn timer and check to see if it just finished](https://cleancut.github.io/rusty_engine/250-timer.html#counting-down--finishing) -- if it did, then:
84
84
1. Set `game_state.spawn_timer` to a new `Timer` with a random value between `0.1` and `1.25`
85
85
- Add the `rand` crate as a dependency in your `Cargo.toml`
@@ -88,7 +88,7 @@ In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-
88
88
-[Create a non-repeating `Timer`](https://cleancut.github.io/rusty_engine/250-timer.html#creation) and assign it as the value to `game_state.spawn_timer`
89
89
1. If there are any cars left (check the value of `game_state.cars_left`), then:
90
90
1. Decrement `game_state.cars_left` by one
91
-
1.[Retrieve a mutable reference to the](https://cleancut.github.io/rusty_engine/165-text-transform.html#adjusting-an-existing-text)`Text` we labeled `"cars left"`
91
+
1.[Retrieve a mutable reference to the](https://cleancut.github.io/rusty_engine/165-text-placement.html#adjusting-an-existing-text)`Text` we labeled `"cars left"`
92
92
- Set the `value` to `format!("Cars left: {}", game_state.cars_left)`
93
93
1. Create a label for the current car that starts with `car`: `format!("car{}", game_state.cars_left)` (remember, a label starting with `car` is what the movement code is looking for).
94
94
1. Create a vector of `SpritePreset`s of cars to randomly select from: `let car_choices = vec![SpritePreset::RacingCarBlack, SpritePreset::RacingCarBlue, SpritePreset::RacingCarGreen, SpritePreset::RacingCarRed, SpritePreset::RacingCarYellow];`
@@ -100,7 +100,7 @@ In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-
100
100
1. Now it's time to handle the collisions! For each [`CollisionEvent`](https://docs.rs/rusty_engine/latest/rusty_engine/physics/struct.CollisionEvent.html) in `engine.collision_events`:
101
101
- We only care about the start of collisions, not the ending of them, so if `event.state.is_end()`, then `continue` the loop.
102
102
- Similarly, if one of the event pair's labels _doesn't_ start with `"marble"`, then it's either two marbles or two cars colliding with each other, which we don't care about. So if `!event.pair.one_starts_with("marble")`, then `continue` the loop.
103
-
- At this point we know that one of the pair is a marble and the other is a car, and they both need to be removed. So using the labels in the `event.pair` tuple, [delete both sprites](https://cleancut.github.io/rusty_engine/60-sprite-transform.html#deleting-a-sprite).
103
+
- At this point we know that one of the pair is a marble and the other is a car, and they both need to be removed. So using the labels in the `event.pair` tuple, [delete both sprites](https://cleancut.github.io/rusty_engine/60-sprite-placement.html#deleting-a-sprite).
104
104
- Now that a marble has been "destroyed", we are allowed to shoot it from the gun again, so grab whichever label of the `event.pair` tuple that starts with `"marble"` and [push](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.push) a clone of it back onto the `game_state.marbles_left` vector.
105
105
-[Play a sound effect](https://cleancut.github.io/rusty_engine/210-sfx.html#play) for successfully hitting a car with a marble. Use `SfxPreset::Confirmation1` with a volume of `0.5`
Copy file name to clipboardExpand all lines: scenarios/road_race.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ In your `// game setup goes here` section of `main()`...
36
36
1. Create a sprite using the [`.add_sprite()`](https://cleancut.github.io/rusty_engine/55-sprite-creation.html) method of `Game` (`.add_sprite()` returns a mutable reference to the sprite you can use to access its fields)
37
37
1. Label it `"player1"`
38
38
1. Use the preset `SpritePreset::RacingCarBlue`
39
-
1. Set the following [attributes](https://cleancut.github.io/rusty_engine/60-sprite-transform.html) on the `player1` sprite via the mutable reference:
39
+
1. Set the following [attributes](https://cleancut.github.io/rusty_engine/60-sprite-placement.html) on the `player1` sprite via the mutable reference:
40
40
1. Set `translation.x` to `-500.0` so the car will be near the left side of the screen
41
41
1. Set the player sprite's `layer` to `10.0` so it will be on top of other sprites by default (higher layers are rendered on top of lower layers)
42
42
1. Set the player sprite's `collision` to `true` so that `player1` will detect collisions with other sprites.
Copy file name to clipboardExpand all lines: tutorial/src/115-mouse-state.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ if engine.mouse_state.just_released_any(&[MouseButton::Left, MouseButton::Middle
37
37
38
38
### Location
39
39
40
-
Use the `location` method to see where the mouse is. It returns an `Option<Vec2>`. If `None` is returned, then the mouse pointer isn't in the window. If present, the `Vec2` value is in the same 2D world coordinate system as the rest of the game. See the [section on sprite translation](60-sprite-transform.html) for more info about `Vec2` or the world coordinate system.
40
+
Use the `location` method to see where the mouse is. It returns an `Option<Vec2>`. If `None` is returned, then the mouse pointer isn't in the window. If present, the `Vec2` value is in the same 2D world coordinate system as the rest of the game. See the [section on sprite translation](60-sprite-placement.html) for more info about `Vec2` or the world coordinate system.
41
41
42
42
It is easy to demonstrate `location` by having a sprite appear wherever your mouse is located:
Copy file name to clipboardExpand all lines: tutorial/src/165-text-placement.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# Text Transform
1
+
# Text Placement
2
2
3
-
Text is rendered as an image. This rendering (or re-rendering) happens at the end of the frame after any of the [Value, Font & Font Size](160-text-attributes.md) attributes are changed. However, when _transform_values such as translation, rotation, scale, or layer are changed, the image remains the same and its representation on screen is manipulated in the GPU, which is high performance.
3
+
Text is rendered as an image. This rendering (or re-rendering) happens at the end of the frame after any of the [Value, Font & Font Size](160-text-attributes.md) attributes are changed. However, when values such as translation, rotation, scale, or layer are changed, the image remains the same and its representation on screen is manipulated in the GPU, which is high performance.
4
4
5
-
In short, feel free to change your text's transform attributes every frame without any big hit in performance.
5
+
In short, feel free to change your text's placement attributes every frame without any big hit in performance.
Usually, you will want to leave text at a scale of `1.0`, but if you wish to have text zoom or shrink, modifying the scale has two important advantages compared to changing the font size:
34
34
35
-
- Changing the scale is _fast_. The text image does not need to be re-rendered, and the size transformation is handled all in GPU hardware.
35
+
- Changing the scale is _fast_. The text image does not need to be re-rendered, and the size change is handled all in GPU hardware.
36
36
- Changing the scale doesn't cause weird re-rendering inconsistencies, so animating scale changes looks smooth.
37
37
38
38
The main drawback of changing the scale is that since the font is not re-rendered, it looks pixellated when scaled up. Though, this could be considered as a stylistic plus as well.
@@ -73,7 +73,7 @@ text.translation.x = 0.0;
73
73
player.translation.y = -300.0;
74
74
```
75
75
76
-
NOTE: If you want to adjust your text's transform smoothly, you will need to multiply your change by the frame's delta value. See the [`Engine`](400-engine.md) section for more details.
76
+
NOTE: If you want to adjust your text's placement smoothly, you will need to multiply your change by the frame's delta value. See the [`Engine`](400-engine.md) section for more details.
Copy file name to clipboardExpand all lines: tutorial/src/50-sprite.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Sprite
2
2
3
-
A _sprite_ in Rusty Engine is a 2D image, its transform (translation, rotation, scale), its collider, and other associated metadata. You will use sprites for all the graphics in your game. Many sprites will represent some _thing_. For example, a race car sprite may represent your player character in your game.
3
+
A _sprite_ in Rusty Engine is a 2D image, how it is placed on the screen (translation, rotation, scale, and layer), its collider, and other associated metadata. You will use sprites for all the graphics in your game. Many sprites will represent some _thing_. For example, a race car sprite may represent your player character in your game.
4
4
5
5

Copy file name to clipboardExpand all lines: tutorial/src/60-sprite-placement.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# Transform
1
+
# Sprite Placement
2
2
3
-
A "transform" is a fancy term for the way that you can position and size your sprite. There are four different fields you can use to position and size your sprite:
3
+
There are four different fields you can use to position and size your sprite:
0 commit comments