Building games is the most "fun" you can have while learning how to program in a new language or platform!
Our quest to follow the Elm Tetris Tutorial by "Captain Coder": https://youtu.be/GMSXYnMH1gg
Tetris is familiar to most people that have played computer/video games...
If you have never played it, try now:
https://tetris.com/play-tetris
And, read the history: https://en.wikipedia.org/wiki/Tetris
Start by installing elm (if you do not already have it on your computer): https://guide.elm-lang.org/install.html
Ensure that you have a text editor installed,
in our case we are using Atom: https://atom.io
We are also using elm-format
to make the code look "elm
-ish".
In my case I had to:
npm install elm-format -g
AND
apm install elm-format
Then re-start Atom and try saving a .elm
file and
if it gets re-formatted, then everything worked.
If you get "stuck" installing the packages, google for the error message you see and if you are still stuck after 10mins of googling, open an issue on GitHub: https://github.com/nelsonic/tetris/issues
In the /tetris
directory run the elm-rector
command.
You should see:
This runs a local web server on your computer that you can access by visiting in the browser: http://localhost:8000
After trying to run the initial code shown in the tuturial:
module Block where
import Graphics.Element
main = Graphics.Element = show 42
elm-format
re-formats it to:
module Block exposing (..)
import Graphics.Element
main =
show 42
The Tetris tutorial requires "Graphics": https://github.com/evancz/elm-graphics
In your terminal, type:
elm-package install evancz/elm-graphics
You should see something like this:
Again, thanks to StackOverflow: https://stackoverflow.com/questions/41408360/what-happened-to-graphics-package-in-elm-0-18