class SGravitySystem extends System
{
public static function main ()
{
//This system will automatically recieve any entity containing
//CVelocity component(s)
EACH (entity, {
entity.CVelocity.vy += .10;
});
}
}
class SBounceSystem extends System
{
public static function main ()
{
//This system recieves any entity containing
//at least one CVelocity AND CPosition component
EACH (entity, {
//(Yes, this is very unoptimized. I wanted it readable)
if (entity.CPosition.x > 512)
{
entity.CVelocity.vx *= -.85;
}
else if (entity.CPosition.x < 0)
{
entity.CVelocity.vx *= -.85;
}
if (entity.CPosition.y > 512)
{
entity.CVelocity.vy *= -.85;
}
});
}
}
class SPhysicsSystem extends System
{
public function main ()
{
EACH (entity, {
entity.CPosition.x += entity.CVelocity.vx;
entity.CPosition.y += entity.CVelocity.vy;
});
}
}
class SRenderSystem extends System
{
public static function main (bmd:BitmapData)
{
bmd.fillRect (bmd.rect, 0x00000000);
EACH (entity, {
bmd.setPixel32 (
entity.CPosition.x,
entity.CPosition.y,
HAS(CColor, //Static conditional
entity.CColor.color,
0xFFFFFFFF)
);
});
}
}