In this lab, you're going to add a feature to your game. The initial version of the game has already been deployed to GitHub Pages. The link can be found in the About section of your repository on GitHub.com.
Currently, the game functions as expected, however players don't know how it works. We need to add the rules of the game so that players know what to do and how to win.
Before you start adding a feature, you should create a branch to work on.
-
Open the terminal or command prompt
-
Create and checkout a new branch
git checkout -b feature/rules
The rules for the game are simple, but they should be displayed so new players know what to do.
-
Open
index.html -
Locate the comment
<!-- Lab 1: Add Game Rules --> -
Add the following code below the comment
<p class="game-explanation"> <strong class="important">How to play:</strong> Use your <strong>arrow keys</strong> to move the tiles. When two tiles with the same number touch, they <strong>merge into one!</strong> </p>
-
Save the file
Before you commit your changes, you should test the feature to make sure it works as expected.
-
Open
index.htmlin your web browser -
Verify the rules are displayed
Now that you've tested the feature, you should commit your changes to your feature branch.
-
Open the terminal or command prompt
-
Add your changes to the staging area
git add index.html
-
Commit your changes
git commit -m 'Add game rules to index.html'
Now that you've added the feature, you should switch back to the main branch
so you can start working on something new!
-
Checkout the
mainbranchgit checkout main
Now that you're on the main branch, you should merge the feature/rules
branch into the main branch. That way, when your changes are pushed, the rules
will be displayed on GitHub Pages the next time you refresh.
-
Merge the
feature/rulesbranch into themainbranchgit merge feature/rules
-
Push your changes to GitHub
git push
-
Navigate to your repository on GitHub.com
-
Click the Actions tab
-
Click the running Deploy to GitHub Pages workflow
-
Wait for the workflow run to complete
-
Click the Code tab
-
Click the link to your game
-
Verify the rules are now displayed on the game page
If you're having trouble with any of the steps, you can ask for help in the meeting chat.
The code changes for this lab can be found in the solutions directory.
- Copy the contents of
solutions/1-add-a-feature/index.htmland replace the contents ofindex.html
