<commit_before><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />

  <title> axis.js demo </title>

  <style>

    html {
      display: table;

      width: 100%;
      height: 100%;
    }

    body {
      display: table-cell;

      vertical-align: middle;
      text-align: center;

      overflow: hidden;
    }
  </style>

</head>
<body>

  <canvas>You need a browser that supports the Canvas element</canvas>
  <script>
    (function(){
      var canvas = document.querySelector('canvas'),
          ctx = canvas.getContext('2d');
      ctx.textAlign = 'center';
      ctx.fillText('Loading...', canvas.width/2, canvas.height/2);
    })();
  </script>

  <script src="../intersect/intersect.js"></script>
  <script src="../src/axis2d.js"></script>
  <script src="../src/axis2d.world.js"></script>
  <script src="../src/axis2d.collider.js"></script>
  <script src="../src/axis2d.debugdraw.js"></script>

  <script src="demo.world.js"></script>
  <script src="demo.inputs.js"></script>
  <script src="demo.canvasrenderer.js"></script>
  <script src="demo.entitymanager.js"></script>
  <script src="demo.entity.js"></script>

  <script>
(function(){
  // paul irish shim
  var requestAnimFrame = (function(){
    return  window.requestAnimationFrame       ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            function( callback ){
              setTimeout(callback, 1000 / 60);
            };
  })();

  var width = 768,
      height = 576,
      canvas = document.querySelector('canvas'),
      renderer = new DEMO.CanvasRenderer(canvas, width, height),
      axisWorld = new DEMO.World({
        renderer: renderer,
        debug: true
      });

  function onWindowResize() {
    renderer.scaleTo(window.innerWidth, window.innerHeight);
  }

  window.addEventListener('resize', onWindowResize);

  // first run
  onWindowResize();

  axisWorld
    .createCollisionMap([
      [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1]
    ]);

  axisWorld
    .createEntity(160, 160)
      .setCollider(100, 100)
      .setUserData({
        foo: 123,
        speed: 15,
        bar: function() {
          return this.foo;
        }
      })
      .setLoop(function() {
        var dirX = 0,
            dirY = 0;

        if(DEMO.inputs.key['87'] || DEMO.inputs.key['38']) {
          dirY = -1;
        }
        else if(DEMO.inputs.key['83'] || DEMO.inputs.key['40']) {
          dirY = 1;
        }
        if(DEMO.inputs.key['65'] || DEMO.inputs.key['37']) {
          dirX = -1;
        }
        else if(DEMO.inputs.key['68'] || DEMO.inputs.key['39']) {
          dirX = 1;
        }

        dirX *= this.userData.speed;
        dirY *= this.userData.speed;

        this.moveTo(this._position.x + dirX, this._position.y + dirY);

        if(this.world._frameCount === 50) {
          this.moveTo(width, height);
        }
      })
      .onCollision(function(hits){
        console.log('player', hits);
      });

  axisWorld
    .createEntity(width/2, height/2)
      .setCollider(120, 100, true)
      .setUserData({
        left: true
      })
      .setLoop(function(){
        /*
        var xSpeed = 0;

        if(this._position.x < 250) {
          this.userData.left = false;
        }
        else if(this._position.x > width - 250) {
          this.userData.left = true;
        }

        xSpeed = this.userData.left ? -2 : 2;

        this.moveTo(this._position.x + xSpeed, this._position.y);
        */

        /*
        if(this.world._frameCount % 500 === 0) {
          if(this.collider.isSensor()) {
            this.collider.setSensor(false);
          }
          else {
            this.collider.setSensor(true);
          }
        }
        */
      })<commit_msg>dynamic/dynamic and sensor/dynamic tests<commit_after><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />

  <title> axis.js demo </title>

  <style>

    html {
      display: table;

      width: 100%;
      height: 100%;
    }

    body {
      display: table-cell;

      vertical-align: middle;
      text-align: center;

      overflow: hidden;
    }
  </style>

</head>
<body>

  <canvas>You need a browser that supports the Canvas element</canvas>
  <script>
    (function(){
      var canvas = document.querySelector('canvas'),
          ctx = canvas.getContext('2d');
      ctx.textAlign = 'center';
      ctx.fillText('Loading...', canvas.width/2, canvas.height/2);
    })();
  </script>

  <script src="../intersect/intersect.js"></script>
  <script src="../src/axis2d.js"></script>
  <script src="../src/axis2d.world.js"></script>
  <script src="../src/axis2d.collider.js"></script>
  <script src="../src/axis2d.debugdraw.js"></script>

  <script src="demo.world.js"></script>
  <script src="demo.inputs.js"></script>
  <script src="demo.canvasrenderer.js"></script>
  <script src="demo.entitymanager.js"></script>
  <script src="demo.entity.js"></script>

  <script>
(function(){
  // paul irish shim
  var requestAnimFrame = (function(){
    return  window.requestAnimationFrame       ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            function( callback ){
              setTimeout(callback, 1000 / 60);
            };
  })();

  var width = 768,
      height = 576,
      canvas = document.querySelector('canvas'),
      renderer = new DEMO.CanvasRenderer(canvas, width, height),
      axisWorld = new DEMO.World({
        renderer: renderer,
        debug: true
      });

  function onWindowResize() {
    renderer.scaleTo(window.innerWidth, window.innerHeight);
  }

  window.addEventListener('resize', onWindowResize);

  // first run
  onWindowResize();

  axisWorld
    .createCollisionMap([
      [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      [1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1]
    ]);

  axisWorld
    .createEntity(160, 160)
      .setCollider(100, 100)
      .setUserData({
        foo: 123,
        speed: 15,
        bar: function() {
          return this.foo;
        }
      })
      .setLoop(function() {
        var dirX = 0,
            dirY = 0;

        if(DEMO.inputs.key['87'] || DEMO.inputs.key['38']) {
          dirY = -1;
        }
        else if(DEMO.inputs.key['83'] || DEMO.inputs.key['40']) {
          dirY = 1;
        }
        if(DEMO.inputs.key['65'] || DEMO.inputs.key['37']) {
          dirX = -1;
        }
        else if(DEMO.inputs.key['68'] || DEMO.inputs.key['39']) {
          dirX = 1;
        }

        dirX *= this.userData.speed;
        dirY *= this.userData.speed;

        this.moveTo(this._position.x + dirX, this._position.y + dirY);

        if(this.world._frameCount === 50) {
          this.moveTo(width, height);
        }
      })
      .onCollision(function(hits){
        console.log('player', hits);
      });

  axisWorld
    .createEntity(width/2, height/2)
      .setCollider(120, 100, true)
      .setUserData({
        left: true
      })
      .setLoop(function(){
        var xSpeed = 0;

        if(this._position.x < 250) {
          this.userData.left = false;
        }
        else if(this._position.x > width - 250) {
          this.userData.left = true;
        }

        xSpeed = this.userData.left ? -2 : 2;

        this.moveTo(this._position.x + xSpeed, this._position.y);

        if(this.world._frameCount % 500 === 0) {
          if(this.collider.isSensor()) {
            this.collider.setSensor(false);
          }
          else {
            this.collider.setSensor(true);
          }
        }
      })
{'fraction_non_alphanumeric': 0.17438026621077055, 'fraction_numerical': 0.04786909268530956, 'mean_word_length': 1.8980891719745223, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5582212', 'n_tokens_mistral': 3194, 'n_tokens_neox': 2829, 'n_words': 637}