1 Reply Latest reply on Apr 10, 2007 1:58 PM by gregmax17

    Tile Help...I don't know whats wrong

    gregmax17
      I learning how to make worlds with the help of tiles and Tonypa. I am in the scrolling tutorial and I believe I am following everything but apparently not! For some reason it will not generate the surrounding tiles around the hero/char when it is moving (it works fine when it firsts builds the map, its the walking/scrolling part that doesn't). Here it was I have:

      (at the bottom of move char)
      game.clip._x = game.center_x - obj.x;
      game.clip._y = game.center_y - obj.y;
      if(obj.x_step < (obj.x - game.t_size)) {
      var x_tile = Math.floor(obj.x_step / game.t_size) + 1;
      var x_new = x_tile + int(game.visible_x/2) + 1;
      var x_old = x_tile - int(game.visible_x/2) - 1;
      for(var i = (obj.y_tile - int(game.visible_y/2)-1); i < (obj.y_tile + int(game.visible_y/2)+1); i++) {
      change_tile(x_old, i, x_new, i);
      }
      obj.x_step += game.t_size;
      } else if(obj.x_step > obj.x) {
      var x_tile = Math.floor(obj.x_step / game.t_size);
      var x_old = x_tile + int(game.visible_x/2) + 1;
      var x_new = x_tile - int(game.visible_x/2) - 1;
      for(var i = (obj.y_tile - int(game.visible_y/2)-1); i < (obj.y_tile + int(game.visible_y/2)+1); i++) {
      change_tile(x_old, i, x_new, i);
      }
      obj.x_step -= game.t_size;
      }
      if(obj.y_step < (obj.y - game.t_size)) {
      var y_tile = Math.floor(obj.y_step / game.t_size) + 1;
      var y_new = y_tile + int(game.visible_y/2) + 1;
      var y_old = y_tile - int(game.visible_y/2) - 1;
      for(var i = (obj.x_tile - int(game.visible_x/2)-1); i < (obj.x_tile + int(game.visible_x)+1); i++) {
      change_tile(i, y_old, i, y_new);
      }
      obj.y_step += game.t_size;
      } else if(obj.y_step > obj.y) {
      var y_tile = Math.floor(obj.y_step / game.t_size);
      var y_old = y_tile + int(game.visible_y/2) + 1;
      var y_new = y_tile - int(game.visible_y/2) - 1;
      for(var i = (obj.x_tile - int(game.visible_x/2)-1); i < (obj.x_tile + int(game.visible_x)+1); i++) {
      change_tile(i, y_old, i, y_new);
      }
      obj.y_step -= game.t_size;
      }

      (and the change_tile function)

      function change_tile(x_old, y_old, x_new, y_new) {

      var old_nm = "t_" + y_old + "_" + x_old;
      var new_nm = "t_" + y_new + "_" + x_new;

      if(y_new >= 0 and x_new >= 0 and y_new <= _root.walk.length-1 and x_new <= _root.walk[0].length-1) {

      game[new_nm] = new game["walk_" + _root.walk[y_new][x_new]]();
      game.clip[old_nm]._name = new_nm;
      game.clip[new_nm].gotoAndStop(game[new_nm].frame);
      game.clip[new_nm]._x = (x_new * game.t_size);
      game.clip[new_nm]._y = (y_new * game.t_size);

      } else {

      game[new_nm] = new game.walk_2();
      game.clip[old_nm]._name = new_nm;
      game.clip[new_nm].gotoAndStop(game[new_nm].frame);

      }


      }

      I appreciate any help given, thanks in advance!