Abstracting Sphere's Map engine person objects
I've been working on a simple library to treat Sphere Persons as javascript objects, rather than having to interface with the map engine's functions. So for example, instead of doing
function game() {
CreatePerson("player","player.rss",destroy_with_map);
AttachCamera("player");
AttachInput("player");
// ...
player_obstructed = IsPersonObstructed("player", GetPersonX("player"), GetPersonY("player"));
direction = GetPersonDirection("player");
QueuePersonCommand("player", COMMAND_MOVE_SOUTH, true);
etc, which can be rather tedious after a while, you would instead do (as it is now)
var player;
function game() {
player = new Person ("player","player.rss",destroy_with_map);
player.attachCamera();
player.attachInput();
// ...
player_obstructed = player.isObstructed(player.x,player.y);
direction = player.getDirection();
player.queueCommand(COMMAND_MOVE_SOUTH,true);
And so on and so forth. This would also make it simpler to create custom update/render functions and custom properties per-person by doing person_object.update = function() {} as desired
Instead of using GetPersonList, you would just reference the persons[] array.
Do you think this is a good way of doing things? Would the new minisphere API benefit from using this method as opposed to the old way? I'd post this in minisphere's engine update thread, but I wanted to make this thread to ask for your guys' opinions on this method in general.