
Page 4 of 5
LOADING THE SCENERY
Ok, I'm pretty proud to show you how I'm loadind the scenery in my game. The way I use allow you to have a larger and longer scenery as you want.
![]() | ![]() |
| line1,col1 | line1,col2 |
![]() | ![]() |
| line2,col1 | line2,col2 |
Ok, you have to put your wall. Make a rectangle and convert it to a MC. Now place all your wall and named them mur1, mur2, mur3, and so on(mur is the french word for wall). Do the same thing with the checkpoint with check1, check2. For each part you begin to wall1 and check1 (if any).
Now we have to set the var of each fla. There is as many var as object in your scenery you want to interact with. So here we have only two object: wall and checkpoint. So there is two var: maxmur and maxcheck. maxmur is for the max number of wall in the part, maxcheck max number of checkpoint in the part. Now, the var MUST be different for each part, so we named it like this (you'll understand why latter):
maxmur_1_1 for the part line 1 col 1, maxmur_2_1 for the line 2 col 1 and so on.
maxcheck_1_1 for the part line 1 col 1, and so on.
So you have here 4 swf named 1_1, 1_2, 2_1, 2_2. This is your level1 so put this 4 swf in a folder named level1, and add a text file with this on it:
ligne=2&colonne=2&Rligne=1&Rcolonne=1&
It let flash know how many line and col you got and the part where your spaceship is (here is the first line -Rligne- and first col -Rcolonne-).
Now here is the code for the decor (this code is in your main fla, not in the scenery fla, ok?!).
//This function init the limit. You can if you want pass parameter to the function to made the limit dynamic.
function InitVarDecor () {
H = 0; //Upper limit
B = 600; // Lower Limit
G = 0; //Left Limit
D = 600; //Right limit
}
/* This function load the decor you created before (all the L_C.swf).
The parameter numlevel is the number of the level.*/
function LoadDecor (numlevel) {
//depth of the clip dupplicated inside the MC we'll made
var niv = 0;
/* increment niveau and create an empty MC called decor, which will contains all the
part of of your scenery*/
niveau++;
_root.createEmptyMovieClip("decor",niveau);
/*create an empty Mc called carte. This MC will contain the jpg of your scenery's part*/
niveau++;
_root.createEmptyMovieClip("carte",niveau);
/*we move the carte to 610 410 because it will be the coord of my grid*/
_root.carte._x = 610;
_root.carte._y = 410;
/*I create a nex LoadVar object which will contain all my var loaded from the info.txt
file. So monLevel will have all the info about the level you load*/
monLevel = new LoadVars();
//loading the info.txt file
monLevel.load("level"+numlevel+"/info.txt");
//if the load is ending
monLevel.onLoad = function (succes) {
//if load with succes
if (succes) {
//while we're not at the end of the scenery lines
for(j=1; j<=monLevel.ligne; j++) {
niv++;
//while we're nit at the end of the scenery cols
for(i=1; i<=monLevel.colonne; i++) {
/* I create a new empty MC and named it i.e for the first one L1_1
(first line first col)*/
_root.decor.createEmptyMovieClip("L"+j+"_"+i,niv);
/* I define its X and Y pos. Why 600*(i or j -1)? Because the height and
width of the MC equal 600 and the first one is on the 0,0 coord. Ok?!
Don't forget that the "center" is on the UPPER LEFT CORNER.
That's why I get 0,0.*/
_root.decor["L"+j+"_"+i]._x = 600*(i-1);
_root.decor["L"+j+"_"+i]._y = 600*(j-1);
// I load the swf in the MC. i.e 1_1.swf is load in the L1_1 MC.
_root.decor["L"+j+"_"+i].loadMovie("level"+numlevel+"/"+j+"_"+i+".swf");
/*This code is for the map. I create an empty MC which receive the jpg
of the part we made. i.e the part 1_1(.swf) I create the
L1_1 (but onthe carte MC) and load the jpg on it.*/
_root.carte.createEmptyMovieClip("L"+j+"_"+i,niv);
/*my carte (french word for map) is 10 times smaller than my decor.
I do the same than above but now for the carte clip*/
_root.carte["L"+j+"_"+i]._x = 0 + 60*(i-1);
_root.carte["L"+j+"_"+i]._y = 2 + 60*(j-1);
//And then I load jpg on it
_root.carte["L"+j+"_"+i].loadMovie("Level"+numlevel+"/"+j+"_"+i+".jpg");
niv++;
}
}
/* this two lines are here to move the decor to the correct
part of the scenery. Rligne is the var telling on which line your spaceship
will appear, Rcolonne is the var telling on which col your spaceship
will appear*/
_root.decor._x -=600*(monLevel.Rcolonne-1);
_root.decor._y -=600*(monLevel.Rligne-1);
// I init the var of the decor
InitVarDecor();
} else {
trace ("Nom chargé")
}
}
}
/*************************************/
/* this function scroll the decor and set up the new coord of the spaceship*/
function ScrollDecor (objet, MonDecor) {
// if the center of my object > D
if (objet._x > D) {
for (m=niveau-20;m<=niveau;m++) {
_root[objet.ligne+""+objet.colonne+"Missile"+m].removeMovieClip();
}
//I move my X decor
MonDecor._x -= 600;
//I add 1 to the var telling us in which cols is my spaceShip
objet.Colonne += G + 1;
//I redefine my X object. My object get out by the right, so it appears by the Left
objet._x = 1;
} else if (objet._x < G) {
for (m=niveau-20;m<=niveau;m++) {
_root[objet.ligne+""+objet.colonne+"Missile"+m].removeMovieClip();
}
//Same thing as above but for the left side
MonDecor._x += 600;
objet.Colonne -= 1;
objet._x = D - 1;
};
if (objet._y > B) {
for (m=niveau-20;m<=niveau;m++) {
_root[objet.ligne+""+objet.colonne+"Missile"+m].removeMovieClip();
}
//same thing as obove but for the lower side
objet._y = H + 1;
objet.ligne += 1;
MonDecor._y -= 600;
} else if (objet._y < H) {
for (m=niveau-50;m<=niveau;m++) {
_root[objet.ligne+""+objet.colonne+"Missile"+m].removeMovieClip();
}
//same thing as above but for the upper side
objet._y = B - 1;
objet.ligne -= 1;
MonDecor._y += 600;
};
}




