This was developed for the F# Game Jam 2021.
While I was not successful in developing a working game within the time limit, I decided to post this work anyway as I think it shows off some of the nice F# tooling that is available.
While reading a thread on the theme, I was inspired by the final suggestion from Vorotato:
Western cowboys but they ranch cats for their fur.
I was reminded that removing fur is not the same as shearing, so I decided to go with milking instead.
- Intriguing introduction story
- Browser code from F# using Fable and Rollup
- Unit tests with Fuchu
- Light and dark themes based on system preference.
- Feed your cat
- Sleep
- Any story beyond the introduction
- Milk your cat
- Buy and sell cats/milk/food
- Get more cats
In the MattMS.CatGame.Browser
folder, run dotnet fable
to build the EcmaScript with Fable.
In the project root, run npm run build
to compile the Pug and Stylus code, and bundle the EcmaScript for the browser.
The "editor choices" section at the end of this document suggests a development approach, with file watchers for source code changes.
In MattMS.CatGame.Tests
, run dotnet run
to test the code.
There is very limited test coverage, as tests were only added when I was having trouble with the code.
I have used most of these libraries/tools before (except Rollup and Sutil), but I do not get to use them in my day job.
It is a small project, without multiple developer preferences, so I can fall back to the standard HTML page approach.
I very much like the graceful degredation approach that websites are meant to follow.
Unfortunately, I did make the choice of requiring CSS, otherwise I would have needed many more pages for each screen of the story.
I hope that wrapping each story "page" in an article
tag can bring me some forgiveness.
My currently installed version of .NET SDK is 5.0.301.
Fable is used to convert F# code into EcmaScript code that can be bundled for the browser. My decision to use it was based on familiarity of using it before.
I chose to use Fuchu for testing due to how quick it is to get started. The tests can be written in a .NET Console application, so there is no need to worry about test runners.
I have used (and really enjoyed using) Elmish before, but I am not a fan of React so I decided to try something different this time. I am quite curious about Svelte and was very happy to learn about Sutil.
All of these were used on Node 14.17.3 with npm 6.14.13, running on Windows 10 Home.
Although not strictly necessary, I decided to use Concurrently to simplify my npm scripts.
I did have npm-run-all
, for the sequential execution, but that does not matter now that there are no dependencies from the Pug templates.
"build": "run-s build-styles build-scripts build-pages",
Pug templates are used to generate the HTML.
Rollup turned out to be a pretty cool project for bundling up the EcmaScript generated by Fable.
I have used Browserify, Parcel, and WebPack on other projects, so I decided to give Rollup a go this time. I was pleasantly surprised at being able to configure it entirely in my npm scripts.
Stylus is used to generate the CSS.
Uglify is used to minify the code that is generated by Rollup.
Not sure how I feel about the 3 different name styles: "UglifyJS" (GitHub), "uglify-js" (npm), and "uglifyjs" (command).
This was mostly written in VS Code, using the Ionide extension.
I made heavy use of the npm scripts
in the Explorer, and the Terminal for using Fable.
Essentially this involved 2 terminal sessions:
dotnet fable watch
npm run watch