Impact++

Impact++ core that requires the primary modules and enhances ImpactJS's core.

Author:
  • Collin Hover - collinhover.com
Source:
// getting started with Impact++ is easy!
// add the two basic scripts to the end of your game HTML file:
// first the ImpactJS main script
<script type="text/javascript" src="lib/impact/impact.js"></script>
// then your game's main script
<script type="text/javascript" src="lib/game/main.js"></script>
// now inside your game's main script file
// you'll set it up the same as when using ImpactJS
// define the main module (script)
ig.module(
     'game.main'
)
// then require the other modules
.requires(
     // to hook Impact++ into your game
     // all you need to do is require one module
     'plusplus.core.plusplus',
     // then don't forget your levels
     'game.levels.name'
)
// now define how your game starts up
.defines(function () {

     // always use strict
     "use strict";

     // store the config in a local variable
     // this is a good pattern to follow in general
     var _c = ig.CONFIG;

     // now have your game extend ig.GameExtended
     var myGameClass = ig.GameExtended.extend({
         // game settings go here
     });

     // (optionally, add custom settings in 'plusplus/config-user.js')

     // then start the game as usual with your game and config
     ig.main(
         // you'll need a canvas element with an id of 'canvas'
          "#canvas",
          // your game class
          myGameClass,
          // this value does nothing
          60,
          // the width / height / scale of your game
          // don't forget that Impact++ can scale dynamically
          // and can be resolution independent (see config)
          _c.GAME_WIDTH,
          _c.GAME_HEIGHT,
          _c.SCALE,
          // and the Impact++ customizable loader
          // within which you can easily change the logos!
          ig.LoaderExtended
      );

     // and whenever you create a new entity remember...
     // plain entities extend ig.EntityExtended
     var myEntityClass = ig.EntityExtended.extend({
         // entity settings go here
     });
     // and in a similar vein...
     // characters entities extend ig.Character
     // creature entities extend ig.Creature
     // particles entities extend ig.Particle
     // player entities extend ig.Player
     // and so on (we've got lots of abstracts)

});
// for a basic tutorial
// check out the Jump n' Run example
// in the "examples/jumpnrun" directory
// or for a more advanced tutorial
// check out the SUPER COLLIDER! example
// in the "examples/supercollider" directory
// which includes almost every feature in Impact++!