From 9c46a41c38d2f37d675547652beba8bab7156ba1 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 17:20:25 +0330 Subject: [PATCH 01/12] docs: Update Makefile and README.md for Python 3 compatibility Updated the Makefile and README.md to ensure compatibility with Python3 by replacing instances of commands with. --- Makefile | 26 +++++++++++++------------- README.md | 9 +++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index b033f78ee..906861973 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Definitions ############################## -REQUIRED_BINS = svn wget java python +REQUIRED_BINS = svn wget java python3 ############################## # Rules @@ -11,42 +11,42 @@ REQUIRED_BINS = svn wget java python all: deps games index: common - python build/compress.py index + python3 build/compress.py index puzzle: common - python build/compress.py puzzle + python3 build/compress.py puzzle maze: common - python build/compress.py maze + python3 build/compress.py maze bird: common - python build/compress.py bird + python3 build/compress.py bird turtle: common - python build/compress.py turtle + python3 build/compress.py turtle movie: common - python build/compress.py movie + python3 build/compress.py movie music: common - python build/compress.py music + python3 build/compress.py music pond-tutor: common - python build/compress.py pond/tutor + python3 build/compress.py pond/tutor pond-duck: common - python build/compress.py pond/duck + python3 build/compress.py pond/duck gallery: common - python build/compress.py gallery + python3 build/compress.py gallery games: index puzzle maze bird turtle movie music pond-tutor pond-duck gallery common: @echo "Converting messages.js to JSON for Translatewiki." - python build/messages_to_json.py + python3 build/messages_to_json.py @echo "Converting JSON from Translatewiki to message files." - python build/json_to_js.py + python3 build/json_to_js.py @echo deps: diff --git a/README.md b/README.md index 24362c0ef..9ac1a2d68 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,12 @@ All code is free and open source. **The games are available at https://blockly.games/** **The developer's site is at https://github.com/google/blockly-games/wiki** + +## Steps + +### 1. Installation +1. Forking the `Blockly Games` repository into the user's GitHub account. +2. Installing `Blockly Games` from the GitHub repository. +3. Setting up game dependencies on macOS using `Homebrew` and `MacPorts`. +4. Installing game dependencies using `make deps` and running the `make games` command. +5. Checked, revised, and updated each sample to use "python3" initially using "python" in `./Makefile` file. \ No newline at end of file From 837fcf1efaeba3b5e08544ef637078b3cc057459 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 17:41:34 +0330 Subject: [PATCH 02/12] feat: add git-conventional-commits package Added the 'git-conventional-commits' package and included 'git-conventional-commits.yaml'. --- .git-hooks/commit-msg | 10 ++++++++ README.md | 3 ++- git-conventional-commits.yaml | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 .git-hooks/commit-msg create mode 100644 git-conventional-commits.yaml diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg new file mode 100755 index 000000000..92de2306e --- /dev/null +++ b/.git-hooks/commit-msg @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +commit_message="$1" +# exit with a non zero exit code incase of an invalid commit message + +# use git-conventional-commits, see https://github.com/qoomon/git-conventional-commits +git-conventional-commits commit-msg-hook "$commit_message" + +# or verify $commit_message with your own tooling +# ... \ No newline at end of file diff --git a/README.md b/README.md index 9ac1a2d68..215e3730b 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,5 @@ All code is free and open source. 2. Installing `Blockly Games` from the GitHub repository. 3. Setting up game dependencies on macOS using `Homebrew` and `MacPorts`. 4. Installing game dependencies using `make deps` and running the `make games` command. -5. Checked, revised, and updated each sample to use "python3" initially using "python" in `./Makefile` file. \ No newline at end of file +5. Checked, revised, and updated each sample to use "python3" initially using "python" in `./Makefile` file. +6. Installing the `git-conventional-commits` package to the repository and included the `git-conventional-commits.yaml` file. \ No newline at end of file diff --git a/git-conventional-commits.yaml b/git-conventional-commits.yaml new file mode 100644 index 000000000..60ac58490 --- /dev/null +++ b/git-conventional-commits.yaml @@ -0,0 +1,43 @@ +--- +convention: + commitTypes: + - feat + - fix + - perf + - refactor + - style + - test + - build + - ops + - docs + - chore + - merge + - revert + commitScopes: [] + releaseTagGlobPattern: v[0-9]*.[0-9]*.[0-9]* +changelog: + commitTypes: + - feat + - fix + - perf + - merge + includeInvalidCommits: true + commitIgnoreRegexPattern: "^WIP " + headlines: + feat: Features + fix: Bug Fixes + perf: Performance Improvements + merge: Merges + breakingChange: BREAKING CHANGES + + ## GitHub + # commitUrl: https://github.com/ACCOUNT/REPOSITORY/commit/%commit% + # commitRangeUrl: https://github.com/ACCOUNT/REPOSITORY/compare/%from%...%to%?diff=split + + ## GitHub Issues + # issueRegexPattern: "#[0-9]+" + # issueUrl: https://github.com/ACCOUNT/REPOSITORY/issues/%issue% + + ## Jira Issues + # issueRegexPattern: "[A-Z][A-Z0-9]+-[0-9]+" + # issueUrl: https://WORKSPACE.atlassian.net/browse/%issue% From 4b74286f1d1ffb981b588c8747b7682a5d8342c3 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 18:07:54 +0330 Subject: [PATCH 03/12] style: Add classes to style.css files Add CSS3 styles to the end of files ./appengine/bird/style.css and ./appengine/maze/style.css --- README.md | 20 +++++++++++++++++++- appengine/bird/style.css | 12 ++++++++++++ appengine/maze/style.css | 12 ++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 215e3730b..cc4d6ce97 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,22 @@ All code is free and open source. 3. Setting up game dependencies on macOS using `Homebrew` and `MacPorts`. 4. Installing game dependencies using `make deps` and running the `make games` command. 5. Checked, revised, and updated each sample to use "python3" initially using "python" in `./Makefile` file. -6. Installing the `git-conventional-commits` package to the repository and included the `git-conventional-commits.yaml` file. \ No newline at end of file +6. Installing the `git-conventional-commits` package to the repository and included the `git-conventional-commits.yaml` file. + +### Coding +1. Add the following CSS3 styles to the end of the files `./appengine/bird/style.css` and `./appengine/maze/style.css`, insert the code below: + +```css +.sliderTrack { + stroke: #aaa; + stroke-width: 6px; + stroke-linecap: round; +} + +.sliderKnob { + fill: #ddd; + stroke: #bbc; + stroke-width: 1px; + stroke-linejoin: round; +} +``` \ No newline at end of file diff --git a/appengine/bird/style.css b/appengine/bird/style.css index 4f2a1beca..7feff2b84 100644 --- a/appengine/bird/style.css +++ b/appengine/bird/style.css @@ -49,3 +49,15 @@ button.primary { html[dir="RTL"] button.primary { text-align: right; } +.sliderTrack { + stroke: #aaa; + stroke-width: 6px; + stroke-linecap: round; +} + +.sliderKnob { + fill: #ddd; + stroke: #bbc; + stroke-width: 1px; + stroke-linejoin: round; +} \ No newline at end of file diff --git a/appengine/maze/style.css b/appengine/maze/style.css index 350db2885..f7587f782 100644 --- a/appengine/maze/style.css +++ b/appengine/maze/style.css @@ -127,3 +127,15 @@ html[dir="RTL"] #pegmanButton>span { width: 49px; background-position: -980px 0; } +.sliderTrack { + stroke: #aaa; + stroke-width: 6px; + stroke-linecap: round; +} + +.sliderKnob { + fill: #ddd; + stroke: #bbc; + stroke-width: 1px; + stroke-linejoin: round; +} \ No newline at end of file From 33f89b4de2cddb6299fefe860646ee08f4190fb2 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 18:21:08 +0330 Subject: [PATCH 04/12] feat(bird): Add speedSlider variable and calculateSpeed function Added a new variable into the ./appengine/bird/main.js, speedSlider, and implemented the calculateSpeed function. This calculateSpeed function computes a value using specific calculations and assigns it to the stepSpeed variable. --- README.md | 3 ++- appengine/bird/src/main.js | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc4d6ce97..cba24eb8e 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,5 @@ All code is free and open source. stroke-width: 1px; stroke-linejoin: round; } -``` \ No newline at end of file +``` +2. Added a new variable into the `./appengine/bird/main.js`, `speedSlider`, and implemented the 'calculateSpeed' function. This function `calculateSpeed` computes a value using specific calculations and assigns it to the `stepSpeed` variable. \ No newline at end of file diff --git a/appengine/bird/src/main.js b/appengine/bird/src/main.js index 0edd189ac..18adc2faf 100644 --- a/appengine/bird/src/main.js +++ b/appengine/bird/src/main.js @@ -45,6 +45,7 @@ let pos; let angle; let currentAngle; let hasWorm; +let speedSlider; /** * Log of duck's moves. Recorded during execution, played back for animation. @@ -401,6 +402,11 @@ function init() { if (BlocklyGames.LEVEL > 1) { BlocklyInterface.workspace.addChangeListener(Blockly.Events.disableOrphans); } + + // Initialize the slider. + const sliderSvg = BlocklyGames.getElementById('slider'); + speedSlider = new Slider(10, 35, 130, sliderSvg); + // Not really needed, there are no user-defined functions or variables. Blockly.JavaScript.addReservedWords('noWorm,heading,getX,getY'); @@ -543,6 +549,16 @@ function levelHelp() { } } +/** + * Calculate adjusted speed based on the speed value provided. + * @param {number} speed - The initial speed value. + * @returns {number} - The adjusted speed value. + */ +function calculateSpeed(speed) { + speed = speed * (-speedSlider.value_ + 1); + return speed; +} + /** * Reset the bird to the start position and kill any pending animation tasks. * @param {boolean} first True if an opening animation is to be played. @@ -726,7 +742,7 @@ function execute() { } // Fast animation if execution is successful. Slow otherwise. - stepSpeed = (result === ResultType.SUCCESS) ? 10 : 15; + stepSpeed = (result === ResultType.SUCCESS) ? calculateSpeed(10) : calculateSpeed(15); // log now contains a transcript of all the user's actions. // Reset the bird and animate the transcript. From fc2ea7c7ff3b541176336225990ad08dff68b643 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 18:36:44 +0330 Subject: [PATCH 05/12] feat(bird): Add speedSlider variable and calculateSpeed function Add new variable into the ./appengine/bird/main.js, speedSlider, and implemented the calculateSpeed function. This calculateSpeed function computes a value using specific calculations and assigns it to the stepSpeed variable. --- README.md | 2 +- appengine/bird/src/main.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc4d6ce97..da98958cf 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,4 @@ All code is free and open source. stroke-width: 1px; stroke-linejoin: round; } -``` \ No newline at end of file +2. Add new variable into the `./appengine/bird/main.js`, `speedSlider`, and implemented the 'calculateSpeed' function. This function `calculateSpeed` computes a value using specific calculations and assigns it to the `stepSpeed` variable. \ No newline at end of file diff --git a/appengine/bird/src/main.js b/appengine/bird/src/main.js index 0edd189ac..450cf405d 100644 --- a/appengine/bird/src/main.js +++ b/appengine/bird/src/main.js @@ -45,6 +45,7 @@ let pos; let angle; let currentAngle; let hasWorm; +let speedSlider; /** * Log of duck's moves. Recorded during execution, played back for animation. @@ -543,6 +544,16 @@ function levelHelp() { } } +/** + * Calculate adjusted speed based on the speed value provided. + * @param {number} speed - The initial speed value. + * @returns {number} - The adjusted speed value. + */ +function calculateSpeed(speed) { + speed = speed * (-speedSlider.value_ + 1); + return speed; +} + /** * Reset the bird to the start position and kill any pending animation tasks. * @param {boolean} first True if an opening animation is to be played. @@ -726,7 +737,7 @@ function execute() { } // Fast animation if execution is successful. Slow otherwise. - stepSpeed = (result === ResultType.SUCCESS) ? 10 : 15; + stepSpeed = (result === ResultType.SUCCESS) ? calculateSpeed(10) : calculateSpeed(15); // log now contains a transcript of all the user's actions. // Reset the bird and animate the transcript. From b853ad3ad995022b10b3c4413f98ede0831bd2f3 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 18:46:46 +0330 Subject: [PATCH 06/12] fix: Add ``` at line 37 of README.md to fix --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da98958cf..711ecbf03 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,5 @@ All code is free and open source. stroke-width: 1px; stroke-linejoin: round; } -2. Add new variable into the `./appengine/bird/main.js`, `speedSlider`, and implemented the 'calculateSpeed' function. This function `calculateSpeed` computes a value using specific calculations and assigns it to the `stepSpeed` variable. \ No newline at end of file +``` +2. Add new variable into the `./appengine/bird/main.js`, `speedSlider`, and implemented the `calculateSpeed` function. This function `calculateSpeed` computes a value using specific calculations and assigns it to the `stepSpeed` variable. \ No newline at end of file From de1a0ea0e159d15666e2a071b9c64bf7e6f9d824 Mon Sep 17 00:00:00 2001 From: Alireza Tahriri Date: Tue, 21 Nov 2023 18:54:25 +0330 Subject: [PATCH 07/12] feat(bird): Add the Slider SVG icon --- README.md | 3 ++- appengine/bird/src/html.js | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 711ecbf03..60d628661 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,5 @@ All code is free and open source. stroke-linejoin: round; } ``` -2. Add new variable into the `./appengine/bird/main.js`, `speedSlider`, and implemented the `calculateSpeed` function. This function `calculateSpeed` computes a value using specific calculations and assigns it to the `stepSpeed` variable. \ No newline at end of file +2. Add new variable into the `./appengine/bird/main.js`, `speedSlider`, and implemented the `calculateSpeed` function. This function `calculateSpeed` computes a value using specific calculations and assigns it to the `stepSpeed` variable. +3. Add the Slider SVG icon into the `./appengine/bird/html.js` file. \ No newline at end of file diff --git a/appengine/bird/src/html.js b/appengine/bird/src/html.js index 9175ce4f5..6a16e6f86 100644 --- a/appengine/bird/src/html.js +++ b/appengine/bird/src/html.js @@ -21,7 +21,7 @@ goog.require('BlocklyGames.html'); * @param {!Object} ij Injected options. * @returns {string} HTML. */ -Bird.html.start = function(ij) { +Bird.html.start = function (ij) { return ` ${BlocklyGames.html.headerBar(ij, BlocklyGames.getMsg('Games.bird', true), '', true, false, '')} @@ -32,7 +32,30 @@ ${BlocklyGames.html.headerBar(ij, BlocklyGames.getMsg('Games.bird', true), '', t - +
+ + + + + + + + + + + + + +