Skip to content

Commit 03a4720

Browse files
committed
fix typos
1 parent a8b23f9 commit 03a4720

File tree

5 files changed

+36
-27
lines changed

5 files changed

+36
-27
lines changed

doc/collision_detection.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ larger than the player's radius:
1414

1515
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/collision/src/Hexagon.elm", lines="110:127" %}{% endcodesnippet %}
1616

17-
With this function we can extend our `isGameOver`-rule:
17+
With this function we can extend our `isGameOver` rule:
1818

1919
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/collision/src/Hexagon.elm", lines="146:149" %}{% endcodesnippet %}
2020

doc/controls.adoc

+11-9
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,36 @@ which provides a model that holds the current state of the keyboard.
99
== Model
1010

1111
We first set up the model for the `Game`, which contains the `Player` with the Player's position
12-
(represented by an angle), the current 'direction' in which the player is moving, and a `keyboardModel`:
12+
(represented by an angle), the current `direction` in which the player is moving, and a `keyboardModel`:
1313

1414
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="1:25", language="elm" %}{% endcodesnippet %}
1515

16-
Elm 0.17 does not use Signals anymore. Instead we use a publication/subscription-pattern that uses messages.
16+
Elm 0.17 does not use Signals anymore. Instead we use a publication/subscription pattern that uses messages.
1717
We need to declare the type of the message here, which can be one of the following:
1818

1919
* a `Step` with a timestamp. This represents a frame of the game-loop.
20-
* a `KeyboardExtraMsg` which is a keyboard-input
20+
* a `KeyboardExtraMsg` which is a keyboard input
2121

2222
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="26:30", language="elm" %}{% endcodesnippet %}
2323

24-
We are also going to need some constant values, e.g. the screen-size and the radius of the player's periphery:
24+
We are also going to need some constant values, e.g. the screen size and the radius of the player's periphery:
2525

2626
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="30:44", language="elm" %}{% endcodesnippet %}
2727

2828

2929
== Update
3030

31-
We now define how the state of the game can change over time. This state-transition is done with the function `update : Msg -> Game -> Game`. This function will receive our `Msg` and will update the game-state accordingly. We distinguish here between `KeyboardExtraMsg` and `Step`:
31+
We now define how the state of the game can change over time. This state-transition is done with the function `update : Msg -> Game -> Game`. This function will receive our `Msg` and will update the game state accordingly. We distinguish here between `KeyboardExtraMsg` and `Step`:
3232

3333
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="99:105", language="elm" %}{% endcodesnippet %}
3434

3535
`onUserInput` will set the current direction based on the arrow-keys pressed on the keyboard:
3636

3737
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="72:87", language="elm" %}{% endcodesnippet %}
3838

39-
`onFrame` on the other hand will update the game's state on the next frame:
39+
`onFrame` on the other hand will update the game's state on the next frame.
40+
There is currently only one `nextCmd` value which does nothing. We are going to add
41+
more commands later on.
4042

4143
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="88:97", language="elm" %}{% endcodesnippet %}
4244

@@ -48,14 +50,14 @@ We now define how the state of the game can change over time. This state-transit
4850

4951
Elm provides different libraries to output html or to render 2d-graphics on a canvas. We use the `Graphics`-Package for this.
5052

51-
The `Player` will be a small triangle that we rotate around the game's center.
52-
A black background will represent our game-screen. We also change the `Player`'s color depending on the angle (for fun and profit):
53+
The `Player` will be a small triangle that we rotate around the center of the game.
54+
A black background will represent our game screen. We also change the player's color depending on the angle (for fun and profit):
5355

5456
// bgBlack, moveRadial, makePlayer
5557
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="109:122" %}{% endcodesnippet %}
5658

5759
The function `view : Game -> Html.Html Msg` is the main function of the view part of our application.
58-
It receives the current game-state and returns `Html`:
60+
It receives the current game state and returns `Html`:
5961

6062
// view
6163
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/controls/src/Hexagon.elm", lines="123:135" %}{% endcodesnippet %}

doc/dancefloor.adoc

