Impact++

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

Author:
  • Collin Hover - collinhover.com
Source:
  1. // getting started with Impact++ is easy!
  2. // add the two basic scripts to the end of your game HTML file:
  3. // first the ImpactJS main script
  4. <script type="text/javascript" src="lib/impact/impact.js"></script>
  5. // then your game's main script
  6. <script type="text/javascript" src="lib/game/main.js"></script>
  7. // now inside your game's main script file
  8. // you'll set it up the same as when using ImpactJS
  9. // define the main module (script)
  10. ig.module(
  11. 'game.main'
  12. )
  13. // then require the other modules
  14. .requires(
  15. // to hook Impact++ into your game
  16. // all you need to do is require one module
  17. 'plusplus.core.plusplus',
  18. // then don't forget your levels
  19. 'game.levels.name'
  20. )
  21. // now define how your game starts up
  22. .defines(function () {
  23. // always use strict
  24. "use strict";
  25. // store the config in a local variable
  26. // this is a good pattern to follow in general
  27. var _c = ig.CONFIG;
  28. // now have your game extend ig.GameExtended
  29. var myGameClass = ig.GameExtended.extend({
  30. // game settings go here
  31. });
  32. // (optionally, add custom settings in 'plusplus/config-user.js')
  33. // then start the game as usual with your game and config
  34. ig.main(
  35. // you'll need a canvas element with an id of 'canvas'
  36. "#canvas",
  37. // your game class
  38. myGameClass,
  39. // this value does nothing
  40. 60,
  41. // the width / height / scale of your game
  42. // don't forget that Impact++ can scale dynamically
  43. // and can be resolution independent (see config)
  44. _c.GAME_WIDTH,
  45. _c.GAME_HEIGHT,
  46. _c.SCALE,
  47. // and the Impact++ customizable loader
  48. // within which you can easily change the logos!
  49. ig.LoaderExtended
  50. );
  51. // and whenever you create a new entity remember...
  52. // plain entities extend ig.EntityExtended
  53. var myEntityClass = ig.EntityExtended.extend({
  54. // entity settings go here
  55. });
  56. // and in a similar vein...
  57. // characters entities extend ig.Character
  58. // creature entities extend ig.Creature
  59. // particles entities extend ig.Particle
  60. // player entities extend ig.Player
  61. // and so on (we've got lots of abstracts)
  62. });
  63. // for a basic tutorial
  64. // check out the Jump n' Run example
  65. // in the "examples/jumpnrun" directory
  66. // or for a more advanced tutorial
  67. // check out the SUPER COLLIDER! example
  68. // in the "examples/supercollider" directory
  69. // which includes almost every feature in Impact++!