Skip to content

Commit

Permalink
Merge amethyst#899
Browse files Browse the repository at this point in the history
899: add imports to pong-tutorial-03.md and make pong.rs things pub r=jojolepro a=jackmott

This addresses amethyst#898 , I added the necessary includes to paddle.rs in the code examples. As well, on page 2, I made the elements that need to be public, pub, which I think will avoid confusion vs making them private then having to notice the offhand comment on page 3 to change them to public.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/amethyst/amethyst/899)
<!-- Reviewable:end -->


Co-authored-by: jack mott <[email protected]>
  • Loading branch information
bors[bot] and jackmott committed Aug 26, 2018
2 parents 83719f0 + 496ba3d commit 55999b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions book/src/pong-tutorial/pong-tutorial-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ that will determine what is rendered on screen. It behaves just like a
real life camera: it records a specific part of the world and can be
moved around at will.

First, let's define some constants:
First, let's define some constants. We will make them public for use in other
modules later:

```rust,no_run,noplaypen
const ARENA_HEIGHT: f32 = 100.0;
const ARENA_WIDTH: f32 = 100.0;
pub const ARENA_HEIGHT: f32 = 100.0;
pub const ARENA_WIDTH: f32 = 100.0;
```

These constants will determine the size of our arena.
Expand Down Expand Up @@ -153,16 +154,17 @@ much better from then on, we promise!

## Our first Component

In `pong.rs` let's create our first `Component`, a definition of a paddle.
In `pong.rs` let's create our first `Component`, a definition of a paddle. We
will make `Side` and `Paddle` public for use in other modules later.

```rust,no_run,noplaypen
#[derive(PartialEq, Eq)]
enum Side {
pub enum Side {
Left,
Right,
}
struct Paddle {
pub struct Paddle {
pub side: Side,
pub width: f32,
pub height: f32,
Expand Down
6 changes: 4 additions & 2 deletions book/src/pong-tutorial/pong-tutorial-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ use amethyst::input::InputHandler;
# impl amethyst::ecs::Component for Paddle {
# type Storage = amethyst::ecs::VecStorage<Paddle>;
# }
pub struct PaddleSystem;
impl<'s> System<'s> for PaddleSystem {
Expand Down Expand Up @@ -139,8 +138,11 @@ impl<'s> System<'s> for PaddleSystem {
}
}
```
Note: You will also need to add a `use` statement to bring in `Paddle` and `Side` from pong.rs:

Note: We had to make our Paddle and Side public in `pong.rs`
```rust,ignore
use pong::{Paddle, Side, ARENA_HEIGHT, PADDLE_HEIGHT};
```

Now lets add this system to our `GameDataBuilder` in `main.rs`:

Expand Down

0 comments on commit 55999b7

Please sign in to comment.