Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by Jerczu

I am just wondering how do you guys code your game logic? I am in the middle of developing my newest game in which I have multiple entities spawning another entities and I do the random pick of the spawner in the main.js and depending on the result (whether spawner can spawn or not) I spawn the entities or choose another one. Of course I could do that from the within the spawner or replace this with timer activated spawns but I am wondering from the performance point of view which approach is better (logic in main.js or within entity)

8 years ago by alexandre

SpawnFactory? I may be talking through my hat (never touched js before but have experience with other languages) but could this not even be turned into some (SpawningRandomizer?) plugin? How useful that would be is debatable, though.

8 years ago by yatayata

it would seem you want to keep logic out of main as much as possible, or main will just continue to bloat...

if you have a functionality thats shared between sprites you can create class hierarchy with impacts include/requires system, or you could create common functions as a plugin and inject into the required classes.

the guys from subsonic LLC gave a good presentation on their javascript game engine + components architecture, but their site seems to be down just right now:
http://sonargame.com/news/page/2/

8 years ago by fugufish

@yatayata did you mean this? http://sonargame.com/2011/06/28/component-based-game-objects-in-javascript/ . Was an awesome read, thanks!

8 years ago by Jerczu

Awesome read thanks...

8 years ago by yatayata

that site seems to be down for me always...

anyway here's an example of how to inject functions into an entity:

ig.module('plugins.pikkle.patches').
requires('impact.game', 'impact.entity', 'game.entities.tourbus').
defines(
  function() {

    Mixins = {};
    Mixins.gauge = function() {
      console.log("mixin:gauge");
    }

    EntityTourbus.prototype.gauge = Mixins.gauge;
    // could add to other entities here...

});

that has the advantage to keep functionality in modules, similar to ruby's mixins. I really like that approach over subclassing etc. as you can just cherry pick the features you need.
Page 1 of 1
« first « previous next › last »