Skip to content

MattMS/fsharp-game-jam-2021

Repository files navigation

JAM (Just Another Milking) game in F#

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.

Inspiration

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.

Features

Mostly working

  • Intriguing introduction story
  • Browser code from F# using Fable and Rollup
  • Unit tests with Fuchu
  • Light and dark themes based on system preference.

Slightly working

  • Feed your cat
  • Sleep

Totally missing

  • Any story beyond the introduction
  • Milk your cat
  • Buy and sell cats/milk/food
  • Get more cats

How to build

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.

How to test

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.

Why this tech?

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.

.NET library/tool choices

My currently installed version of .NET SDK is 5.0.301.

Fable

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.

Fuchu

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.

Sutil

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.

Node tool choices

All of these were used on Node 14.17.3 with npm 6.14.13, running on Windows 10 Home.

Concurrently

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

Pug templates are used to generate the HTML.

Rollup

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

Stylus is used to generate the CSS.

Uglify

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).

Editor choices

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published