Hm, dwks told me about vectors in another thread, but I haven't seriously looked into them yet. Perhaps that would be a good idea.... My code is going to get very gluggy for multiple checks. I've just implemented a system that scrolls the map when the character gets within a certain distance of the edge of the screen (or not, if the map is too small or if it's already *at* the edge of the map), but since at the moment it reruns the mapprint() function every single time it scrolls up or down, it's S-L-O-W. Ideally, it'd be best to do something similar to what you say about printing in blocks - make the move without changing the display, then check each tile inside the screen block against its new value after the move to see if it's changed. If it has, *then* reprint that location, if not, don't.
Currently, though, I'm working on implementing an 'examine' command... maybe once that's done I'll look into vectors.
It is kind of addictive.... At the moment I have a larger map with a house-type thing with two doors that the character can (slowly, if any scrolling is required) wander about. Not exactly the next installment of Half-Life, and yet strangely addicting all the same. Maybe because it's different when you have an idea of just how difficult it is to make these things
EDIT: Hitting some severe difficulties with my map refreshing function....
Code:
void location::refresh_temp()
{
for (int y = ydisp; y<31; y++) {
for (int x = xdisp; x<101; x++){
for (int z = 0; z < TYPE ; z++){
mapt[x][y][z]=map[x][y][z];
}
}
}
}
void location::refresh_print()
{
int x1;
int y1;
x1 = 0;
y1 = 0;
for (int y = ydisp; y < (ydisp+10); y++){
for (int x = xdisp; x < (xdisp+50); x++){
for (int z = 0; z<TYPE; z++){
if (mapt[x][y][z] != map[x][y][z]){
locate.printloc(x,y,x1,y1);
}
}
x1++;
}
y1++;
}
}
At the moment, it calls refresh_temp() before moving or changing anything, and refresh_print() after the move/change has been made. ydisp and xdisp are the top left corner actual x and y coordinates, and the printloc function variables are, in order, actual x, actual y, display x, display y.
At the moment, the display doesn't change at all. I'm not sure if this is due to problems in the comparison or in the values passed to printloc or what, but it's really bugging me. If anyone can spot what I'm doing wrong here, I'd really appreciate it.