Entity based game engine in javascript