Retro remakes for various 1980s computer games.
"You can't use Functional Programming to make games!" -- Anon.
Well yes you can, and no there isn't too much garbage collection going on, in fact there's almost none.
This is a Jonathan-kills-many-birds exercise, involving many technologies.
Technology:
- Windows desktop (F# / .Net Core / SDL2-CS / SDL2)
- [Untested] Linux desktop (F# / .Net Core / SDL2-CS / SDL2)
- In the browser (F# / Fable / Web Canvas / HTML)
- TODO: F#-Bolero in-browser solution
In other words, retro games, one language, go many places.
This is a research project also:
- Practice F#
- Distill a game library from this
- Distill desktop and web mini-frameworks from this
- Use in other similar games
These are in the Web folders.
It's all node.js / npm stack, so you need these installed.
Erases and re-builds the wwwroot folder.
The needed files are copied into wwwroot, and the Fable compiler runs to generate a hash-stamped JS file from the F# source code.
Each game has its own wwwroot folder, which is self- contained, and can be pasted into a larger web site that links to the index.html file.
Run build_production.bat first!
Serves the wwwroot folder at http://localhost:8080
Run build_production.bat first, so that the support files are created within the wwwroot folder. It is worthy of note that the main..js file is not used, because WebPack starts the Fable compiler, and the Fable compiler's output (main.js) is served directly from Webpack's RAM.
This supports live recompiling and refreshing of the browser if the F# code changes.
This serves the wwwroot folder at: http://localhost:8080
On the F# side, the 'web' code can be compiled by the .Net compiler, which can be useful for error checking, even though it can never yield a useful program binary.
Requires SDL2 libraries from distro provider, eg: Ubuntu:
sudo apt-get install libsdl2-dev
sudo apt-get install libsdl2-image-dev
sudo apt-get install libsdl2-ttf-dev
sudo apt-get install libsdl2-mixer-dev
cd FsFortAssaultDesktopLinux
dotnet run
I just use Visual Studio 2019, Community Edition. I provide SDL2.dll and other DLLs. Set 'Desktop' as the startup project.
Shared Assemblies | Purpose |
---|---|
GameLib | Game algorithm library, based on F# core library only. |
GameLibDesktopFramework | Game mini-framework for desktop Windows and Linux, using SDL2. |
GameLibTests | Automation Tests for the complex bits of GameLib. |
GameLibWebFramework | Game mini-framework for web browsers using Fable, and Web Canvas. |
SDL2-CS | A (hopefully temporary) copy of the SDL2-CS framework, until the author puts that on NuGet! hint |
XunitExtensionsLib | Jonathan's attempt at making XUnit tests nicer on F#, in lieu of looking for a proper F# test lib. |
Game Assemblies | Purpose |
---|---|
FortAssaultDesktop | Fort Assault Linux/Windows Desktop version main program. |
FortAssaultEngine | Fort Assault Game engine, host-environment-agnostic. |
FortAssaultWeb | Fort Assault web version main program. |
PacmanDesktop | Pac Man Linux/Windows Desktop version main program. |
PacmanEngine | Pac Man Game engine, host-environment-agnostic. |
PacmanEngineTests | Pac Man engine tests. |
PacmanWeb | Pac Man web version main program. |
In development, you can shortcut the game to a screen by altering the "NewStoryboard" function. This calls the "Shortcut" function, and you can choose various start-state cases for development purposes. You must set this back to 'RunGameNormally' for release.
For Fort Assault:
SHORT_PLAYTHROUGH : A special mode for testing, enabled by inserting the following into FsFortAssaultEngine.fsproj:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;SHORT_PLAYTHROUGH</DefineConstants>
</PropertyGroup>
Another game! Adding more games helps determine requirements for the shared library and framework.
Add more test framework for the shared game library and framework.
Design for, and include the following:
- Sound support
- Runtime-generated bitmap images. This would allow for more variety without the need for manually-drawn image files.
F#-Bolero (.Net WebAssembly) version, as a technology demonstrator.