00:00
00:00
View Profile FlukeDude
The programmer formerly known as souled

Male

UK

Joined on 9/18/06

Level:
14
Exp Points:
2,120 / 2,180
Exp Rank:
28,340
Vote Power:
5.64 votes
Rank:
Safety Patrol
Global Rank:
31,024
Blams:
63
Saves:
248
B/P Bonus:
6%
Whistle:
Garbage
Trophies:
2
Medals:
26

Emanuele Feronato

Posted by FlukeDude - February 23rd, 2008


Here's the code, for this, creating this:

//create an invisible movie clip across the entire stage using API
_root.createEmptyMovieClip("base", 1);
with (base) {
lineStyle(2, 0x0000000, 0);
beginFill(0x00000000, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 0);
}
//whether to pan or not
level_pan = false;
//tile size
tile_size = 50;
// pan variables
pan_dist = 50;
pan_speed = 5;
// tiles array generation
tiles = [[0, 1, 0, 0], [1, 1, 2, 1], [1, 2, 1, 2], [0, 0, 1, 0]];
// bombs array generation
bombs = [[0, 1, 0, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 1, 0]];
// creating the level movieclip
_root.createEmptyMovieClip("level", _root.getNextHighestDepth());
// placing tiles
for (x=0; x<tiles.length; x++) {
for (y=0; y<tiles[x].length; y++) {
if (tiles[y][x]) {
placed = level.attachMovie("tile", "tile"+level.getNextHighestDepth(), level.getNextHighestDepth(), {_x:x*tile_size, _y:y*tile_size});
placed.gotoAndStop(tiles[y][x]);
}
}
}
// placing bombs
for (x=0; x<bombs.length; x++) {
for (y=0; y<bombs[x].length; y++) {
if (bombs[y][x]) {
level.attachMovie("bomb", "bomb"+level.getNextHighestDepth(), level.getNextHighestDepth(), {_x:x*tile_size, _y:y*tile_size});
}
}
}
// centering level
level._x = (Stage.width-tiles.length*tile_size)/2 ;
level._y = (Stage.height-tiles[0].length*tile_siz e)/2;
level.onEnterFrame = function() {
//if mouse is on stage
if (level_pan) {
//stopping level leaving screen
//too high
if (level._y<=0) {
level._y = 0;
}
//too low
if (level._y>=Stage.height-level._height) {
level._y = Stage.height-level._height;
}
//too far to the left
if (level._x<=0) {
level._x = 0;
}
//too far to the right
if (level._x>=Stage.width-level._width) {
level._x = Stage.width-level._width;
}
// panning level
// pan right
if (_root._xmouse<pan_dist) {
level._x += pan_speed;
}
// pan left
if (_root._xmouse>Stage.width-pan_dist) {
level._x -= pan_speed;
}
// pan down
if (_root._ymouse<pan_dist) {
level._y += pan_speed;
}
// pan up
if (_root._ymouse>Stage.height-pan_dist) {
level._y -= pan_speed;
}
}
};
//when mouse is on stage pan
base.onRollOver = function() {
level_pan = true;
};
//when mouse leaves stage stop panning
base.onRollOut = function() {
level_pan = false;
};


Comments

Comments ain't a thing here.