From 1d742d1800af1f7ffb94d8b1e9d3c87ce985a43d Mon Sep 17 00:00:00 2001 From: jonnyroutley Date: Tue, 14 Jul 2020 17:39:37 +0200 Subject: [PATCH 1/3] Update tutorial.md Include declaration of score variable and the first setText statement. --- website/content/tutorial.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/content/tutorial.md b/website/content/tutorial.md index cb01d2f..db53dd9 100644 --- a/website/content/tutorial.md +++ b/website/content/tutorial.md @@ -189,6 +189,8 @@ the item disappears, and the user's score increases. We can display the user's current score using the `game.setText` function. ```javascript +let score = 0; + function update(game) { for (let i = 0; i < items.length; i++) { const item = items[i]; @@ -200,6 +202,8 @@ function update(game) { } // ... + + game.setText(Score: ${score}`) } ``` From 66feab086296d9047896e13c6f42f3a556662024 Mon Sep 17 00:00:00 2001 From: James Routley Date: Tue, 1 Sep 2020 09:10:05 +0100 Subject: [PATCH 2/3] Build website --- docs/tutorial/index.html | 10 +++++++--- website/content/tutorial.md | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/tutorial/index.html b/docs/tutorial/index.html index 0cd50cf..9cae1e9 100644 --- a/docs/tutorial/index.html +++ b/docs/tutorial/index.html @@ -205,7 +205,9 @@

6. Collecting items

Currently, nothing happens when our player walks over an item. Lets change it so the item disappears, and the user’s score increases. We can display the user’s current score using the game.setText function.

-
function update(game) {
+
let score = 0;
+
+function update(game) {
   for (let i = 0; i < items.length; i++) {
     const item = items[i];
     if (item.x == player.x && item.y == player.y) {
@@ -216,8 +218,10 @@ 

6. Collecting items

} // ... -} -
+ + game.setText(Score: ${score}`) +} +

We iterate through all the items, and if the item is at the same position as the player, we increment the score and remove the item from the list.

diff --git a/website/content/tutorial.md b/website/content/tutorial.md index db53dd9..6f9ae08 100644 --- a/website/content/tutorial.md +++ b/website/content/tutorial.md @@ -202,7 +202,7 @@ function update(game) { } // ... - + game.setText(Score: ${score}`) } ``` From 1e0892ab7c6e9691a2876f878b1fbead1bb877be Mon Sep 17 00:00:00 2001 From: James Routley Date: Tue, 1 Sep 2020 09:11:01 +0100 Subject: [PATCH 3/3] Add helter shelter to game list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5bce348..fec56df 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,6 @@ Please see our [website for more information, examples, and a tutorial](https:// - [24Rogue](https://www.raza6.fr/24Rogue/), by [@raza6](https://github.com/raza6/24rogue) - [Paint](https://bernardini687.github.io/paint/index.html), by [@bernardini687](https://github.com/bernardini687) - [24MadRush](https://keatonfs.github.io/24.../), by [@keatonfs](https://github.com/keatonfs/24MadRush) +- [Helter Shelter](https://tolbish.github.io/helter-shelter), by @tolbish If you've built something using 24a2 please let us know! Feel free to open an Issue or Pull Request to add it to this list.