Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Uncover Image Game

By adamlubek

This recipe demonstrates RxJS implementation of Uncover Image Game.

Example Code

( StackBlitz )

index.ts

// RxJS v6+
import { interval } from 'rxjs';
import { finalize, scan, takeWhile, tap, withLatestFrom } from 'rxjs/operators';
import { keyboardEvents$ } from './keyboard';
import { initialGame, updateGame, isGameOn } from './game';
import { paintGame, paintGameOver } from './html-renderer';

interval(15)
  .pipe(
    withLatestFrom(keyboardEvents$),
    scan(updateGame, initialGame),
    tap(paintGame),
    takeWhile(isGameOn),
    finalize(paintGameOver)
  )
  .subscribe();

game.ts

player.ts

enemy.ts

keyboard.ts

interfaces.ts

constants.ts

html-renderer.ts

index.html

Operators Used

Last updated