+11-6
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ The board is made of two elements: Six triangles in alternating dark and bright
3333
colors and a center hexagon.
3434

3535
First, we create the function that calculates the color values. It takes the progress
36-
as an input and returns a `Colors` object that contains the values for the three colors.
36+
as an input and returns a `Colors` object that contains the values for the three colors. +
37+
`msRunning` is a `Float` and `hue` is an angle. So this function cycles through all
38+
the colors in the color wheel.
3739

3840
// makeColors
3941
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/dancefloor/src/Hexagon.elm", lines="230:239" %}{% endcodesnippet %}
4042

4143
A triangle is defined by its three corner points. Each point is a tuple of floats.
4244
One point in every triangle is the center point (0, 0). The other two points are
4345
calculated using simple trigonometry. The radius depends on the canvas size.
44-
Its length is $$\sqrt2$$ * screen width. This way the triangles always cover the whole
46+
Its length is $$\sqrt2$$ * half screen width. This way the triangles always cover the whole
4547
field.
4648

4749
The field itself consists of a group of Forms. Firstly we define two helper
@@ -64,7 +66,9 @@ The center element is a hexagon that has a dark fill color and a light outline.
6466

6567

6668
Now we can draw the element. We define the new colors in the let block of the view function.
67-
Then we can add the new elements and pass the whole group to a (yet empty) rotate function.
69+
Then we can add the new elements and pass the whole group to a (yet empty) rotate function. +
70+
The `makeCenterHole` function returns a list so we use `List.append` to merge the two lists in
71+
the view function.
6872

6973
// view
7074
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/dancefloor/src/Hexagon.elm", lines="240:257" %}{% endcodesnippet %}
@@ -73,7 +77,7 @@ Then we can add the new elements and pass the whole group to a (yet empty) rotat
7377
## Adding Rotation
7478

7579
Compared to the original game, the rotation in this version is much simpler. The rotation speed is
76-
defined with a sinus function. So it starts rotating in one direction, gets faster, then after
80+
defined with a sinus function. The board starts rotating in one direction, gets faster, then after
7781
having reached a maximum it gets slower until it rotates the other way. And so forth.
7882

7983
To accomplish this we have to modify the angle that is passed to the `rotate` function.
@@ -83,12 +87,13 @@ That's why we added the two values `autoRotateAngle` and `autoRotateSpeed` to th
8387
derivate of `autoRotateAngle`.
8488

8589
The two functions `updateAutoRotateAngle` and `updateAutoRotateSpeed` take care
86-
of this:
90+
of this. You can see the values change in the console when you add the
91+
`Debug.log` function. Don't forget to remove it later on.
8792

8893
// updateAutoRotateAngle, updateAutoRotateSpeed
8994
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/dancefloor/src/Hexagon.elm", lines="107:116" %}{% endcodesnippet %}
9095

91-
the functions are called during the update cycle in the `onFrame` method:
96+
The functions are called during the update cycle in the `onFrame` method:
9297

9398
// onFrame
9499
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/dancefloor/src/Hexagon.elm", lines="144:163" %}{% endcodesnippet %}

doc/enemies.adoc

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ Enemies
33

44
image:Bildschirmfoto 2016-06-26 um 15.31.42.png[alt=""]
55

6-
In the original game the shape of the "enemies" are defined in a large class and they are created in waves. For this tutorial we keep it simpler. We have some pre-defined enemy-arrangements that repeat themselves.
6+
In the original game the shape of the "enemies" is defined in a large class and they are created in waves. For this tutorial we keep it simpler. We have some predefined enemy arrangements that repeat themselves.
77

88
Let's first introduce a new type `Enemy`:
99

1010
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="26:30", language="elm" %}{% endcodesnippet %}
1111

1212

13-
1413
* radius: the distance of the enemies to the center
1514
* parts: a list of true/false that indicate where the enemy has a "hole"
1615
@@ -22,7 +21,7 @@ We also need to add new initial states for our game:
2221

2322
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="352:371", language="elm" %}{% endcodesnippet %}
2423

