I put 23 card and board games in the browser: Scissor Games. They are written in Rust, compiled to WebAssembly and drawn with WebGL 2. There is no game engine in it and no physics engine either.

A deal of Solitaire, then the last cards go up and the deck flies apart

What is in it

There are 17 kinds of solitaire (Klondike, Spider, FreeCell, Pyramid, Golf, Yukon and others) and six board games: Chess, Checkers, Backgammon, Mahjong, Sudoku and Minesweeper.

All 23 run from one wasm file. It is 1.16 MB on disk and about 570 KB over the network with Brotli. The Rust is about 12,400 lines.

The dependency list is short:

[dependencies] wasm-bindgen = "=0.2.129" js-sys = "0.3" web-sys = "0.3" glam = "0.34" console_error_panic_hook = "0.1" 

glam does the vector maths. Everything that touches the page or the GPU goes through web-sys.

Cards on springs

Each card has a place it wants to be and a spring that pulls it there. A card at rest uses a stiffness of 160. When you drag a run of cards, the first one follows the pointer with a stiffness of 700, and each card behind it gets less:

c.k = 700.0 / (1.0 + 0.3 * i as f32); 

That is why a dragged run trails behind the pointer.

When you win, the springs are switched off. Every card gets a random spin and is let go:

c.physics = true; c.spin = Vec3::new(rng.range(-4.0, 4.0), rng.range(-9.0, 9.0), rng.range(-9.0, 9.0)); 

One table, many games

The 17 card games share one scene. A game is a type that implements a Rules trait: where the piles sit (slots), which cards may be picked up (can_pick), where they may be dropped (can_drop), and so on. The scene knows nothing about Klondike or Spider. The board games each have a scene of their own.

No text in the engine

The engine draws no text. Card faces are painted once with a 2D canvas into a sheet of 9 by 6 cards, 455 x 637 pixels each, and uploaded as one texture. The counters, the buttons and the result card are ordinary HTML over the canvas. That is how the site comes in 30 languages, right-to-left ones included, without a font renderer in the wasm.

Shadows

Cards cast soft shadows. The table shader looks up a shadow map, searches 16 Poisson samples for blockers, then takes 16 more with a radius that grows with the distance to the blocker. A card lifted off the table gets a wider, softer shadow than one lying flat.

Phones

On a phone the buttons fold into a menu, and there is a large-print deck with bigger numbers for small screens.

Try it

games.scissor.studio/solitaire

It is free, with no account and no ads. Each card game has a deal of the day that is the same for everyone.

I would like to hear where it feels wrong, especially on phones.