Skip to content

Commit

Permalink
Add a new chapter in the pong tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenoit committed Oct 23, 2018
1 parent f1460f9 commit 59cccc3
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 11 deletions.
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [Opening (and closing!) a window](./pong-tutorial/pong-tutorial-01.md)
* [Drawing the paddles](./pong-tutorial/pong-tutorial-02.md)
* [Moving the paddles](./pong-tutorial/pong-tutorial-03.md)
* [Making a ball move and bounce](./pong-tutorial/pong-tutorial-04.md)
* [Call for contribution](./pong-tutorial/contribution.md)
* [Animation](./animation.md)
* [Interpolation](./animation/interpolation.md)
Expand Down
14 changes: 7 additions & 7 deletions book/src/pong-tutorial/pong-tutorial-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Then, in `main.rs` declare a module:
mod pong;
```

And in main.rs, at the top of the file, add this import:
And in main.rs, below the module declaration and before the main, add this import:

```rust,ignore
use pong::Pong;
Expand Down Expand Up @@ -252,7 +252,7 @@ general as it makes operations like rotation easier.
# }
# struct Paddle;
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
# impl Paddle {
# fn new(side: Side) -> Paddle { Paddle }
Expand Down Expand Up @@ -337,7 +337,7 @@ this by adding the following line before `initialise_paddles(world)` in the
# extern crate amethyst;
# struct Paddle;
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
# fn register() {
# let mut world = amethyst::ecs::World::new();
Expand Down Expand Up @@ -484,7 +484,7 @@ Heading back to the code, we need to add this snippet after loading the texture.
# &texture_storage,
# )
# };
// `texture_id` is a application defined ID given to the texture to store in
// `texture_id` is an application-defined ID given to the texture to store in
// the `World`. This is needed to link the texture to the sprite_sheet.
let texture_id = 0;
let mut material_texture_set = world.write_resource::<MaterialTextureSet>();
Expand All @@ -493,7 +493,7 @@ material_texture_set.insert(texture_id, texture_handle);
```

The `MaterialTextureSet` is yet another `resource`, which is a bi-directional
map between an application defined texture ID and the handle of the loaded
map between an application-defined texture ID and the handle of the loaded
texture. In other words, this allows us to associate a specific global ID to
our texture. As you will see in a moment, `SpriteSheet`s are linked to textures
through this ID. Since we only have one sprite sheet, we can just use `0` as the
Expand Down Expand Up @@ -539,7 +539,7 @@ file containing the sprites' positions and the texture ID, and create a
nicely packaged `SpriteSheet` struct. It is this struct that we will be using
to actually draw stuff on the screen.

Please note that the order of sprites declared in the sprite sheet file
Please note that the order of sprites declared in the sprite sheet file
is also significant, as sprites are referenced by the index in
the vector. If you're wondering about the ball sprite, it does exist on the
image, but we will get to it in a later part of the tutorial.
Expand Down Expand Up @@ -630,7 +630,7 @@ all together in the `on_start()` method:
# use amethyst::ecs::World;
# struct Paddle;
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
# fn initialise_paddles(world: &mut World, spritesheet: SpriteSheetHandle) { }
# fn initialise_camera(world: &mut World) { }
Expand Down
7 changes: 4 additions & 3 deletions book/src/pong-tutorial/pong-tutorial-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ use amethyst::input::InputHandler;
# side: Side,
# }
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
pub struct PaddleSystem;
impl<'s> System<'s> for PaddleSystem {
Expand Down Expand Up @@ -239,7 +240,7 @@ component of the transform's translation.
# side: Side,
# }
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
# pub struct PaddleSystem;
# impl<'s> System<'s> for PaddleSystem {
Expand Down Expand Up @@ -297,7 +298,7 @@ Our run function should now look something like this:
# side: Side,
# }
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
# pub struct PaddleSystem;
# impl<'s> System<'s> for PaddleSystem {
Expand Down
Loading

0 comments on commit 59cccc3

Please sign in to comment.