Can anyone help me in this department. I've tried pulling apart some of the code from Shining Aid, but there's too many classes and I can't seem to pinpoint them. I'll keep looking, but if anyone could help me figure out how to implement the range tiles, that would be awesome.
#
#o#
#
#
###
##o##
###
#
EDIT: Nevermind, I'm an idiot. I figured it out. lol
« previous next » |
Range Algorithms (Read 44170 times)

#2
Administrator
Shining Sideburns

Posts: 837
Logged
#3
Administrator
Shining Spammer


Posts: 1,208
Logged
This is a buggy version that results in an infinite loop. However, if you can prevent it from walking the same squares twice it will work properly (just add a few if-statements regarding that
.).

Code:
Walk(Xo,Yo,Xo,Yo);
int distanceof(x1,y1,x2,y2) {
return abs(x1-x2) + abs(y1-y2);
}
Walk(x,y,Xo,Yo) {
if (distanceof(x,y,Xo,Yo) < range) {
//square is in range. Set some marker here to store this fact.
//Walk on.
Walk(x+1,y+1,Xo,Yo);
Walk(x-1,y+1,Xo,Yo);
Walk(x+1,y-1,Xo,Yo);
Walk(x-1,y-1,Xo,Yo);
}
return;
}