Frame 1
this.map = new Array();
this.map_tiles = new Array();
vivian._x = 0;
vivian._y = 0;
this.map1 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0);
this.collide_object_with_background = function (obj) {
var left = Math.floor(obj._x / 32);
var top = Math.floor(obj._y / 32);
var right = (Math.ceil((obj._x + obj.width) / 32) - 1);
var bottom = (Math.ceil((obj._y + obj.height) / 32) - 1);
var last_left = Math.floor((obj._x - obj.inertia_x) / 32);
var last_top = Math.floor((obj._y - obj.inertia_y) / 32);
var last_right = (Math.ceil(((obj._x + obj.width) - obj.inertia_x) / 32) - 1);
var last_bottom = (Math.ceil(((obj._y + obj.height) - obj.inertia_y) / 32) - 1);
var i = 0;
if (left < last_left) {
i = last_top;
while (last_bottom >= i) {
if (this.get_map_tile(left, i)) {
obj._x = last_left * 32;
obj.inertia_x = 0;
obj.on_collision_with_background("left");
left = last_left;
right = last_right;
}
i++;
}
} else if (last_right < right) {
i = last_top;
while (last_bottom >= i) {
if (this.get_map_tile(right, i)) {
obj._x = ((last_right + 1) * 32) - obj.width;
obj.inertia_x = 0;
obj.on_collision_with_background("right");
left = last_left;
right = last_right;
}
i++;
}
}
if (top < last_top) {
i = left;
while (right >= i) {
if (this.get_map_tile(i, top)) {
obj._y = last_top * 32;
obj.inertia_y = 0;
obj.on_collision_with_background("top");
}
i++;
}
} else if (last_bottom < bottom) {
i = left;
while (right >= i) {
if (this.get_map_tile(i, bottom)) {
obj._y = ((last_bottom + 1) * 32) - obj.height;
obj.inertia_y = 0;
obj.on_collision_with_background("bottom");
}
i++;
}
}
};
this.on_mouse_click = function () {
var x = Math.floor(_xmouse / 32);
var y = Math.floor(_ymouse / 32);
this.set_map_tile(x, y, 1 - (1 * this.get_map_tile(x, y)));
};
this.set_map_tile = function (x, y, i) {
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 6)) {
if (i) {
if (!map_tile[x + (y * 8)]) {
map_tile.duplicateMovieClip("map_tile_" + (x + (y * 8)), x + (y * 8));
map_tiles[x + (y * 8)] = eval ("map_tile_" + (x + (y * 8)));
map_tiles[x + (y * 8)]._x = x * 32;
map_tiles[x + (y * 8)]._y = y * 32;
}
map_tiles[x + (y * 8)].gotoAndStop(i + 2);
} else if (map_tiles[x + (y * 8)]) {
map_tiles[x + (y * 8)].removeMovieClip();
}
this.map[x + (y * 8)] = i;
}
};
this.get_map_tile = function (x, y) {
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 6)) {
return(this.map[x + (y * 8)]);
}
return(0);
};
this.load_map = function (m) {
i = 0;
while (i < m.length) {
this.set_map_tile(i % 8, Math.floor(i / 8), m[i]);
i++;
}
};
this.load_map(this.map1);
Instance of Symbol 12 MovieClip in Frame 1
onClipEvent (mouseDown) {
_root.on_mouse_click();
}
Frame 2
stop();
Symbol 4 MovieClip Frame 1
stop();
Symbol 9 MovieClip Frame 1
stop();
Symbol 10 MovieClip Frame 1
this.inertia_x = 0;
this.inertia_y = 0;
this.is_on_ground = false;
this.is_jumping = false;
this.height = 28;
this.width = 8;
this.on_collision_with_background = function (side) {
if (side == "bottom") {
this.is_on_ground = true;
}
};
Symbol 10 MovieClip Frame 2
if (Key.isDown(Key.LEFT)) {
this.inertia_x = this.inertia_x - 1;
} else if (this.inertia_x < 0) {
if (-1 < this.inertia_x) {
this.inertia_x = 0;
} else {
this.inertia_x = this.inertia_x + 1;
}
}
if (this.inertia_x < -3) {
this.inertia_x = this.inertia_x + 1;
}
if (Key.isDown(Key.RIGHT)) {
this.inertia_x = this.inertia_x + 1;
} else if (0 < this.inertia_x) {
if (this.inertia_x < 1) {
this.inertia_x = 0;
} else {
this.inertia_x = this.inertia_x - 1;
}
}
if (3 < this.inertia_x) {
this.inertia_x = this.inertia_x - 1;
}
if (Key.isDown(Key.UP)) {
if (this.is_on_ground && (!this.is_jumping)) {
this.inertia_y = -12;
this.is_jumping = true;
}
} else {
this.is_jumping = false;
}
if ((!this.is_jumping) && (this.inertia_y < 0)) {
this.inertia_y = this.inertia_y + 2;
}
this.inertia_y = this.inertia_y + 1;
this._x = this._x + this.inertia_x;
this._y = this._y + this.inertia_y;
this.is_on_ground = false;
if (192 < (this._y + this.height)) {
this._y = 192 - this.height;
this.inertia_y = 0;
this.is_on_ground = true;
}
_root.collide_object_with_background(this);
if (Key.isDown(Key.LEFT)) {
if (!Key.isDown(Key.RIGHT)) {
sprite.gotoAndStop("left");
}
} else if (Key.isDown(Key.RIGHT)) {
sprite.gotoAndStop("right");
}
Symbol 10 MovieClip Frame 3
gotoAndPlay (2);