document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. class SGravitySystem extends System
  2. {
  3.     public static function main ()
  4.     {
  5.         //This system will automatically recieve any entity containing
  6.         //CVelocity component(s)
  7.         EACH (entity, {
  8.             entity.CVelocity.vy += .10;
  9.         });
  10.     }
  11. }
  12. class SBounceSystem extends System
  13. {
  14.     public static function main ()
  15.     {
  16.         //This system recieves any entity containing
  17.         //at least one CVelocity AND CPosition component       
  18.         EACH (entity, {
  19.             //(Yes, this is very unoptimized. I wanted it readable)
  20.             if (entity.CPosition.x > 512)
  21.             {
  22.                 entity.CVelocity.vx *= -.85;
  23.             }
  24.             else if (entity.CPosition.x < 0)
  25.             {
  26.                 entity.CVelocity.vx *= -.85;
  27.             }
  28.            
  29.             if (entity.CPosition.y > 512)
  30.             {
  31.                 entity.CVelocity.vy *= -.85;
  32.             }
  33.         });
  34.     }
  35. }
  36. class SPhysicsSystem extends System
  37. {
  38.     public function main ()
  39.     {              
  40.         EACH (entity, {
  41.             entity.CPosition.x += entity.CVelocity.vx;
  42.             entity.CPosition.y += entity.CVelocity.vy;         
  43.         });
  44.     }
  45. }
  46. class SRenderSystem extends System
  47. {
  48.     public static function main (bmd:BitmapData)
  49.     {
  50.         bmd.fillRect (bmd.rect, 0x00000000);
  51.         EACH (entity, {
  52.             bmd.setPixel32 (
  53.                 entity.CPosition.x,
  54.                 entity.CPosition.y,
  55.                 HAS(CColor,             //Static conditional
  56.                     entity.CColor.color,
  57.                     0xFFFFFFFF)
  58.             );
  59.         });
  60.     }
  61. }
');