GithubHelp home page GithubHelp logo

gameutils's Introduction

GameUtils

A few utilities usefull when writing games in typescript.

geometry stuff

  • Vec2: An immutable 2 dimensional vector class with helper for length, angle and basic operations
  • Line: A class representing a line segment (defined by two vectors), support for collision with other line, rect, test if a point is on the line
  • Rect: A Rectangle class, which can be built from multiple criteria such as size, position, center, etc... With support for collision and inclusion

events

  • IEmitter, IListener: interfaces for a pub-sub system
  • Emitter: general purpose concretion of IEmitter
  • FListener: concretion of IListener to use with callbacks

state/data

  • LiveData: a wrapper around any value which can send events to listeners when the value changes. Can be used to centralize some value in one place then have multiple component react to value changes
  • AbstractFsm: a base class for a finite state machine, with live check that no illegal transition is happening. Can be used with enums as the states
  • LiveDataFsm: a concrete fsm which wraps the state object in a livedata object which can be subscribed to outside of the fsm
  • ObservableFsm: Variant of the LiveDataFsm where the fsm itself is an event emitter (ie you can subscribe a listener to the fsm's state changes)

utils

  • assert: throws an exception if passed an expression whic evaluates to false, can be used as a sanoty check
  • sum: sums together all element of an array (works with numbers only)
  • all: return true if all elements in an array are truthy
  • any: return true if at least one element in an array is truthy
  • range: return an array filled with numbers from 0 to i (non-inclusive). This is not base on generators/iterators and will create the whole array eagerly

others

  • Cooldown: an object which takes track of time elasped between two uses of a feture and allow to rate limit the usage
  • TagManager: an object which helps in managing multiple strings as tags for something else

gameutils's People

Contributors

maxlarue avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.