PDA

View Full Version : Making a giant World Map



Kojitasan
September 8th, 2006, 07:13 PM
OK I dont know either if I want to use an art type map or a tile type map, But I am making a game that requires a giant world map, one that scrolls with the character not like the original legend of Zelda game, Im after a Final Fantasy type map I have the map drawn to a point and I need to know how to set it up so It can have town, shops caves etc. I have mountains, Hills, And Buildings drawn out so I can set em and Script them, But need help sorry if this sounds all jumbeled but I really dont know excatly how to say this right.

signifer123
September 8th, 2006, 07:20 PM
Just have it like a normal town/dungeon. And have it jump frames to the town...the variables in the _root class, or the _global class should stay...

so you would just test a looped 4 corners/hitTest of each mc on ,ove, thne use gotoAndStop() to go into the town.

I attached a small sample...if you don't understand the above..

The sample only answers what i think you asked, the town can use the same principle as the world map to allow for you to jump back.

Things it doesn't handle that you'll run into:
-Loading world map and ending up right next to it, just save how much you moved then remodify it on load
-hitTest, you can loop though hitTest-able objects on move, or call pixel based test on move
-Random battles..., just use Math.ceil(Math.random()*100) and test what number out of 100 you want it to be.

Kojitasan
September 8th, 2006, 07:22 PM
I dont have the towns or caves and such drawn I have the world map drawn thats it nothing I know how to do Well I have a character moving too

Kojitasan
September 8th, 2006, 10:32 PM
OK that helps me a Bit but my main purpose is to actionscript the World map so it will scroll with the character moving. Here are the towns and the world map if it will help out and thanks in advance for even looking

LittleFenris
September 9th, 2006, 11:49 AM
OK that helps me a Bit but my main purpose is to actionscript the World map so it will scroll with the character moving. Here are the towns and the world map if it will help out and thanks in advance for even looking
Do a search for character movement in this forum. Basically instead of moving your character around the screen, you will move the background to it looks as if the character is moving, but he's staying in the middle of the scene (you'll take a character movement setup and reverse the + and - symbols cause the background will have to go the opposite way to look like the character is going in the right direction. I ended up giving up on that movement idea for my art-based project because it was using way too much CPU power. I'm sure this is why people go w/ tile-based games a lot of times but I don't have a clue where to begin to make a tile-based engine.

Here is all the code from my art based project that moves the background (a movieclip called "scene_mc"). There is some collision detecting in this script to so the character doesn't walk over things they aren't supposed to like walls and such. I just used a movieclip called "hitSpot1_mc" "hitSpot2_mc" etc...for the spots the character can't go past.


