이미지 덮기 게임

By adamlubek

This recipe demonstrates RxJS implementation of Uncover Image Game.

Ultimate RxJS

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