So, let's think big here. Let's say you have an entire MMO you want to put together. Naturally, this involves a lot of resources from mobs, items, spritesheets, tilemaps, dialogue, characters, etc etc. In a typical game engine, you'd load or unload these resources based on some arbitrary designator, such as a map or "zone".
Is there a Javascript version of this? For example, would you be able to, while the game loop is running.
(pseudocode)
If playerPosition = theRightPlace {
Load Resources for Next Zone
Unload Resources for Previous Zone
}
Is there a performance gain in doing this? Or should you just load all resources for the game and be done with it? Say in some zones I have a class UglyMonster and in another zone I have UglierMonster.
I can instantiate these two classes either via John Resig's classical inheritance Class structure (which I've been using up until I hit this conversation starter, and which is handy for this kind of program)
var UglyMonster = Monster.extend({
Stuff why it is ugly;
Make a position!
Attack player!!!
});
var Monster1 = new UglyMonster();
or Function
function UglyMonster(name, position) {
Create Ugly Monster!!!! Attack player!
Stuff why it is ugly
}
var Monster1 = new UglyMonster('Fred', 100);
If I declare them all as Variables, all Monsters in the game are sitting in the Global variable, are they not? Is there a way to declare variables WITHOUT actually constructing them? I'm new to the whole Inheritance game in Javascript, so perhaps I'm missing something obvious.
What's the best way to handle these kinds of classes floating around? Leave them? Remove them? Instantiate via Functions? Does it make a noticeable difference?
I hope I've stated clearly enough what I hope to accomplish. Thank you!