domasx2/banditracer-client — comment on commit 9f042f3d863e6d249c8f99e69fedab42346a0ac7
File:  line 0
By domasx2:

Hey Simon,

Get ready for a long-winded ramble :)

As I might have mentioned a few dozen times, my approach to making Bandit
Racer was to do it quick and dirty, and once I'm sure how the pieces are
supposed to fit in the end, rewrite it nice and clean. I think that at this
time I have a pretty decent image in my mind of how the game (or any
similar game) should be structured. Now I'm trying to extract core concepts
into a generic higher level game engine, both for use in Bandit Racer and
for my future projects.

Roughly, high level goals are:

- base implementations of core concepts, like game world, game object
- thin abstraction over box2d to do away with most of tedious boiler
plate, data type conversions between box2d and gamejs
- resource caching/processing framework
- infrastructure for game world serialization & synchronisation for
multiplayer
- renderer implementation to provide a viewport into the game world with
ability to follow object, zoom, render objects in layers, some most common
render implementations for rendering objects, animations
- director / scene management
- general scaffolding for a game

So, lofty goals :) All of this is already implemented in Bandit Racer in
one way or another. Just need to refactor away abstract concepts from
game-specific stuff, and clean it up a lot.

With this commit things I added:

Object - a base classs all game obejcts are derived from

Entity - a base class for a physical in-game object
World - base game world class that handles creation, destruction and
interaction of its objects, in a discrete and serializable way

>>> +Object.prototype.AM_OBJECT = true; //HAHAH IM A DUMBASS. srsly, dont
know better way.
>
> what do you need that for? to check whether an instance has
`engine.Object` in the prototype chain?
Yup. I don't remember why I neglected to google it at the time. Don't look
at it, my shame is overwhelming!

> i was a bit shocked to see you overwrite the standard JS `Object`, i
would have called it `EngineObject` or something but i don't fully
understand what you do, yet :)
I prefer overwriting a key variable in the scope of object.js rather than
having to write engine.EngineObject a bunch of times :) Might be there are
some risks i'm unaware of. If so, let me know :/

This commit resolved the worst problem with BR code, lack of proper class
hierarchy and physics abstraction. My next immediate goal is to properly
enable sound, for which I'm thinking of Web Audio API with fallback to
Audio object. Did you consider implementing Web Audio into gamejs?

--
Domas