so-called endless scene - multi-tile/actor objects


for more info about diagnosis drawings https://stencyl-nator.blogspot.com/p/diagnosis-drawing.html

Introduction: 
This Stencyl logic is involved in so-called endless/infinite scenes. this time in multiple tile/actor objects. which each object may consist of multiple actor 

Prerequisutes 
so-called endless scenes of any versions for single tile/actor objects. most of the functions are the same but in this pre-creation process will be more complecated and the ways to interact with the object will be way more complex. This logic uses the entire so-called endless scenes for one tile objects plus pre-creation process whics is most of the code. 

contents
This logic will use 1 scene behavior which extends SceneScript and 1 custom code. the scene behavior is a modified version of https://stencyl-nator.blogspot.com/p/so-called-endless-scene-code-mode.html which will use the custom code which most of the code will be in. 

In this case, both codes has drawing without using G. So to use these codes you need to first understand the drawing without using G. 

The scene behavior = 1-tile rendering system for floors.
The cusotm code = milti-tile rendering system for objects. 

The object id0 and id1 will be used for interaction purposes for as said before, the object may consist of multiple tiles thus actors  For example, each object will have its own armor and hitpoint and drops. Which actors belong to which object? 

The pre-creation process 
As menstioned before, the pre-creation is the addition This accounts for the adjacent actor/tile considerations which most of the code is about which is in custom code. 

codes
the scene behavior which generates the floors

package scripts;
import com.stencyl.Engine; 
import com.stencyl.behavior.SceneScript; // all Scene Behaviors entend SceneScript
import com.stencyl.behavior.Script; 
import com.stencyl.behavior.TimedTask;  // for post-initilisation and update rates
import com.stencyl.models.Scene;
import com.stencyl.models.Actor;
import com.stencyl.utils.motion.Easing;
import scripts.Interbehav;

