Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wiringbits/scala-js-games

Simple games ported to Scala.js (Scala 3)
https://github.com/wiringbits/scala-js-games

hacktoberfest scala scala3 scalajs

Last synced: 5 days ago
JSON representation

Simple games ported to Scala.js (Scala 3)

Awesome Lists containing this project

README

        

# Scala.js Games (Scala 3)

This is a collection of games ported from Scala 2 to Scala.js (Scala 3): the [source](https://github.com/wiringbits/scala-js-games) for each game is written in Scala, and [Scala.js](https://scala-js.org) cross compiled to run in the browser targeting the [HTML5 Canvas](https://developer.mozilla.org/en-US/docs/HTML/Canvas). The original games can be found [here](https://github.com/lihaoyi/scala-js-games) and targeting Scala 2.

[Live demo](https://scalajs-games.wiringbits.net)

The games are, in order:



  • Asteroids: shoot down the asteroid swarms and avoid getting hit!


  • Astrolander: bring your lander to a a gentle landing on flat ground before you run out of fuel.


  • Snake: eat apples to grow long and don't crash into walls!


  • Pong: outsmart your AI opponent to get the ball past his paddle (right) to score points!


  • Brick: use your paddle to bounce the ball up, destroying all the bricks before you run out of balls.


  • Tetris: collect points by clearing rows and don't let the screen fill with blocks.


The controls are generally up-down-left-right and spacebar; they
aren't very complex games. Click on a game to start playing and click
somewhere else to pause it.

## How to build
- Install [sdkman](https://sdkman.io) - or, make sure to pick the correct java version (see [.sdkmanrc](.sdkmanrc)).
- Install [nvm](https://github.com/nvm-sh/nvm) - or, make sure to pick the correct node version (see [.nvmrc](.nvmrc)).
- Install [sbt](https://www.scala-sbt.org/).
- Clone the repo.
- Run `sbt fastLinkJS` (just to make sure the app compiles).
- Run `npm install` to install the js dependencies.
- Run `npm run dev` to launch the dev server, then, open `http://localhost:3000` to load the app.
- Run `npm run build` to prepare the production build.

## Scala.js bundle size

The bundle size is ~600kb, ~100kb compressed:

![sjs-games-code-size](./docs/images/sjs-games-code-size.png)