Tutorials Home
What's New
Top Rated
Submit
myTutes
Random!
Tile Based World - Part 1 the Engine
Author: Steven Richardson
Now the Map Container
create a new movie called container this will be the heart of the engine, in the frame add this
// adds the man movie
attachMovie("man", "man", 702);
setProperty ("man", _x, "30");
setProperty ("man", _y, "30");
// arrays for level.... 0 == wall, 1 == floor
M0 = new Array(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);
M1 = new Array(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0);
M2 = new Array(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0);
M3 = new Array(0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M4 = new Array(0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M5 = new Array(0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M6 = new Array(0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M7 = new Array(0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M8 = new Array(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0);
M9 = new Array(0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M10 = new Array(0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M11 = new Array(0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M12 = new Array(0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0);
M13 = new Array(0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0);
M14 = new Array(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0);
M15 = new Array(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0);
M16 = new Array(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0);
M17 = new Array(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);
// vars for duplication
n1 = 0;
n2 = 0;
n3 = 0;
// go through arrays and attach wall/floor movie clips as needed
while (n1<18) {
while (n2<27) {
if (eval("M" add n1)[n2] == 0) {
// wall
attachMovie("w", "w" add n1 add "-" add n2, n3);
eval("w" add n1 add "-" add n2)._x = (n2*20);
eval("w" add n1 add "-" add n2)._y = (n1*20);
}
if (eval("M" add n1)[n2] == 1) {
// floor
attachMovie("floor", "floor" add n1 add "-" add n2, n3);
eval("floor" add n1 add "-" add n2)._x = (n2*20);
eval("floor" add n1 add "-" add n2)._y = (n1*20);
}
n3++;
n2++;
}
n2 = 0;
n1++;
}
So the first bit attaches the man movie to depth 702 and then sets the Map arrays the 0's are walls and the 1's are the floors. Then the next bit attaches the movies depending on the number in the array
this needs the linkage name mapcontainer
» Level Intermediate
Added: : 2002-03-18
Rating: 5.01 Votes: 81
Hits: 785
» Author
Steven Richardson
» Download
Download the files used in this tutorial.
Download (20 kb)
Get conversion and unzipping tools
for PC and Mac here!
» Forums
More help? Search our boards for quick answers!
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.