HeatGub / TS-object-pool-game

JS game coding tutorials rewritten to TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object pool asteroid game - TypeScript

This code is mainly the one you can find under source links (with minor changes), but rewritten from JavaScript to TypeScript. Made for coding practise and enjoyment.

Overwiew

  • Object oriented code with object pool optimization which eliminates JS garbage collection.

  • Click an asteroid to gain a point. Collect 10 point to save the universe and admire the magnificent winning text.

  • Run a server for dist/index.html to play.

Object pools

  • Object pools (asteroidPool and explosionPool) are lists of objects of given length. These pools are being initialized in the Game class constructor. Instead of being created and deleted, objects are just turned back to the initial state. Therefore garbage collection wont have a reason to happen, which is an advantage, especially in calculation-heavy moments.

  • Pool's length have to be carefully chosen. You can only have as many instances as pool length. If the pool length is too long, memory is needlessly used.

Sources

Thanks

to Frank's laboratory for sharing the knowledge

About

JS game coding tutorials rewritten to TypeScript


Languages

Language:TypeScript 100.0%