Alright, I’m using a tile-like system here (to load maps anyway…), After the battle completes the first time, I see two guys (guy is the character I’m controlling).
Here’s the main part:
stop();
map1 = [ //first map
[0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1],
[0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1],
[0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1],
[0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1]
]; //second map
map2=[
[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, 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, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]
];
map3 = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0]
];
map4 = [
[1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1],
[1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1],
[1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1]
];
map5 = [
[0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0]
];
maps = [map1,map2,map3,map4,map5];
Stage.scaleMode = "noScale";
currentMap = 0;
depths = new Array();
function loadMap(map){
if(_root.getNextHighestDepth() > 5){
return
trace("WEWTZORZ TIMES A BILLION");
}
trace("WEWTZORZ");
maxwidth = map[0].length*11;
maxheight = map.length*11;
for (var i = 0; i<map.length; i++) {
for (var j = 0; j<map*.length; j++) {
depth = this.getNextHighestDepth();
depths.push(depth);
if (map*[j] == 1) {
this.attachMovie("tile", "tile"+depth.toString(), depth);
this["tile"+depth]._x = (j*10)+this["tile"+depth]._width/2;
this["tile"+depth]._y = (i*10)+this["tile"+depth]._height/2;
this["tile"+depth].gotoAndStop("grass");
}
else if (map*[j] == 0) {
this.attachMovie("tile", "tile"+depth.toString(), depth);
this["tile"+depth]._x = (j*10)+this["tile"+depth]._width/2;
this["tile"+depth]._y = (i*10)+this["tile"+depth]._height/2;
this["tile"+depth].gotoAndStop("water");
}
/* this["tile"+depth].onEnterFrame = function() {
if(["tile"+depth]._currentframe=="grass"){
}
else if(["tile"+depth]._currentframe=="water"){
}
}*/
}
}
guy = attachMovie("man","man"+depth,depth);
guy._x = guy._width/2;
guy._y = guy._height/2;
}
function updateMap(map){
maxwidth = map[0].length*11;
maxheight = map.length*11;
n = 0;
for (var i = 0; i<map.length; i++) {
for (var j = 0; j<map*.length; j++) {
depth = depths[n];
n++;
if (map*[j] == 1) {
this["tile"+depth].gotoAndStop("grass");
}
else if (map*[j] == 0) {
this["tile"+depth].gotoAndStop("water");
}
}
}
}
loadMap(maps[currentMap]);
guy.onEnterFrame = function(){
trace(chance+" "+battle);
if(Key.isDown(Key.LEFT) || Key.isDown(Key.RIGHT) || Key.isDown(Key.UP) || Key.isDown(Key.DOWN) and !battle){
chance = random(100);
if(chance <= 1){
battle = true;
gotoAndStop("battle");
}
}
if(Key.isDown(Key.LEFT) and !battle){
guy.gotoAndStop("left");
if(guy._x-10 <= 0 and currentMap > 0){
currentMap--;
map = "map"+currentMap.toString();
updateMap(maps[currentMap]);
guy._x = 150-guy._width/2;
guy.swapDepths(_root.getNextHighestDepth());
}
else if(guy._x-10 <= 0 and currentMap <= 0){
}
else{
guy._x -=10;
}
}
if(Key.isDown(Key.RIGHT) and !battle){
guy.gotoAndStop("right");
if(guy._x+10 >= 150+guy._width/2 and currentMap+1 <= maps.length){
currentMap++;
updateMap(maps[currentMap]);
guy._x = guy._width/2;
guy.swapDepths(_root.getNextHighestDepth());
}
else if(guy._x+10 >= 150/*-guy._width/2*/ and currentMap+1 <= maps.length){
}
else{
guy._x +=10;
}
}
if(Key.isDown(Key.DOWN) and guy._y+10 <= 50-guy._height/2 and !battle)
{
guy.gotoAndStop("down");
guy._y +=10;
}
if(Key.isDown(Key.UP) and guy._y-10 >= 0+guy._height/2 and !battle){
guy.gotoAndStop("up");
guy._y -=10;
}
}
Here’s the battle part:
battleMap = [ //Battle map
[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, 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, 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]
];
function startBattle(){
prevX = guy._x;
prevY = guy._y;
updateMap(battleMap);
guy._x = 22;
guy._y = 8;
monstDepth = _root.getNextHighestDepth();
mob = _root.attachMovie("monster","monster"+monstDepth,monstDepth);
mob._x = 115;
mob._y = 3;
guy.hp = 100;
mob.hp = 25;
guy.attack = 10;
mob.attack = 5;
showMenu();
}
function endBattle(){
updateMap(maps[currentMap]);
guy._x = prevX;
guy._y = prevY;
chance = 100;
battle = false;
hideMenu();
_root.gotoAndStop(1);
}
function showMenu(){
menu.visible=true;
menu._x = 50;
menu._y = 10;
menu.swapDepths(_root.getNextHighestDepth());
}
function hideMenu(){
menu.visible=false;
menu._x = -100;
menu._y = -200;
}
function attack(){
trace("ATTACK!");
mob.hp -= guy.attack;
if(mob.hp <= 0){ //mob death check
mob.removeMovieClip();
hideMenu();
endBattle();
}
}
function run(chance){
if(chance <= 40){
hideMenu();
endBattle();
}
else{
trace("You failed to escape!");
}
}
startBattle();
My FLA is too big for Kirupa’s attachment, probably because of the images I’m using for everything…:jail:
The main problem is the menu is still there after the 2nd battle ends, I have no idea why.