25-
We further define a constant values `enemyThickness`, `enemyDistance`, `enemyInitialSpeed` and `enemyAcceleration`:
24+
We further define the constant values `enemyThickness`, `enemyDistance`, `enemyInitialSpeed` and `enemyAcceleration`:
2625

2726
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="67:70", language="elm" %}{% endcodesnippet %}
2827

@@ -38,7 +37,7 @@ As you may have noticed, we have only defined the `parts` property of the Enemy
3837
== Updating radius
3938

4039

41-
Let's introduce two new functions in the `onFrame`-Function that will update `enemies` and `enemySpeed` on the game state:
40+
Let's introduce two new functions in the `onFrame` function that will update `enemies` and `enemySpeed` on the game state:
4241

4342
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="192:213", language="elm" %}{% endcodesnippet %}
4443

@@ -72,11 +71,11 @@ We subtract the `enemyProgress`, so that value will be negative (for most enemie
7271

7372
First we need a function to create a trapezoid:
7473

75-
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="240:247", language="elm" %}{% endcodesnippet %}
74+
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="240:248" %}{% endcodesnippet %}
7675

7776
We will now use this function to create a trapezoid for every occupied part of any enemy:
7877

79-
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="250:263", language="elm" %}{% endcodesnippet %}
78+
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="250:263" %}{% endcodesnippet %}
8079

8180
This function returns a `Form` that contains a group of these trapezoids. Notice how we filter out parts by creating a tuple of `(index:Int, part:Bool)`, removing parts where part is `False` and sending the index to `makeEnemyPart`. Pure functional magic:
8281

@@ -86,7 +85,7 @@ The following function `makeEnemies` will create a `List(Form)` for every enemy:
8685

8786
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="264:266", language="elm" %}{% endcodesnippet %}
8887

89-
Finally we add this function to our `view`-function:
88+
Finally we add this function to our `view` function:
9089

9190
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/enemies/src/Hexagon.elm", lines="320:339", language="elm" %}{% endcodesnippet %}
9291

doc/gameloop.adoc

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Game Loop and Debugger
22
----------------------
33

4-
In this chapter we introduce a progress in the form of miliseconds that have passed since start. This progress is used to calculate the rotations and the movement of the enemies and also represents the "score" of the player.
4+
In this chapter we introduce a progress counter in the form of miliseconds that have passed since the start of the game.
5+
This progress is used to calculate the rotations and the movement of the enemies and also represents the "score" of the player.
56

6-
We further extend the controls by a `Play`/`Pause`-behavior triggered by the space-key. For that we introduce a new type `State`:
7+
We further extend the controls by a `Play`/`Pause`-behavior triggered by the space key. For that we introduce a new type `State`:
78

89
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/game-progress/src/Hexagon.elm", lines="16:17", language="elm" %}{% endcodesnippet %}
910

@@ -19,17 +20,19 @@ Because the player should only be able to move on the `Play`-`State` feature, we
1920

2021
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/game-progress/src/Hexagon.elm", lines="76:86", language="elm" %}{% endcodesnippet %}
2122

22-
`onUserInput` needs also some modifications to fetch the space-key and update the game-state accordingly:
23+
`onUserInput` needs also some modifications to fetch the status of the space key and update the game state accordingly:
2324

2425
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/game-progress/src/Hexagon.elm", lines="100:124", language="elm" %}{% endcodesnippet %}
2526

2627
== Update times
2728

28-
The function `onFrame` is called on every animation frame event (60 times a second). We add the timing-update behaviors there:
29+
The function `onFrame` is called on every animation frame event (60 times a second). We add the timing update behaviors there:
2930

3031
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/game-progress/src/Hexagon.elm", lines="126:143", language="elm" %}{% endcodesnippet %}
3132

3233
with some additional functions:
34+
We add the current minus the last stored timestamp to `game.msRunning`. This is
35+
the time that has passed since the last call to `onFrame`.
3336

3437
{% codesnippet "https://raw.githubusercontent.com/macrozone/elm-hexagon-tutorial/chapter/game-progress/src/Hexagon.elm", lines="86:98", language="elm" %}{% endcodesnippet %}
3538

0 commit comments

Comments
 (0)