var characterDirection = "down";
var speed:Number = 4;
var run:Number = 0;
var standing = 1;
var totalHitSpots:Number = 12;
//SCENE CONTROLS
scene_mc.onEnterFrame = function() {
if (Key.isDown(Key.SHIFT)) {
speed = 6;
run = 1;
} else {
speed = 4;
run = 0;
}
if (Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
characterDirection = "up";
this._y += speed;
} else if (Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
characterDirection = "down";
this._y -= speed;
} else if (Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN) && !Key.isDown(Key.UP)) {
characterDirection = "left";
this._x += speed;
} else if (Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) {
characterDirection = "right";
this._x -= speed;
} else if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
characterDirection = "upleft";
this._y += speed;
this._x += speed;
} else if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
characterDirection = "upright";
this._y += speed;
this._x -= speed;
} else if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
characterDirection = "downright";
this._y -= speed;
this._x -= speed;
} else if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
characterDirection = "downleft";
this._y -= speed;
this._x += speed;
}
};
//CHARACTER CINTROLS
character_mc.onEnterFrame = function() {
if (characterDirection == "up") {
this.gotoAndStop("up");
}
if (characterDirection == "upright") {
this.gotoAndStop("upright");
}
if (characterDirection == "right") {
this.gotoAndStop("right");
}
if (characterDirection == "downright") {
this.gotoAndStop("downright");
}
if (characterDirection == "down") {
this.gotoAndStop("down");
}
if (characterDirection == "downleft") {
this.gotoAndStop("downleft");
}
if (characterDirection == "left") {
this.gotoAndStop("left");
}
if (characterDirection == "upleft") {
this.gotoAndStop("upleft");
}
//STOP CHARACTER FROM GOING OVER OBJECTS
for (i=1; i<=totalHitSpots; i++) {
if ((characterDirection == "right") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x += speed;
foreGround_mc._x += speed;
}
if ((characterDirection == "upright") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x += speed;
scene_mc._y -= speed;
foreGround_mc._x += speed;
foreGround_mc._y -= speed;
}
if ((characterDirection == "left") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x -= speed;
foreGround_mc._x -= speed;
}
if ((characterDirection == "upleft") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x -= speed;
scene_mc._y -= speed;
foreGround_mc._x -= speed;
foreGround_mc._y -= speed;
}
if ((characterDirection == "down") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y += speed;
foreGround_mc._y += speed;
}
if ((characterDirection == "downleft") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y += speed;
scene_mc._x -= speed;
foreGround_mc._y += speed;
foreGround_mc._x -= speed;
}
if ((characterDirection == "downright") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y += speed;
scene_mc._x += speed;
foreGround_mc._y += speed;
foreGround_mc._x += speed;
}
if ((characterDirection == "up") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y -= speed;
foreGround_mc._y -= speed;
}
//MAKE ALL HITSPOTS INVISIBLE TO VIEWER
scene_mc["hitSpot"+i+"_mc"]._visible = false;
this.characterHitArea_mc._visible = false;
foreGround_mc._visible = false;
}
};
//SHOW DIRECTION OF CHARACTER FOR TESTING PURPOSES
this.onEnterFrame = function() {
if (!Key.isDown(Key.DOWN) && !Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
standing = 1;
} else {
standing = 0;
}
trace(characterDirection);
trace("run ="+run);
trace("standing ="+standing);
};


Hopefully this helps you some.

KIERIOSHIMOTO
September 10th, 2006, 12:27 AM
if (Key.isDown(Key.UP)){
_root.map+=speed;
}

easiest way

LittleFenris
September 11th, 2006, 10:32 AM
if (Key.isDown(Key.UP)){
_root.map+=speed;
}

easiest way

How does this code help them? Thats not going to move anything, its just going to make the speed variable change. :h:

Actually I guess it won't even change the speed variable.

Joppe
September 11th, 2006, 10:59 AM
^ it wont even change the speed variable, it will just move the map with the spee.. Hold on, it wont even move the map.. that code doesnt do anything.. :/

LittleFenris
September 11th, 2006, 01:11 PM
^ it wont even change the speed variable, it will just move the map with the spee.. Hold on, it wont even move the map.. that code doesnt do anything.. :/

Exactly my point, that code does nothing.

Bash321
September 12th, 2006, 01:49 PM
i think it was supposed to be:
if (Key.isDown(Key.UP)){
_root.map._y+=speed;
}
and ofcourse

if (Key.isDown(Key.LEFT)){
_root.map._x+=speed;
}
and so on...

Joppe
September 12th, 2006, 01:57 PM
^Bash, so what if it was supposed to be like that. The speed variable is still undefined. And he didnt write that did he..?

LittleFenris
September 12th, 2006, 02:17 PM
^Bash, so what if it was supposed to be like that. The speed variable is still undefined. And he didnt write that did he..?

Yeah, telling someone wrong code is bad enough, but they didn't even define the speed variable for them in the wrong code either. It's best not to post code if its completely wrong or if its going to just confuse the person even more.

Bash321
September 13th, 2006, 02:03 PM
well i thought that it was self-explaining to define the speed

LittleFenris
September 13th, 2006, 03:25 PM
well i thought that it was self-explaining to define the speed

It may not be to someone not very familiar w/ Actionscripting yet. It's always good to make sure even the basics are covered when you help someone out w/ code cause a lot of times is something simple that is the problem.