import scripts.Conte;
class Sur_sce_behav extends SceneScript
{
public var texts:Array<Dynamic>=[]; public var cheklag: Int = 0; public var shifting:Bool = false; 
public var sceh:Float = Engine.sceneHeight; public var scew:Float = Engine.sceneWidth; 
public var scrh:Float = Engine.screenHeight; public var scrw:Float = Engine.screenWidth;
public var player:Actor; public var player_positile_x:Int; public var player_positile_y:Int;  
public var offsx:Float=0; public var offsy:Float=0; 
public var obdat:Objdata_3 = new Objdata_3(); //object data - moved to other script as a variable. 

public var marg_xmax:Float; public var marg_xmin:Float; 
        public var marg_ymax:Float; public var marg_ymin:Float;  
public var last_created_ground:Actor; 
public var initile_xmax:Int; public var initile_xmin:Int;
public var initile_ymax:Int; public var initile_ymin:Int; 
public var half_scrh:Float = Engine.screenHeight/2; public var half_scrw:Float = Engine.screenWidth/2;
public var half_sceh:Float = Engine.sceneHeight/2; public var half_scew:Float = Engine.sceneWidth/2;
public var grdat_ids_nxny:Array<Dynamic>; public var grdat_ids_nxpy:Array<Dynamic>; 
        public var grdat_ids_pxny:Array<Dynamic>; public var grdat_ids_pxpy:Array<Dynamic>;
public var grdat_rfl_nxny:Array<Dynamic>; public var grdat_rfl_nxpy:Array<Dynamic>; 
        public var grdat_rfl_pxny:Array<Dynamic>; public var grdat_rfl_pxpy:Array<Dynamic>;
public var grdat_rot_nxny:Array<Dynamic>; public var grdat_rot_nxpy:Array<Dynamic>; 
        public var grdat_rot_pxny:Array<Dynamic>; public var grdat_rot_pxpy:Array<Dynamic>;
public var grdat_actors:Array<Dynamic>;

//diagnosis data. For diagnosis only. not to be used in real game. 
public var diag_create_x:Float; public var diag_create_y:Float; public var diag_noa:Int;  public var diag_last_created_ids:String="";
public var diag_rny:Int; public var diag_counter:Int = 0; public var aon:Int =0; 

public var camx:Float; public var camy:Float;  //refers to camera positions
public var upd:Bool = false// gate for upadate
public function new(u0:Int, u1:Engine){super();}
override public function init()
{
//create buttons
Script.createRecycledActor(Script.getActorType(72),this.scrw-90,0,Script.FRONT);
Script.createRecycledActor(Script.getActorType(78),this.scrw-90,55,Script.FRONT);

//setting drawing parameters bypassing G
this.texts[0] = new F(); this.texts[0].c = 16777215; this.texts[0].f_cu = Script.getFont(19);
this.texts[1] = new F(); this.texts[0].c = 16777215; this.texts[1].f_cu = Script.getFont(19); 
this.add_def(def); 
this.add_dra(diag_drawing);
this.sceh = Engine.sceneHeight; this.scew = Engine.sceneWidth;
this.scrh = Engine.screenHeight; this.scrw = Engine.screenWidth;  
this.half_sceh = Engine.sceneHeight/2; this.half_scew = Engine.sceneWidth/2;  
Script.createRecycledActorOnLayer(Conte.player_part("legs"),this.scew*0.5-96,this.sceh*0.5-64, Engine.engine.getLayerById(2)); // create player legs
this.player = Script.lastCreatedActor; 
this.load_sce();
}
public function add_def(a:Dynamic):Void{Engine.engine.whenUpdatedListeners.push(a);}
public function add_dra(a:Dynamic):Void{Engine.engine.whenDrawingListeners.push(a);}

public function create_ground(a:String, x:Float, y:Float) // an optimsed way of create actors
{
var b:Actor = Engine.engine.getRecycledActorOfTypeOnLayer(Conte.grdat_actorType(a), x, y,0); this.last_created_ground = b;
}
public function def():Void
{
this.cheklag += 1; if(this.cheklag > 2147400000){this.cheklag = -2147400000;}
Engine.engine.cameraFollow(this.player);
if(this.upd)
{
this.upd = false
this.camx = Engine.cameraX; this.camy = Engine.cameraY; 
this.marg_xmax = this.half_scew + this.initile_xmax*64 + this.offsx - this.camx - this.scrw;
this.marg_xmin = this.camx - this.half_scew - this.initile_xmin* 64 - this.offsx;
this.marg_ymax = this.half_sceh + this.initile_ymax*64 + this.offsy - this.camy - this.scrh;
this.marg_ymin = this.camy - this.half_sceh - this.initile_ymin* 64 - this.offsy;
if(!(this.shifting))
{
if(this.marg_xmax < 128){
this.popu_grdat_vert(this.initile_xmax); 
this.obdat.rpx(this.initile_xmax,this.initile_ymax,this.initile_ymin); 
this.initile_xmax +=1;
}
else if(this.marg_xmax > 192){
this.initile_xmax -=1; 
this.obdat.remo_rpx(this.initile_xmax,this.initile_ymax,this.initile_ymin);
this.remo_grdat_vert(this.initile_xmax);
}
if(this.marg_xmin < 128){
this.initile_xmin -=1; 
this.popu_grdat_vert(this.initile_xmin);
this.obdat.rnx(this.initile_xmin,this.initile_ymax,this.initile_ymin); 
}
else if(this.marg_xmin > 192)
{this.remo_grdat_vert(this.initile_xmin); 
this.obdat.remo_rnx(this.initile_xmin,this.initile_ymax,this.initile_ymin);
this.initile_xmin +=1;
}
if(this.marg_ymax < 128){
this.obdat.rpy(this.initile_ymax,this.initile_xmax,this.initile_xmin);
this.popu_grdat_horz(this.initile_ymax); 
this.initile_ymax +=1;
}
else if(this.marg_ymax > 192){
this.initile_ymax -=1;
this.remo_grdat_horz(this.initile_ymax); 
this.obdat.remo_rpy(this.initile_ymax,this.initile_xmax,this.initile_xmin);
}
if(this.marg_ymin < 128){
this.initile_ymin -=1;
this.popu_grdat_horz(this.initile_ymin); 
this.obdat.rny(this.initile_ymin,this.initile_xmax,this.initile_xmin);
}
else if(this.marg_ymin > 192){
this.remo_grdat_horz(this.initile_ymin); 
this.obdat.remo_rny(this.initile_ymin,this.initile_xmax,this.initile_xmin);
this.initile_ymin +=1;
}

if(this.camx < 128){this.shift_xinc();this.obdat.shift_px(this.initile_xmax,this.initile_xmin,this.initile_ymax,this.initile_ymin);}
else if(this.scew - this.camx - this.scrw < 128){this.shift_xdec(); this.obdat.shift_nx(this.initile_xmax,this.initile_xmin,this.initile_ymax,this.initile_ymin);}
if(this.camy < 128){this.shift_yinc();this.obdat.shift_py(this.initile_xmax,this.initile_xmin,this.initile_ymax,this.initile_ymin);} // it is shifting the actor by half a screen; 
else if(this.scew - this.camy - this.scrh < 128){this.shift_ydec(); this.obdat.shift_ny(this.initile_xmax,this.initile_xmin,this.initile_ymax,this.initile_ymin);}
}
Script.runLater(125,update,null);
}
}

public function diag_drawing() //for bug diagnosis
{
this.texts[0].ds("check lag: "+this.cheklag,5,0); this.texts[1].ds("number of actors: " + this.diag_noa + " diagcount:" + this.diag_counter,300,0);
this.texts[1].ds("camx: "+this.camx,5,20);
this.texts[1].ds("camy: "+this.camy,5,40);
this.texts[1].ds("initile_xmax: "+this.initile_xmax,5,70);
this.texts[1].ds("initile_xmin: "+this.initile_xmin,5,90);
this.texts[1].ds("initile_ymax: "+this.initile_ymax,5,110);
this.texts[1].ds("initile_ymin: "+this.initile_ymin,5,130);
this.texts[1].ds("marg_xmax: "+this.marg_xmax,5,160);
this.texts[1].ds("marg_xmin: "+this.marg_xmin,5,180);
this.texts[1].ds("marg_ymax: "+this.marg_ymax,5,200);
this.texts[1].ds("marg_ymin: "+this.marg_ymin,5,220);
this.texts[1].ds("offsx: "+this.offsx,5,240);
this.texts[1].ds("offsy: "+this.offsy,5,260);
this.texts[1].ds("player x: "+this.player.getX(),5,280);
this.texts[1].ds("player y: "+this.player.getY(),5,300);
this.texts[1].ds("diag_rny: "+this.diag_rny,5,320);
this.obdat.diagnosis_data(5,350); 
}
public function init_data() // initialise all data arrays. 
{ //ground data. 
if(this.grdat_actors == null||""+this.grdat_actors =="undefined"){this.grdat_actors = [];}
if(this.grdat_ids_nxny == null||""+this.grdat_ids_nxny=="undefined"){this.grdat_ids_nxny = [];}
if(this.grdat_ids_nxpy == null||""+this.grdat_ids_nxpy=="undefined"){this.grdat_ids_nxpy = [];}
if(this.grdat_ids_pxny == null||""+this.grdat_ids_pxny=="undefined"){this.grdat_ids_pxny = [];}
if(this.grdat_ids_pxpy == null||""+this.grdat_ids_pxpy=="undefined"){this.grdat_ids_pxpy = [];}
if(this.grdat_rfl_nxny == null||""+this.grdat_rfl_nxny=="undefined"){this.grdat_rfl_nxny = [];}
if(this.grdat_rfl_nxpy == null||""+this.grdat_rfl_nxpy=="undefined"){this.grdat_rfl_nxpy = [];}
if(this.grdat_rfl_pxny == null||""+this.grdat_rfl_pxny=="undefined"){this.grdat_rfl_pxny = [];}
if(this.grdat_rfl_pxpy == null||""+this.grdat_rfl_pxpy=="undefined"){this.grdat_rfl_pxpy = [];}
if(this.grdat_rot_nxny == null||""+this.grdat_rot_nxny=="undefined"){this.grdat_rot_nxny = [];}
if(this.grdat_rot_nxpy == null||""+this.grdat_rot_nxpy=="undefined"){this.grdat_rot_nxpy = [];}
if(this.grdat_rot_pxny == null||""+this.grdat_rot_pxny=="undefined"){this.grdat_rot_pxny = [];}
if(this.grdat_rot_pxpy == null||""+this.grdat_rot_pxpy=="undefined"){this.grdat_rot_pxpy = [];}
this.init_sce();
}
public function init_sce()
{
this.obdat.load();
this.initile_xmax = Std.int(Math.ceil(this.half_scrw/64)) +2; this.initile_xmin = Std.int(Math.floor(0-this.half_scrw/64)) -2;
this.initile_ymax = Std.int(Math.ceil(this.half_scrh/64)) +2; this.initile_ymin = Std.int(Math.floor(0-this.half_scrh/64)) -2;
var a:Int = this.initile_xmin; var b:Int = this.initile_xmax; var c:Int = this.initile_ymin; var d:Int = this.initile_ymax;
Engine.engine.cameraFollow(this.player);
//currently testing populate vertiucal. 
while(a < b){this.popu_grdat_vert(a); /*this.obdat.rpx(a,this.initile_ymax,this.initile_ymin);*/ a = a+1; }
//while(a > this.initile_xmin){a = a-1; this.obdat.rnx(a,this.initile_ymax,this.initile_ymin);}
//while(c < d){this.obdat.rpy(c,this.initile_xmax,this.initile_xmin); c=c+1;}
c = this.initile_ymax; while(c > this.initile_ymin){c = c-1; this.obdat.rny(c,this.initile_xmax, this.initile_xmin); this.diag_counter +=1;}
this.diag_rny = c; 
this.upd= true; 
}
public function load_sce()
{
this.obdat.load(); 
this.init_data();
}
     public function popu_grdat_horz(y):Void
     {
      var xmax:Int = this.initile_xmax; var xmin:Int = this.initile_xmin; var x:Int = xmin;
      var create_x:Float=0; var create_y:Float=0; var a:String =""; var f:Bool = false; var r:Float=0; 
      if(y < 0)
      {
      while(x < xmax)
      {
      if(this.grdat_actors[x]==null||""+this.grdat_actors[x]=="undefined"){this.grdat_actors[x] = [];}
      if(x < 0)
      {
      if(this.grdat_ids_nxny[0-x]==null||""+this.grdat_ids_nxny[0-x]=="undefined"){this.grdat_ids_nxny[0-x]=[];}
      if(this.grdat_rfl_nxny[0-x]==null||""+this.grdat_rfl_nxny[0-x]=="undefined"){this.grdat_rfl_nxny[0-x]=[];}
      if(this.grdat_rot_nxny[0-x]==null||""+this.grdat_rot_nxny[0-x]=="undefined"){this.grdat_rot_nxny[0-x]=[];}
      if(this.grdat_ids_nxny[0-x][0-y]==null||""+this.grdat_ids_nxny[0-x][0-y]=="undefined"){this.grdat_ids_nxny[0-x][0-y]=this.randgen_grdat_ids();}
      if(this.grdat_rfl_nxny[0-x][0-y]==null||""+this.grdat_rfl_nxny[0-x][0-y]=="undefined"){this.grdat_rfl_nxny[0-x][0-y]=this.randgen_rfl();}
      if(this.grdat_rot_nxny[0-x][0-y]==null||""+this.grdat_rot_nxny[0-x][0-y]=="undefined"){this.grdat_rot_nxny[0-x][0-y]=this.randgen_rot();}
      a = this.grdat_ids_nxny[0-x][0-y]; f=this.grdat_rfl_nxny[0-x][0-y]; r= this.grdat_rot_nxny[0-x][0-y];
      }
      else
      {
      if(this.grdat_ids_pxny[x]==null||""+this.grdat_ids_pxny[x]=="undefined"){this.grdat_ids_pxny[x]=[];}
      if(this.grdat_rfl_pxny[x]==null||""+this.grdat_rfl_pxny[x]=="undefined"){this.grdat_rfl_pxny[x]=[];}
      if(this.grdat_rot_pxny[x]==null||""+this.grdat_rot_pxny[x]=="undefined"){this.grdat_rot_pxny[x]=[];}
      if(this.grdat_ids_pxny[x][0-y]==null||""+this.grdat_ids_pxny[x][0-y]=="undefined"){this.grdat_ids_pxny[x][0-y]=this.randgen_grdat_ids();}
      if(this.grdat_rfl_pxny[x][0-y]==null||""+this.grdat_rfl_pxny[x][0-y]=="undefined"){this.grdat_rfl_pxny[x][0-y]=this.randgen_rfl();}
      if(this.grdat_rot_pxny[x][0-y]==null||""+this.grdat_rot_pxny[x][0-y]=="undefined"){this.grdat_rot_pxny[x][0-y]=this.randgen_rot();}
      a = this.grdat_ids_pxny[x][0-y]; f=this.grdat_rfl_pxny[x][0-y]; r = this.grdat_rot_pxny[x][0-y];
      }
      create_x = this.half_scew + x*64 + this.offsx; create_y = this.half_sceh + y*64 + this.offsy; 
      this.diag_last_created_ids = a; 
      this.create_ground(a,create_x,create_y);
      this.diag_noa += 1; 
      this.grdat_actors[x][y] = this.last_created_ground;
      this.grdat_actors[x][y].setValue("Ground_behav","x",x);
      this.grdat_actors[x][y].setValue("Ground_behav","y",y);
if(r !=0){this.grdat_actors[x][y].spinTo(r,0,null);}
      x = x+1; 
      }
      }
      else 
      {
      while(x < xmax)
      {
      if(this.grdat_actors[x]==null||""+this.grdat_actors[x]=="undefined"){this.grdat_actors[x] = [];}
      if(x < 0)
      {
      if(this.grdat_ids_nxpy[0-x]==null||""+this.grdat_ids_nxpy[0-x]=="undefined"){this.grdat_ids_nxpy[0-x]=[];}
      if(this.grdat_rfl_nxpy[0-x]==null||""+this.grdat_rfl_nxpy[0-x]=="undefined"){this.grdat_rfl_nxpy[0-x]=[];}
      if(this.grdat_rot_nxpy[0-x]==null||""+this.grdat_rot_nxpy[0-x]=="undefined"){this.grdat_rot_nxpy[0-x]=[];}
      if(this.grdat_ids_nxpy[0-x][y]==null||""+this.grdat_ids_nxpy[0-x][y]=="undefined"){this.grdat_ids_nxpy[0-x][y]=this.randgen_grdat_ids();}
      if(this.grdat_rfl_nxpy[0-x][y]==null||""+this.grdat_rfl_nxpy[0-x][y]=="undefined"){this.grdat_rfl_nxpy[0-x][y]=this.randgen_rfl();}
      if(this.grdat_rot_nxpy[0-x][y]==null||""+this.grdat_rot_nxpy[0-x][y]=="undefined"){this.grdat_rot_nxpy[0-x][y]=this.randgen_rot();}
      a = this.grdat_ids_nxpy[0-x][y]; f=this.grdat_rfl_nxpy[0-x][y]; r = this.grdat_rot_nxpy[0-x][y];
      }
      else
      {
      if(this.grdat_ids_pxpy[x]==null||""+this.grdat_ids_pxpy[x]=="undefined"){this.grdat_ids_pxpy[x]=[];}
      if(this.grdat_rfl_pxpy[x]==null||""+this.grdat_rfl_pxpy[x]=="undefined"){this.grdat_rfl_pxpy[x]=[];}
      if(this.grdat_rot_pxpy[x]==null||""+this.grdat_rot_pxpy[x]=="undefined"){this.grdat_rot_pxpy[x]=[];}
   if(this.grdat_ids_pxpy[x][y]==null||""+this.grdat_ids_pxpy[x][y]=="undefined"){this.grdat_ids_pxpy[x][y]=this.randgen_grdat_ids();}
    if(this.grdat_rfl_pxpy[x][y]==null||""+this.grdat_rfl_pxpy[x][y]=="undefined"){this.grdat_rfl_pxpy[x][y]=this.randgen_rfl();}
      if(this.grdat_rot_pxpy[x][y]==null||""+this.grdat_rot_pxpy[x][y]=="undefined"){this.grdat_rot_pxpy[x][y]=this.randgen_rot();}
      a = this.grdat_ids_pxpy[x][y]; f=this.grdat_rfl_pxpy[x][y]; r = this.grdat_rot_pxpy[x][y];
      }
      create_x = this.half_scew + x*64 + this.offsx; create_y = this.half_sceh + y*64 + this.offsy; 
      this.diag_last_created_ids = a; 
      this.create_ground(a,create_x,create_y);this.diag_noa += 1; 
      this.grdat_actors[x][y] = this.last_created_ground;
      this.grdat_actors[x][y].setValue("Ground_behav","x",x);
      this.grdat_actors[x][y].setValue("Ground_behav","y",y);
if(r !=0){this.grdat_actors[x][y].spinTo(r,0,Easing.linear);}
      x = x+1; 
      }
      }
     }

public function popu_grdat_vert(x):Void
{
if(this.grdat_actors[x]==null ||""+this.grdat_actors[x] == "undefined"){this.grdat_actors[x] = [];}
var ymax:Int = this.initile_ymax; var ymin:Int = this.initile_ymin; var y:Int = ymin;  var a:String="";  var f:Bool; var r:Float; var create_x:Float=0; var create_y:Float=0; 
if(x < 0)
{
while (y < ymax)
{
if(y < 0)
{
if(this.grdat_ids_nxny[0-x]==null ||""+this.grdat_ids_nxny[0-x]=="undefined"){this.grdat_ids_nxny[0-x]=[];}
if(this.grdat_ids_nxny[0-x][0-y]==null ||""+this.grdat_ids_nxny[0-x][0-y]=="undefined"){this.grdat_ids_nxny[0-x][0-y] = this.randgen_grdat_ids();}
if(this.grdat_rfl_nxny[0-x]==null ||""+this.grdat_rfl_nxny[0-x]=="undefined"){this.grdat_rfl_nxny[0-x]=[];}
if(this.grdat_rfl_nxny[0-x][0-y]==null ||""+this.grdat_rfl_nxny[0-x][0-y]=="undefined"){this.grdat_rfl_nxny[0-x][0-y] = this.randgen_rfl();}
if(this.grdat_rot_nxny[0-x]==null ||""+this.grdat_rot_nxny[0-x]=="undefined"){this.grdat_rot_nxny[0-x]=[];}
if(this.grdat_rot_nxny[0-x][0-y]==null ||""+this.grdat_rot_nxny[0-x][0-y]=="undefined"){this.grdat_rot_nxny[0-x][0-y] = this.randgen_rot();}
a = this.grdat_ids_nxny[0-x][0-y]; f = this.grdat_rfl_nxny[0-x][0-y]; r = this.grdat_rot_nxny[0-x][0-y];
}
else
{
if(this.grdat_ids_nxpy[0-x]==null ||""+this.grdat_ids_nxpy[0-x]=="undefined"){this.grdat_ids_nxpy[0-x]=[];}
if(this.grdat_ids_nxpy[0-x][y]==null ||""+this.grdat_ids_nxpy[0-x][y]=="undefined"){this.grdat_ids_nxpy[0-x][y] = this.randgen_grdat_ids();}
if(this.grdat_rfl_nxpy[0-x]==null ||""+this.grdat_rfl_nxpy[0-x]=="undefined"){this.grdat_rfl_nxpy[0-x]=[];}
if(this.grdat_rfl_nxpy[0-x][y]==null ||""+this.grdat_rfl_nxpy[0-x][y]=="undefined"){this.grdat_rfl_nxpy[0-x][y] = this.randgen_rfl();}
if(this.grdat_rot_nxpy[0-x]==null ||""+this.grdat_rot_nxpy[0-x]=="undefined"){this.grdat_rot_nxpy[0-x]=[];}
if(this.grdat_rot_nxpy[0-x][y]==null ||""+this.grdat_rot_nxpy[0-x][y]=="undefined"){this.grdat_rot_nxpy[0-x][y] = this.randgen_rot();}
a = this.grdat_ids_nxpy[0-x][y]; f = this.grdat_rfl_nxpy[0-x][y]; r = this.grdat_rot_nxpy[0-x][y];
}
create_x = this.half_scew + x*64 + this.offsx; create_y = this.half_sceh + y*64 + this.offsy;  
this.diag_create_x = create_x; this.diag_create_y = create_y; 
this.create_ground(a,create_x,create_y);this.diag_noa += 1; 
this.grdat_actors[x][y] = this.last_created_ground;
this.grdat_actors[x][y].setValue("Ground_behav","x",x);
      this.grdat_actors[x][y].setValue("Ground_behav","y",y);
if(r !=0){this.grdat_actors[x][y].spinTo(r,0,Easing.linear);}
y = y + 1; 
}
}
else
{
while (y < ymax)
{
if(y < 0)
{
if(this.grdat_ids_pxny[x]==null ||""+this.grdat_ids_pxny[x]=="undefined"){this.grdat_ids_pxny[x]=[];}
if(this.grdat_ids_pxny[x][0-y]==null ||""+this.grdat_ids_pxny[x][0-y]=="undefined"){this.grdat_ids_pxny[x][0-y] = this.randgen_grdat_ids();}
if(this.grdat_rfl_pxny[x]==null ||""+this.grdat_rfl_pxny[x]=="undefined"){this.grdat_rfl_pxny[x]=[];}
if(this.grdat_rfl_pxny[x][0-y]==null ||""+this.grdat_rfl_pxny[x][0-y]=="undefined"){this.grdat_rfl_pxny[x][0-y] = this.randgen_rfl();}
if(this.grdat_rot_pxny[x]==null ||""+this.grdat_rot_pxny[x]=="undefined"){this.grdat_rot_pxny[x]=[];}
if(this.grdat_rot_pxny[x][0-y]==null ||""+this.grdat_rot_pxny[x][0-y]=="undefined"){this.grdat_rot_pxny[x][0-y] = this.randgen_rot();}
a = this.grdat_ids_pxny[x][0-y]; f = this.grdat_rfl_pxny[x][0-y]; r = this.grdat_rot_pxny[x][0-y];
}
else
{
if(this.grdat_ids_pxpy[x]==null ||""+this.grdat_ids_pxpy[x]=="undefined"){this.grdat_ids_pxpy[x]=[];}
if(this.grdat_ids_pxpy[x][y]==null ||""+this.grdat_ids_pxpy[x][y]=="undefined"){this.grdat_ids_pxpy[x][y] = this.randgen_grdat_ids();}
if(this.grdat_rfl_pxpy[x]==null ||""+this.grdat_rfl_pxpy[x]=="undefined"){this.grdat_rfl_pxpy[x]=[];}
if(this.grdat_rfl_pxpy[x][y]==null ||""+this.grdat_rfl_pxpy[x][y]=="undefined"){this.grdat_rfl_pxpy[x][y] = this.randgen_rfl();}
if(this.grdat_rot_pxpy[x]==null ||""+this.grdat_rot_pxpy[x]=="undefined"){this.grdat_rot_pxpy[x]=[];}
if(this.grdat_rot_pxpy[x][y]==null ||""+this.grdat_rot_pxpy[x][y]=="undefined"){this.grdat_rot_pxpy[x][y] = this.randgen_rot();}
a = this.grdat_ids_pxpy[x][y]; f = this.grdat_rfl_pxpy[x][y]; r = this.grdat_rot_pxpy[x][y];
}
create_x = this.half_scew + x*64 + this.offsx; create_y = this.half_sceh + y*64 + this.offsy;  
this.diag_create_x = create_x; this.diag_create_y = create_y; 
this.create_ground(a,create_x,create_y);this.diag_noa += 1; 
this.grdat_actors[x][y] = this.last_created_ground;
this.grdat_actors[x][y].setValue("Ground_behav","x",x);
      this.grdat_actors[x][y].setValue("Ground_behav","y",y);
if(r !=0){this.grdat_actors[x][y].spinTo(r,0,Easing.linear);}
y = y + 1; 
}
}
}
public function randgen_grdat_ids():String
{
var rand:Int =  Std.int(Math.floor(Math.random() * 9.999));
if(rand == 0){return "grass_0";} else if(rand == 1){return "grass_1";}
else if(rand == 2){return "grass_2";} else if(rand == 3){return "grass_3";}
else if(rand == 4){return "grass_4";} else if(rand == 5){return "grass_5";}
else if(rand == 6){return "grass_6";} else if(rand == 7){return "grass_7";}
else if(rand == 8){return "grass_8";} else if(rand == 9){return "grass_9";}
return "grass_9";
}
public function randgen_obdat_ids():String
{
var rand:Int = Std.int(Math.floor(Math.random()*10.999));
var ocu: Float = Math.random(); 
if(ocu > 0.94)
{
if(rand == 0){return "tru_1a";}
else if(rand == 1){return "tru_1b";}
else if(rand == 2){return "tru_1c";}
else if(rand == 3){return "tru_2a";}
else if(rand == 4){return "tru_2b";}
else if(rand == 5){return "tru_2c";}
else if(rand == 6){return "tru_3a";}
else if(rand == 7){return "tru_3b";}
else if(rand == 8){return "tru_3c";}
else if(rand == 9){return "tru_2x3a";}
else if(rand ==10){return "tru_2x3b";}
return "";
}
return "";
}
public function randgen_rfl():Bool{if(Math.random() > 0.5) {return true;} return false;}
public function randgen_rot():Float{return Math.floor(Math.random() * 3.999) * 90;}

public function remo_grdat_horz(y):Void
{
var xmax:Int = this.initile_xmax; var xmin = this.initile_xmin; var x=xmin;  
while(x < xmax)
{
if(this.grdat_actors[x][y] !=null && ""+this.grdat_actors[x][y]!="undefined"){Script.recycleActor(this.grdat_actors[x][y]); this.grdat_actors[x][y]=null; this.diag_noa -=1;}
x+=1; 
}
}
public function remo_grdat_vert(x):Void
{
var ymax:Int = this.initile_ymax; var ymin = this.initile_ymin; var y=ymin;
while(y < ymax)
{
if(this.grdat_actors[x][y] !=null && ""+this.grdat_actors[x][y]!="undefined"){Script.recycleActor(this.grdat_actors[x][y]); this.grdat_actors[x][y]=null; this.diag_noa -=1;}
y+=1;
}
}
public function shift_xdec():Void
{
this.shifting = true; this.player.makeAlwaysSimulate();
var xmax:Int = this.initile_xmax; var xmin:Int = this.initile_xmin; var x:Int = xmin; 
var ymax:Int = this.initile_ymax; var ymin:Int = this.initile_ymin; var y:Int = ymin;  
while(x < xmax)
{
y = ymin;
while(y < ymax)
{
if(this.grdat_actors[x][y]!=null&&""+this.grdat_actors[x][y]!="undefined"){this.grdat_actors[x][y].setX(this.grdat_actors[x][y].getX() - this.half_scew);}
y = y+1;
}
x = x+1; 
}
this.offsx -= this.half_scew; 
this.player.setValue("Player_leg_behav","x",this.player.getValue("Player_leg_behav","x")-this.half_scew); 
Script.runLater(20,stop_shift,null);
}
public function shift_xinc():Void
{
this.shifting = true;this.player.makeAlwaysSimulate();
var xmax:Int = this.initile_xmax; var xmin:Int = this.initile_xmin; var x:Int = xmin; 
var ymax:Int = this.initile_ymax; var ymin:Int = this.initile_ymin; var y:Int = ymin;  
while(x < xmax)
{
y = ymin;
while(y < ymax)
{
if(this.grdat_actors[x][y]!=null&&""+this.grdat_actors[x][y]!="undefined"){this.grdat_actors[x][y].setX(this.grdat_actors[x][y].getX() + this.half_scew);}
y = y+1;
}
x = x+1; 
}
this.offsx += this.half_scew; 
this.player.setValue("Player_leg_behav","x",this.player.getValue("Player_leg_behav","x")+this.half_scew); 
Script.runLater(200,stop_shift,null);
}
public function shift_ydec():Void
{
this.shifting = true;this.player.makeAlwaysSimulate(); 
var xmax:Int = this.initile_xmax; var xmin:Int = this.initile_xmin; var x:Int = xmin; 
var ymax:Int = this.initile_ymax; var ymin:Int = this.initile_ymin; var y:Int = ymin;  
while(x < xmax)
{
y = ymin;
while(y < ymax)
{
if(this.grdat_actors[x][y]!=null&&""+this.grdat_actors[x][y]!="undefined"){this.grdat_actors[x][y].setY(this.grdat_actors[x][y].getY() - this.half_sceh);}
y = y+1;
}
x = x+1; 
}
this.offsy -= this.half_sceh; 
this.player.setValue("Player_leg_behav","y",this.player.getValue("Player_leg_behav","y")-this.half_sceh); 
Script.runLater(20,stop_shift,null);
}
public function shift_yinc():Void
{
this.shifting = true;this.player.makeAlwaysSimulate(); 
var xmax:Int = this.initile_xmax; var xmin:Int = this.initile_xmin; var x:Int = xmin; 
var ymax:Int = this.initile_ymax; var ymin:Int = this.initile_ymin; var y:Int = ymin;  
while(x < xmax)
{
y = ymin;
while(y < ymax)
{
if(this.grdat_actors[x][y]!=null&&""+this.grdat_actors[x][y]!="undefined"){this.grdat_actors[x][y].setY(this.grdat_actors[x][y].getY() + this.half_sceh);}
y = y+1;
}
x = x+1; 
}
this.offsy += this.half_sceh; 
this.player.setValue("Player_leg_behav","y",this.player.getValue("Player_leg_behav","y")+this.half_sceh); 
Script.runLater(20,stop_shift,null);
}
public function stop_shift(t:TimedTask):Void{this.shifting = false; this.player.makeSometimesSimulate();}
public function update(t:TimedTask):Void {this.upd = true;}
}

The custom code is too long was shown here in this page and indluding the code in this page will make us difficult to edit this page.  so it will have its own page instead. This code is responsible for the  multi-actor objects. 


No comments:

Post a Comment