The document discusses architectures for multiplatform game development. It proposes a three layer architecture with platform, core, and physics layers. The platform layer handles platform-specific code, the core layer focuses on game logic and behavior, and the physics layer manages collisions. This ensures consistent behavior by having only one core codebase. It allows rewriting only the platform layer for different platforms. Tests can target the core directly and need only be written once. The approach guarantees behavior consistency, has no framework dependencies, and makes porting efforts clear by separating concerns into layers.
7. Architeture
Sprite.prototype.update = function (delta) {
// update position, animation, ...
};
Sprite.prototype.draw = function (context) {
< // draw on the screen
};
function mainLoop () {
for (var i in sprites) {
sprites[i].update();
sprites[i].draw();
}
}
Sprite's update deals with UI (platform-dependent) and
behavior (platform-independent)
8. What kinds of problems do we
face with this kind of
architecture?
11. The velocity needs to be
scaled
1. Before setting the sprite parameter:
2. Inside the sprite's update:
var rect = new RectSprite();
rect.velocity = config.velocity / UI.SCALE;
RectSprite.prototype.update = function (delta) {
this.x += (this.velocity / UI.SCALE) * delta;
};
32. Core
Elements are entities that have a group of bodies
Interactions are input events and collisions between entities
33. UI
Elements are sprites that display an entity
No interactions, only forwarding of events (the UI doesn't alter the
game)
34. How do we use it in multiple
platforms?
Rewrite only the Platform layer
35. Summary
Behavior consistency guaranteed by having only one code for
behavior
No framework dependency, making it easy to translate to other
languages (C++?)
Tests are easier to write (no frameworks) and need to be written
once (one code)
Porting effort is clear