Okay, I dug into the old code and have made some updates. I didn't really do much to the maps (or the art or the music or... ugh), but I updated to the latest engine and cleaned up the main system code some.
http://kildorf.com/westrun/journey_to_black_mountain.zip
(If you use Chrome, it might warn you that this is dangerous to download or whatever because no one else has; I assure you it's the same game as available on the site, with a few tweaks to the code.)
The important parts here are two files:
mapswitch.vc and
transitions.vc. Feel free to copy these right into your project! You can use them with #include ...
#include "mapswitch.vc"
#include "transitions.vc"
... in your
system.vc file.
There are three functions you'll need to use. First, before you call any maps (somewhere in autoexec() would work), call setDefaultPlayerCHR(). This sets the CHR file you want to use for your main character. In JtBM I call it right before my first mapSwitch, on line 255 of
system.vc.
setDefaultPlayerCHR("kiel.chr");
Next, when you want to switch to a map, instead of calling Map() directly, call mapSwitch() instead. It takes five parameters:
void mapSwitch(string mapname, int x, int y, string face, int trans);
-
mapname is the name of the MAP file you want to load.
-
x and
y are the coordinates you want to put the player at to start.
-
face is one of "U", "D", "L", or "R" (for up, down, left, and right, of course) which is what direction you want them to be facing when the new map loads. Lastly,
-
trans is the transition you want to use for the map change, and should be one of either
TRANS_BOX or
TRANS_FADE. TRANS_BOX will give you a sort of shrinking/expanding box effect , while fade just does a fade to black and then back in.
I use mapSwitch all over the place in the map VC files. The first one I use is in
system.vc on line 256, and looks like
mapSwitch("home.map", 13, 4, "R", TRANS_BOX);
Lastly, in every map file you need to specify a Startup Script. You do this in the map properties (Map > Properties...) in maped3. I use the startup script name 'start' for all my maps, and they're always right at the top of the map's VC file, just for convenience. You need to call onMapLoaded() in this function. For example, from
gory.vc in JtBM...
void start() {
hookRetrace("tick");
onMapLoaded();
}
You can ignore the hookRetrace, the important line is the second one. What that function call does is goes and retrieves all the things that got saved when you called mapSwitch() -- where you want the player to end up, etc -- and spawns a new player entity for you, and hooks it all up.
Whew! It's been quite a while since I've written any VergeC. I hope this has been somewhat informative! Take a look at how I implemented mapSwitch() -- hopefully it should be pretty straightforward. If you're still confused as to how it's working, I'm happy to explain more. :)