code for so called endless scenes - floor data.
package scripts;
import com.stencyl.Engine; //for actor creation purposes
import com.stencyl.models.Actor;
class Floor_data
{
public var ids_nxny:Array <Dynamic> = []; public var ids_nxpy:Array <Dynamic>= []; public var ids_pxny:Array <Dynamic>= []; public var ids_pxpy:Array <Dynamic>= [];
public var rfl_nxny:Array <Dynamic> = []; public var rfl_nxpy:Array <Dynamic>= []; public var rfl_pxny:Array <Dynamic>= []; public var rfl_pxpy:Array <Dynamic>= [];
public var rot_nxny:Array <Dynamic> = []; public var rot_nxpy:Array <Dynamic>= []; public var rot_pxny:Array <Dynamic>= []; public var rot_pxpy:Array <Dynamic>= [];
public var actors:Array <Dynamic> = []; public var place:String = "";
public var actors_posx:Array<Dynamic> =[]; public var actors_posy:Array<Dynamic>=[]; // these arriays to prevent aliasing.
public var number_of_actors:Int =0;
public static var diag_create_x:Float=0; public static var diag_create_y:Float=0;
public function new(a:Int =0){}
public function create_floor(a:String, x:Int,y:Int) // center point =
{
var create_x:Float = Engine.cameraX + Engine.screenWidth/2 + (x - S_gameplay_behav.disp_xcen)*512 *S_gameplay_behav.zoom;
var create_y:Float = Engine.cameraY + Engine.screenHeight/2 + (y - S_gameplay_behav.disp_ycen)*512 *S_gameplay_behav.zoom;
Floor_data.diag_create_x = create_x; //showing tat create_x has problem.
if(this.actors[x] == null ||""+this.actors[x] == "undefined"){this.actors[x] = [];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
this.actors_posx[x][y] = create_x- 256 * (1 - S_gameplay_behav.zoom); this.actors_posy[x][y] = create_y- 256 * (1 - S_gameplay_behav.zoom);
this.actors[x][y] = Engine.engine.getRecycledActorOfTypeOnLayer(Conte.floor_atid(a),create_x,create_y,0); this.number_of_actors +=1;
if(this.get_rfl(x,y)){this.actors[x][y].tweenProps.realScaleXY.tween(-1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);}
else this.actors[x][y].tweenProps.realScaleXY.tween(1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);
this.actors[x][y].setX(this.actors[x][y].getX() - 256 * (1 - S_gameplay_behav.zoom)); this.actors[x][y].setY(this.actors[x][y].getY() - 256 * (1 - S_gameplay_behav.zoom));
this.actors[x][y].setValue("Floor_behav","x",x); this.actors[x][y].setValue("Floor_behav","y",y);
}
public function get_rfl(x,y):Bool
{
if(x < 0)
{
if(y < 0)
{
if(this.rfl_nxny[0-x] == null ||""+this.rfl_nxny[0-x] == "undefined"){return false;}
return this.rfl_nxny[0-x][0-y];
}
else
{
if(this.rfl_nxpy[0-x] == null ||""+this.rfl_nxpy[0-x] == "undefined"){return false;}
return this.rfl_nxpy[0-x][y];
}
}
else
{
if(y < 0)
{
if(this.rfl_pxny[x] == null ||""+this.rfl_pxny[x] == "undefined"){return false;}
return this.rfl_pxny[x][0-y];
}
else
{
if(this.rfl_pxpy[x] == null ||""+this.rfl_pxpy[x] == "undefined"){return false;}
return this.rfl_pxpy[x][y];
}
}
return false;
}
public function init()
{
this.number_of_actors = 0;
if(this.ids_nxny == null || ""+ this.ids_nxny =="undefined"){this.ids_nxny = [];}
if(this.ids_nxpy == null || ""+ this.ids_nxpy =="undefined"){this.ids_nxpy = [];}
if(this.ids_pxny == null || ""+ this.ids_pxny =="undefined"){this.ids_pxny = [];}
if(this.ids_pxpy == null || ""+ this.ids_pxpy =="undefined"){this.ids_pxpy = [];}
if(this.rfl_nxny == null || ""+ this.rfl_nxny =="undefined"){this.rfl_nxny = [];}
if(this.rfl_nxpy == null || ""+ this.rfl_nxpy =="undefined"){this.rfl_nxpy = [];}
if(this.rfl_pxny == null || ""+ this.rfl_pxny =="undefined"){this.rfl_pxny = [];}
if(this.rfl_pxpy == null || ""+ this.rfl_pxpy =="undefined"){this.rfl_pxpy = [];}
if(this.rot_nxny == null || ""+ this.rot_nxny =="undefined"){this.rot_nxny = [];}
if(this.rot_nxpy == null || ""+ this.rot_nxpy =="undefined"){this.rot_nxpy = [];}
if(this.rot_pxny == null || ""+ this.rot_pxny =="undefined"){this.rot_pxny = [];}
if(this.rot_pxpy == null || ""+ this.rot_pxpy =="undefined"){this.rot_pxpy = [];}
}
public function load() // we now use the multi save system and loading screen and since the scene data are now publis static vars we use the loading screen.
{
this.init();
}
public function randgen_ids(): String
{
var a:Int = Std.int(Math.floor( Math.random() * 9.999));
if(a == 0) return "dun0";
if(a == 1) return "dun1";
if(a == 2) return "dun2";
if(a == 3) return "dun3";
if(a == 4) return "dun4";
if(a == 5) return "dun5";
if(a == 6) return "dun6";
if(a == 7) return "dun7";
if(a == 8) return "dun8";
if(a == 9) return "dun9";
return "";
}
public function randgen_rfl():Bool
{
var a:Float = Math.random();
if(a < 0.5) return false;
else return true;
return false;
}
public function randgen_rot():Int
{
var a:Int = Std.int(Math.floor(Math.random() * 3.99));
if(a==0) return 0;
else if(a==1) return 90;
else if(a==2) return 180;
else if(a==3) return 270;
return 0;
}
public function remo_horz(y,xmin,xmax)
{
var x:Int = xmin;
while(x < xmax)
{
if(this.actors[x]==null ||""+this.actors[x]=="undefined"){}
else if(Std.is(this.actors[x][y],Actor))
{
Engine.engine.recycleActor(this.actors[x][y]); this.actors[x][y] = null;
this.number_of_actors -=1;
}
x = x +1;
}
}
public function remo_vert(x,ymin,ymax)
{
if(this.actors[x]==null ||""+this.actors[x]=="undefined"){return;}
var y:Int = ymin;
while(y < ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
Engine.engine.recycleActor(this.actors[x][y]); this.actors[x][y] = null;
this.number_of_actors -=1;
}
y = y+1;
}
}
public function ren_horz(y,xmin,xmax)
{
var x:Int = xmin;
var ids: String; var rfl:Bool; var rot:Int;
if(y < 0)
{
x = xmin;
while(x < xmax)
{
if(this.actors[x]== null ||""+this.actors == "undefined"){this.actors[x]=[];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
if(x < 0)
{
if(this.ids_nxny[0-x] == null ||""+this.ids_nxny[0-x]=="undefined"){this.ids_nxny[0-x]=[];}
if(this.rfl_nxny[0-x] == null ||""+this.rfl_nxny[0-x]=="undefined"){this.rfl_nxny[0-x]=[];}
if(this.rot_nxny[0-x] == null ||""+this.rot_nxny[0-x]=="undefined"){this.rot_nxny[0-x]=[];}
if(this.ids_nxny[0-x][0-y] == null ||""+this.ids_nxny[0-x][0-y]=="undefined"){this.ids_nxny[0-x][0-y]=this.randgen_ids();}
if(this.rfl_nxny[0-x][0-y] == null ||""+this.rfl_nxny[0-x][0-y]=="undefined"){this.rfl_nxny[0-x][0-y]=this.randgen_rfl();}
if(this.rot_nxny[0-x][0-y] == null ||""+this.rot_nxny[0-x][0-y]=="undefined"){this.rot_nxny[0-x][0-y]=this.randgen_rot();}
ids = this.ids_nxny[0-x][0-y]; rfl = this.rfl_nxny[0-x][0-y]; rot = this.rot_nxny[0-x][0-y];
}
else
{
if(this.ids_pxny[x] == null ||""+this.ids_pxny[x]=="undefined"){this.ids_pxny[x]=[];}
if(this.rfl_pxny[x] == null ||""+this.rfl_pxny[x]=="undefined"){this.rfl_pxny[x]=[];}
if(this.rot_pxny[x] == null ||""+this.rot_pxny[x]=="undefined"){this.rot_pxny[x]=[];}
if(this.ids_pxny[x][0-y] == null ||""+this.ids_pxny[x][0-y]=="undefined"){this.ids_pxny[x][0-y]=this.randgen_ids();}
if(this.rfl_pxny[x][0-y] == null ||""+this.rfl_pxny[x][0-y]=="undefined"){this.rfl_pxny[x][0-y]=this.randgen_rfl();}
if(this.rot_pxny[x][0-y] == null ||""+this.rot_pxny[x][0-y]=="undefined"){this.rot_pxny[x][0-y]=this.randgen_rot();}
ids = this.ids_pxny[x][0-y]; rfl = this.rfl_pxny[x][0-y]; rot = this.rot_pxny[x][0-y];
}
this.create_floor(ids,x,y);
x = x +1;
}
}
else
{
x = xmin;
while(x < xmax)
{
if(this.actors[x]== null ||""+this.actors == "undefined"){this.actors[x]=[];}
if(x < 0)
{
if(this.ids_nxpy[0-x] == null ||""+this.ids_nxpy[0-x]=="undefined"){this.ids_nxpy[0-x]=[];}
if(this.rfl_nxpy[0-x] == null ||""+this.rfl_nxpy[0-x]=="undefined"){this.rfl_nxpy[0-x]=[];}
if(this.rot_nxpy[0-x] == null ||""+this.rot_nxpy[0-x]=="undefined"){this.rot_nxpy[0-x]=[];}
if(this.ids_nxpy[0-x][y] == null ||""+this.ids_nxpy[0-x][y]=="undefined"){this.ids_nxpy[0-x][y]=this.randgen_ids();}
if(this.rfl_nxpy[0-x][y] == null ||""+this.rfl_nxpy[0-x][y]=="undefined"){this.rfl_nxpy[0-x][y]=this.randgen_rfl();}
if(this.rot_nxpy[0-x][y] == null ||""+this.rot_nxpy[0-x][y]=="undefined"){this.rot_nxpy[0-x][y]=this.randgen_rot();}
ids = this.ids_nxpy[0-x][y]; rfl = this.rfl_nxpy[0-x][y]; rot = this.rot_nxpy[0-x][y];
}
else
{
if(this.ids_pxpy[x] == null ||""+this.ids_pxpy[x]=="undefined"){this.ids_pxpy[x]=[];}
if(this.rfl_pxpy[x] == null ||""+this.rfl_pxpy[x]=="undefined"){this.rfl_pxpy[x]=[];}
if(this.rot_pxpy[x] == null ||""+this.rot_pxpy[x]=="undefined"){this.rot_pxpy[x]=[];}
if(this.ids_pxpy[x][y] == null ||""+this.ids_pxpy[x][y]=="undefined"){this.ids_pxpy[x][y]=this.randgen_ids();}
if(this.rfl_pxpy[x][y] == null ||""+this.rfl_pxpy[x][y]=="undefined"){this.rfl_pxpy[x][y]=this.randgen_rfl();}
if(this.rot_pxpy[x][y] == null ||""+this.rot_pxpy[x][y]=="undefined"){this.rot_pxpy[x][y]=this.randgen_rot();}
ids = this.ids_pxpy[x][y]; rfl = this.rfl_pxpy[x][y]; rot = this.rot_pxpy[x][y];
}
this.create_floor(ids,x,y);
x = x +1;
}
}
}
public function ren_vert(x,ymin,ymax)
{
var y:Int = ymin;
var ids: String; var rfl:Bool; var rot:Int;
if(this.actors[x]== null ||""+this.actors == "undefined"){this.actors[x]=[];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
if(x < 0)
{
if(this.ids_nxny[0-x] == null ||""+this.ids_nxny[0-x]=="undefined"){this.ids_nxny[0-x]=[];}
if(this.rfl_nxny[0-x] == null ||""+this.rfl_nxny[0-x]=="undefined"){this.rfl_nxny[0-x]=[];}
if(this.rot_nxny[0-x] == null ||""+this.rot_nxny[0-x]=="undefined"){this.rot_nxny[0-x]=[];}
if(this.ids_nxpy[0-x] == null ||""+this.ids_nxpy[0-x]=="undefined"){this.ids_nxpy[0-x]=[];}
if(this.rfl_nxpy[0-x] == null ||""+this.rfl_nxpy[0-x]=="undefined"){this.rfl_nxpy[0-x]=[];}
if(this.rot_nxpy[0-x] == null ||""+this.rot_nxpy[0-x]=="undefined"){this.rot_nxpy[0-x]=[];}
while(y < ymax)
{
if(y < 0)
{
if(this.ids_nxny[0-x][0-y] == null ||""+this.ids_nxny[0-x][0-y]=="undefined"){this.ids_nxny[0-x][0-y]=this.randgen_ids();}
if(this.rfl_nxny[0-x][0-y] == null ||""+this.rfl_nxny[0-x][0-y]=="undefined"){this.rfl_nxny[0-x][0-y]=this.randgen_rfl();}
if(this.rot_nxny[0-x][0-y] == null ||""+this.rot_nxny[0-x][0-y]=="undefined"){this.rot_nxny[0-x][0-y]=this.randgen_rot();}
ids = this.ids_nxny[0-x][0-y]; rfl = this.rfl_nxny[0-x][0-y]; rot = this.rot_nxny[0-x][0-y];
}
else
{
if(this.ids_nxpy[0-x][y] == null ||""+this.ids_nxpy[0-x][y]=="undefined"){this.ids_nxpy[0-x][y]=this.randgen_ids();}
if(this.rfl_nxpy[0-x][y] == null ||""+this.rfl_nxpy[0-x][y]=="undefined"){this.rfl_nxpy[0-x][y]=this.randgen_rfl();}
if(this.rot_nxpy[0-x][y] == null ||""+this.rot_nxpy[0-x][y]=="undefined"){this.rot_nxpy[0-x][y]=this.randgen_rot();}
ids = this.ids_nxpy[0-x][y]; rfl = this.rfl_nxpy[0-x][y]; rot = this.rot_nxpy[0-x][y];
}
this.create_floor(ids,x,y);
y = y+1;
}
}
else
{
if(this.ids_pxny[x] == null ||""+this.ids_pxny[x]=="undefined"){this.ids_pxny[x]=[];}
if(this.rfl_pxny[x] == null ||""+this.rfl_pxny[x]=="undefined"){this.rfl_pxny[x]=[];}
if(this.rot_pxny[x] == null ||""+this.rot_pxny[x]=="undefined"){this.rot_pxny[x]=[];}
if(this.ids_pxpy[x] == null ||""+this.ids_pxpy[x]=="undefined"){this.ids_pxpy[x]=[];}
if(this.rfl_pxpy[x] == null ||""+this.rfl_pxpy[x]=="undefined"){this.rfl_pxpy[x]=[];}
if(this.rot_pxpy[x] == null ||""+this.rot_pxpy[x]=="undefined"){this.rot_pxpy[x]=[];}
while(y < ymax)
{
if(y < 0)
{
if(this.ids_pxny[x][0-y] == null ||""+this.ids_pxny[x][0-y]=="undefined"){this.ids_pxny[x][0-y]=this.randgen_ids();}
if(this.rfl_pxny[x][0-y] == null ||""+this.rfl_pxny[x][0-y]=="undefined"){this.rfl_pxny[x][0-y]=this.randgen_rfl();}
if(this.rot_pxny[x][0-y] == null ||""+this.rot_pxny[x][0-y]=="undefined"){this.rot_pxny[x][0-y]=this.randgen_rot();}
ids = this.ids_pxny[x][0-y]; rfl = this.rfl_pxny[x][0-y]; rot = this.rot_pxny[x][0-y];
}
else
{
if(this.ids_pxpy[x][y] == null ||""+this.ids_pxpy[x][y]=="undefined"){this.ids_pxpy[x][y]=this.randgen_ids();}
if(this.rfl_pxpy[x][y] == null ||""+this.rfl_pxpy[x][y]=="undefined"){this.rfl_pxpy[x][y]=this.randgen_rfl();}
if(this.rot_pxpy[x][y] == null ||""+this.rot_pxpy[x][y]=="undefined"){this.rot_pxpy[x][y]=this.randgen_rot();}
ids = this.ids_pxpy[x][y]; rfl = this.rfl_pxpy[x][y]; rot = this.rot_pxpy[x][y];
}
this.create_floor(ids,x,y);
y = y+1;
}
}
}
public function set_zoom()
{
var old_zoom = S_gameplay_behav.old_zoom;
var cam_center_x :Float = Engine.cameraX + 0.5 * Engine.screenWidth;
var cam_center_y :Float = Engine.cameraY + 0.5 * Engine.screenHeight;
var delt_x:Float; var delt_y:Float; var new_delt_x:Float; var new_delt_y:Float;
var xmax:Int = S_gameplay_behav.disp_xmax; var xmin:Int = S_gameplay_behav.disp_xmin;
var ymax:Int = S_gameplay_behav.disp_ymax; var ymin:Int = S_gameplay_behav.disp_ymin;
var x:Int = xmin; var y:Int = ymin;
while(x < xmax)
{
if(this.actors[x] == null ||""+this.actors[x] == "undefined"){this.actors[x] = [];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
y = ymin; while(y < ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
if(this.get_rfl(x,y)){this.actors[x][y].tweenProps.realScaleXY.tween(-1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);}
else{this.actors[x][y].tweenProps.realScaleXY.tween(1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);}
delt_x = this.actors_posx[x][y] + 256*(1 - old_zoom) - cam_center_x;
delt_y = this.actors_posy[x][y] + 256*(1 - old_zoom) - cam_center_y; // differences between upper left corner and camera center.
new_delt_x = delt_x * S_gameplay_behav.zoom / old_zoom; new_delt_y = delt_y * S_gameplay_behav.zoom / old_zoom;
this.actors_posx[x][y] = cam_center_x + new_delt_x - 256*(1 - S_gameplay_behav.zoom);
this.actors_posy[x][y] = cam_center_y + new_delt_y - 256*(1 - S_gameplay_behav.zoom);
this.actors[x][y].setX(this.actors_posx[x][y]); this.actors[x][y].setY(this.actors_posy[x][y]);
}
y = y+1;
}
x = x +1;
}
}
public function shift_nx() // sfint actors to the left.
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posx[x][y] -= Engine.sceneWidth/2;
this.actors[x][y].setX(this.actors_posx[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
public function shift_ny() //shift actors to the right
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posy[x][y] -= Engine.sceneHeight/2;
this.actors[x][y].setY(this.actors_posy[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
public function shift_px()
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posx[x][y] += Engine.sceneWidth/2;
this.actors[x][y].setX(this.actors_posx[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
public function shift_py()
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posy[x][y] += Engine.sceneHeight/2;
this.actors[x][y].setY(this.actors_posy[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
}
import com.stencyl.Engine; //for actor creation purposes
import com.stencyl.models.Actor;
class Floor_data
{
public var ids_nxny:Array <Dynamic> = []; public var ids_nxpy:Array <Dynamic>= []; public var ids_pxny:Array <Dynamic>= []; public var ids_pxpy:Array <Dynamic>= [];
public var rfl_nxny:Array <Dynamic> = []; public var rfl_nxpy:Array <Dynamic>= []; public var rfl_pxny:Array <Dynamic>= []; public var rfl_pxpy:Array <Dynamic>= [];
public var rot_nxny:Array <Dynamic> = []; public var rot_nxpy:Array <Dynamic>= []; public var rot_pxny:Array <Dynamic>= []; public var rot_pxpy:Array <Dynamic>= [];
public var actors:Array <Dynamic> = []; public var place:String = "";
public var actors_posx:Array<Dynamic> =[]; public var actors_posy:Array<Dynamic>=[]; // these arriays to prevent aliasing.
public var number_of_actors:Int =0;
public static var diag_create_x:Float=0; public static var diag_create_y:Float=0;
public function new(a:Int =0){}
public function create_floor(a:String, x:Int,y:Int) // center point =
{
var create_x:Float = Engine.cameraX + Engine.screenWidth/2 + (x - S_gameplay_behav.disp_xcen)*512 *S_gameplay_behav.zoom;
var create_y:Float = Engine.cameraY + Engine.screenHeight/2 + (y - S_gameplay_behav.disp_ycen)*512 *S_gameplay_behav.zoom;
Floor_data.diag_create_x = create_x; //showing tat create_x has problem.
if(this.actors[x] == null ||""+this.actors[x] == "undefined"){this.actors[x] = [];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
this.actors_posx[x][y] = create_x- 256 * (1 - S_gameplay_behav.zoom); this.actors_posy[x][y] = create_y- 256 * (1 - S_gameplay_behav.zoom);
this.actors[x][y] = Engine.engine.getRecycledActorOfTypeOnLayer(Conte.floor_atid(a),create_x,create_y,0); this.number_of_actors +=1;
if(this.get_rfl(x,y)){this.actors[x][y].tweenProps.realScaleXY.tween(-1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);}
else this.actors[x][y].tweenProps.realScaleXY.tween(1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);
this.actors[x][y].setX(this.actors[x][y].getX() - 256 * (1 - S_gameplay_behav.zoom)); this.actors[x][y].setY(this.actors[x][y].getY() - 256 * (1 - S_gameplay_behav.zoom));
this.actors[x][y].setValue("Floor_behav","x",x); this.actors[x][y].setValue("Floor_behav","y",y);
}
public function get_rfl(x,y):Bool
{
if(x < 0)
{
if(y < 0)
{
if(this.rfl_nxny[0-x] == null ||""+this.rfl_nxny[0-x] == "undefined"){return false;}
return this.rfl_nxny[0-x][0-y];
}
else
{
if(this.rfl_nxpy[0-x] == null ||""+this.rfl_nxpy[0-x] == "undefined"){return false;}
return this.rfl_nxpy[0-x][y];
}
}
else
{
if(y < 0)
{
if(this.rfl_pxny[x] == null ||""+this.rfl_pxny[x] == "undefined"){return false;}
return this.rfl_pxny[x][0-y];
}
else
{
if(this.rfl_pxpy[x] == null ||""+this.rfl_pxpy[x] == "undefined"){return false;}
return this.rfl_pxpy[x][y];
}
}
return false;
}
public function init()
{
this.number_of_actors = 0;
if(this.ids_nxny == null || ""+ this.ids_nxny =="undefined"){this.ids_nxny = [];}
if(this.ids_nxpy == null || ""+ this.ids_nxpy =="undefined"){this.ids_nxpy = [];}
if(this.ids_pxny == null || ""+ this.ids_pxny =="undefined"){this.ids_pxny = [];}
if(this.ids_pxpy == null || ""+ this.ids_pxpy =="undefined"){this.ids_pxpy = [];}
if(this.rfl_nxny == null || ""+ this.rfl_nxny =="undefined"){this.rfl_nxny = [];}
if(this.rfl_nxpy == null || ""+ this.rfl_nxpy =="undefined"){this.rfl_nxpy = [];}
if(this.rfl_pxny == null || ""+ this.rfl_pxny =="undefined"){this.rfl_pxny = [];}
if(this.rfl_pxpy == null || ""+ this.rfl_pxpy =="undefined"){this.rfl_pxpy = [];}
if(this.rot_nxny == null || ""+ this.rot_nxny =="undefined"){this.rot_nxny = [];}
if(this.rot_nxpy == null || ""+ this.rot_nxpy =="undefined"){this.rot_nxpy = [];}
if(this.rot_pxny == null || ""+ this.rot_pxny =="undefined"){this.rot_pxny = [];}
if(this.rot_pxpy == null || ""+ this.rot_pxpy =="undefined"){this.rot_pxpy = [];}
}
public function load() // we now use the multi save system and loading screen and since the scene data are now publis static vars we use the loading screen.
{
this.init();
}
public function randgen_ids(): String
{
var a:Int = Std.int(Math.floor( Math.random() * 9.999));
if(a == 0) return "dun0";
if(a == 1) return "dun1";
if(a == 2) return "dun2";
if(a == 3) return "dun3";
if(a == 4) return "dun4";
if(a == 5) return "dun5";
if(a == 6) return "dun6";
if(a == 7) return "dun7";
if(a == 8) return "dun8";
if(a == 9) return "dun9";
return "";
}
public function randgen_rfl():Bool
{
var a:Float = Math.random();
if(a < 0.5) return false;
else return true;
return false;
}
public function randgen_rot():Int
{
var a:Int = Std.int(Math.floor(Math.random() * 3.99));
if(a==0) return 0;
else if(a==1) return 90;
else if(a==2) return 180;
else if(a==3) return 270;
return 0;
}
public function remo_horz(y,xmin,xmax)
{
var x:Int = xmin;
while(x < xmax)
{
if(this.actors[x]==null ||""+this.actors[x]=="undefined"){}
else if(Std.is(this.actors[x][y],Actor))
{
Engine.engine.recycleActor(this.actors[x][y]); this.actors[x][y] = null;
this.number_of_actors -=1;
}
x = x +1;
}
}
public function remo_vert(x,ymin,ymax)
{
if(this.actors[x]==null ||""+this.actors[x]=="undefined"){return;}
var y:Int = ymin;
while(y < ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
Engine.engine.recycleActor(this.actors[x][y]); this.actors[x][y] = null;
this.number_of_actors -=1;
}
y = y+1;
}
}
public function ren_horz(y,xmin,xmax)
{
var x:Int = xmin;
var ids: String; var rfl:Bool; var rot:Int;
if(y < 0)
{
x = xmin;
while(x < xmax)
{
if(this.actors[x]== null ||""+this.actors == "undefined"){this.actors[x]=[];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
if(x < 0)
{
if(this.ids_nxny[0-x] == null ||""+this.ids_nxny[0-x]=="undefined"){this.ids_nxny[0-x]=[];}
if(this.rfl_nxny[0-x] == null ||""+this.rfl_nxny[0-x]=="undefined"){this.rfl_nxny[0-x]=[];}
if(this.rot_nxny[0-x] == null ||""+this.rot_nxny[0-x]=="undefined"){this.rot_nxny[0-x]=[];}
if(this.ids_nxny[0-x][0-y] == null ||""+this.ids_nxny[0-x][0-y]=="undefined"){this.ids_nxny[0-x][0-y]=this.randgen_ids();}
if(this.rfl_nxny[0-x][0-y] == null ||""+this.rfl_nxny[0-x][0-y]=="undefined"){this.rfl_nxny[0-x][0-y]=this.randgen_rfl();}
if(this.rot_nxny[0-x][0-y] == null ||""+this.rot_nxny[0-x][0-y]=="undefined"){this.rot_nxny[0-x][0-y]=this.randgen_rot();}
ids = this.ids_nxny[0-x][0-y]; rfl = this.rfl_nxny[0-x][0-y]; rot = this.rot_nxny[0-x][0-y];
}
else
{
if(this.ids_pxny[x] == null ||""+this.ids_pxny[x]=="undefined"){this.ids_pxny[x]=[];}
if(this.rfl_pxny[x] == null ||""+this.rfl_pxny[x]=="undefined"){this.rfl_pxny[x]=[];}
if(this.rot_pxny[x] == null ||""+this.rot_pxny[x]=="undefined"){this.rot_pxny[x]=[];}
if(this.ids_pxny[x][0-y] == null ||""+this.ids_pxny[x][0-y]=="undefined"){this.ids_pxny[x][0-y]=this.randgen_ids();}
if(this.rfl_pxny[x][0-y] == null ||""+this.rfl_pxny[x][0-y]=="undefined"){this.rfl_pxny[x][0-y]=this.randgen_rfl();}
if(this.rot_pxny[x][0-y] == null ||""+this.rot_pxny[x][0-y]=="undefined"){this.rot_pxny[x][0-y]=this.randgen_rot();}
ids = this.ids_pxny[x][0-y]; rfl = this.rfl_pxny[x][0-y]; rot = this.rot_pxny[x][0-y];
}
this.create_floor(ids,x,y);
x = x +1;
}
}
else
{
x = xmin;
while(x < xmax)
{
if(this.actors[x]== null ||""+this.actors == "undefined"){this.actors[x]=[];}
if(x < 0)
{
if(this.ids_nxpy[0-x] == null ||""+this.ids_nxpy[0-x]=="undefined"){this.ids_nxpy[0-x]=[];}
if(this.rfl_nxpy[0-x] == null ||""+this.rfl_nxpy[0-x]=="undefined"){this.rfl_nxpy[0-x]=[];}
if(this.rot_nxpy[0-x] == null ||""+this.rot_nxpy[0-x]=="undefined"){this.rot_nxpy[0-x]=[];}
if(this.ids_nxpy[0-x][y] == null ||""+this.ids_nxpy[0-x][y]=="undefined"){this.ids_nxpy[0-x][y]=this.randgen_ids();}
if(this.rfl_nxpy[0-x][y] == null ||""+this.rfl_nxpy[0-x][y]=="undefined"){this.rfl_nxpy[0-x][y]=this.randgen_rfl();}
if(this.rot_nxpy[0-x][y] == null ||""+this.rot_nxpy[0-x][y]=="undefined"){this.rot_nxpy[0-x][y]=this.randgen_rot();}
ids = this.ids_nxpy[0-x][y]; rfl = this.rfl_nxpy[0-x][y]; rot = this.rot_nxpy[0-x][y];
}
else
{
if(this.ids_pxpy[x] == null ||""+this.ids_pxpy[x]=="undefined"){this.ids_pxpy[x]=[];}
if(this.rfl_pxpy[x] == null ||""+this.rfl_pxpy[x]=="undefined"){this.rfl_pxpy[x]=[];}
if(this.rot_pxpy[x] == null ||""+this.rot_pxpy[x]=="undefined"){this.rot_pxpy[x]=[];}
if(this.ids_pxpy[x][y] == null ||""+this.ids_pxpy[x][y]=="undefined"){this.ids_pxpy[x][y]=this.randgen_ids();}
if(this.rfl_pxpy[x][y] == null ||""+this.rfl_pxpy[x][y]=="undefined"){this.rfl_pxpy[x][y]=this.randgen_rfl();}
if(this.rot_pxpy[x][y] == null ||""+this.rot_pxpy[x][y]=="undefined"){this.rot_pxpy[x][y]=this.randgen_rot();}
ids = this.ids_pxpy[x][y]; rfl = this.rfl_pxpy[x][y]; rot = this.rot_pxpy[x][y];
}
this.create_floor(ids,x,y);
x = x +1;
}
}
}
public function ren_vert(x,ymin,ymax)
{
var y:Int = ymin;
var ids: String; var rfl:Bool; var rot:Int;
if(this.actors[x]== null ||""+this.actors == "undefined"){this.actors[x]=[];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
if(x < 0)
{
if(this.ids_nxny[0-x] == null ||""+this.ids_nxny[0-x]=="undefined"){this.ids_nxny[0-x]=[];}
if(this.rfl_nxny[0-x] == null ||""+this.rfl_nxny[0-x]=="undefined"){this.rfl_nxny[0-x]=[];}
if(this.rot_nxny[0-x] == null ||""+this.rot_nxny[0-x]=="undefined"){this.rot_nxny[0-x]=[];}
if(this.ids_nxpy[0-x] == null ||""+this.ids_nxpy[0-x]=="undefined"){this.ids_nxpy[0-x]=[];}
if(this.rfl_nxpy[0-x] == null ||""+this.rfl_nxpy[0-x]=="undefined"){this.rfl_nxpy[0-x]=[];}
if(this.rot_nxpy[0-x] == null ||""+this.rot_nxpy[0-x]=="undefined"){this.rot_nxpy[0-x]=[];}
while(y < ymax)
{
if(y < 0)
{
if(this.ids_nxny[0-x][0-y] == null ||""+this.ids_nxny[0-x][0-y]=="undefined"){this.ids_nxny[0-x][0-y]=this.randgen_ids();}
if(this.rfl_nxny[0-x][0-y] == null ||""+this.rfl_nxny[0-x][0-y]=="undefined"){this.rfl_nxny[0-x][0-y]=this.randgen_rfl();}
if(this.rot_nxny[0-x][0-y] == null ||""+this.rot_nxny[0-x][0-y]=="undefined"){this.rot_nxny[0-x][0-y]=this.randgen_rot();}
ids = this.ids_nxny[0-x][0-y]; rfl = this.rfl_nxny[0-x][0-y]; rot = this.rot_nxny[0-x][0-y];
}
else
{
if(this.ids_nxpy[0-x][y] == null ||""+this.ids_nxpy[0-x][y]=="undefined"){this.ids_nxpy[0-x][y]=this.randgen_ids();}
if(this.rfl_nxpy[0-x][y] == null ||""+this.rfl_nxpy[0-x][y]=="undefined"){this.rfl_nxpy[0-x][y]=this.randgen_rfl();}
if(this.rot_nxpy[0-x][y] == null ||""+this.rot_nxpy[0-x][y]=="undefined"){this.rot_nxpy[0-x][y]=this.randgen_rot();}
ids = this.ids_nxpy[0-x][y]; rfl = this.rfl_nxpy[0-x][y]; rot = this.rot_nxpy[0-x][y];
}
this.create_floor(ids,x,y);
y = y+1;
}
}
else
{
if(this.ids_pxny[x] == null ||""+this.ids_pxny[x]=="undefined"){this.ids_pxny[x]=[];}
if(this.rfl_pxny[x] == null ||""+this.rfl_pxny[x]=="undefined"){this.rfl_pxny[x]=[];}
if(this.rot_pxny[x] == null ||""+this.rot_pxny[x]=="undefined"){this.rot_pxny[x]=[];}
if(this.ids_pxpy[x] == null ||""+this.ids_pxpy[x]=="undefined"){this.ids_pxpy[x]=[];}
if(this.rfl_pxpy[x] == null ||""+this.rfl_pxpy[x]=="undefined"){this.rfl_pxpy[x]=[];}
if(this.rot_pxpy[x] == null ||""+this.rot_pxpy[x]=="undefined"){this.rot_pxpy[x]=[];}
while(y < ymax)
{
if(y < 0)
{
if(this.ids_pxny[x][0-y] == null ||""+this.ids_pxny[x][0-y]=="undefined"){this.ids_pxny[x][0-y]=this.randgen_ids();}
if(this.rfl_pxny[x][0-y] == null ||""+this.rfl_pxny[x][0-y]=="undefined"){this.rfl_pxny[x][0-y]=this.randgen_rfl();}
if(this.rot_pxny[x][0-y] == null ||""+this.rot_pxny[x][0-y]=="undefined"){this.rot_pxny[x][0-y]=this.randgen_rot();}
ids = this.ids_pxny[x][0-y]; rfl = this.rfl_pxny[x][0-y]; rot = this.rot_pxny[x][0-y];
}
else
{
if(this.ids_pxpy[x][y] == null ||""+this.ids_pxpy[x][y]=="undefined"){this.ids_pxpy[x][y]=this.randgen_ids();}
if(this.rfl_pxpy[x][y] == null ||""+this.rfl_pxpy[x][y]=="undefined"){this.rfl_pxpy[x][y]=this.randgen_rfl();}
if(this.rot_pxpy[x][y] == null ||""+this.rot_pxpy[x][y]=="undefined"){this.rot_pxpy[x][y]=this.randgen_rot();}
ids = this.ids_pxpy[x][y]; rfl = this.rfl_pxpy[x][y]; rot = this.rot_pxpy[x][y];
}
this.create_floor(ids,x,y);
y = y+1;
}
}
}
public function set_zoom()
{
var old_zoom = S_gameplay_behav.old_zoom;
var cam_center_x :Float = Engine.cameraX + 0.5 * Engine.screenWidth;
var cam_center_y :Float = Engine.cameraY + 0.5 * Engine.screenHeight;
var delt_x:Float; var delt_y:Float; var new_delt_x:Float; var new_delt_y:Float;
var xmax:Int = S_gameplay_behav.disp_xmax; var xmin:Int = S_gameplay_behav.disp_xmin;
var ymax:Int = S_gameplay_behav.disp_ymax; var ymin:Int = S_gameplay_behav.disp_ymin;
var x:Int = xmin; var y:Int = ymin;
while(x < xmax)
{
if(this.actors[x] == null ||""+this.actors[x] == "undefined"){this.actors[x] = [];}
if(this.actors_posx[x] == null ||""+this.actors_posx[x] == "undefined"){this.actors_posx[x] = [];}
if(this.actors_posy[x] == null ||""+this.actors_posy[x] == "undefined"){this.actors_posy[x] = [];}
y = ymin; while(y < ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
if(this.get_rfl(x,y)){this.actors[x][y].tweenProps.realScaleXY.tween(-1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);}
else{this.actors[x][y].tweenProps.realScaleXY.tween(1,S_gameplay_behav.zoom,1,S_gameplay_behav.zoom,null,0);}
delt_x = this.actors_posx[x][y] + 256*(1 - old_zoom) - cam_center_x;
delt_y = this.actors_posy[x][y] + 256*(1 - old_zoom) - cam_center_y; // differences between upper left corner and camera center.
new_delt_x = delt_x * S_gameplay_behav.zoom / old_zoom; new_delt_y = delt_y * S_gameplay_behav.zoom / old_zoom;
this.actors_posx[x][y] = cam_center_x + new_delt_x - 256*(1 - S_gameplay_behav.zoom);
this.actors_posy[x][y] = cam_center_y + new_delt_y - 256*(1 - S_gameplay_behav.zoom);
this.actors[x][y].setX(this.actors_posx[x][y]); this.actors[x][y].setY(this.actors_posy[x][y]);
}
y = y+1;
}
x = x +1;
}
}
public function shift_nx() // sfint actors to the left.
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posx[x][y] -= Engine.sceneWidth/2;
this.actors[x][y].setX(this.actors_posx[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
public function shift_ny() //shift actors to the right
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posy[x][y] -= Engine.sceneHeight/2;
this.actors[x][y].setY(this.actors_posy[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
public function shift_px()
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posx[x][y] += Engine.sceneWidth/2;
this.actors[x][y].setX(this.actors_posx[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
public function shift_py()
{
var x:Int = S_gameplay_behav.disp_xmin; var y:Int;
while(x < S_gameplay_behav.disp_xmax)
{
if(this.actors[x] != null &&""+ this.actors[x] != "undefined")
{
y = S_gameplay_behav.disp_ymin; while(y < S_gameplay_behav.disp_ymax)
{
if(Std.is(this.actors[x][y],Actor))
{
this.actors_posy[x][y] += Engine.sceneHeight/2;
this.actors[x][y].setY(this.actors_posy[x][y]);
}
y = y+1;
}
}
x = x +1;
}
}
}
No comments:
Post a Comment