ID:1052522
 
Code:
var/X,Y // passed to the proc as args
// source coords.
var/tX,tY //used for temporary storage of values
//pulled out of a multi-dimensional list of X & Y coords, representing steps away from source coords
var/cX,cY //used in proc after this section

switch(dir)
if(NORTH)
cX= X+ tX
cY= Y+ tY

if(SOUTH)
cX= X- tX
cY= Y- tY

if(EAST)
cY= Y+ tX //0x,1y dirN = 1 step north, dirE = step east
cX= X+ tY

if(WEST)
cY= Y- tX
cX= X- tY


Problem description:
I haven't yet taken the time to figure out what the diagonals will be, and I don't mind having the switch() here, but is there an easier (efficiency being my only concern) method of doing this?
What exactly is dir?
In response to Jemai1
Jemai1 wrote:
What exactly is dir?

lol. The facing dir, default orientation being NORTH. That's what the comment explains, //0x,1y dirN = 1 step north, dirE = step east
In response to AJX
Could you please explain that better? I don't get what your are trying to do here.

Nvm. I get it now.

It is fine the way it is. The transformation is direct to the point. There are no unnecessary calculations.
In response to Jemai1
Jemai1 wrote:
Could you please explain that better? I don't get what your are trying to do here.

Nvm. I get it now.

Just in case you don't: Coords of 1,1 would be one step up and one step right in a normal NORTH alignment. They would be one step down and one step left if facing SOUTH.

It is fine the way it is. The transformation is direct to the point. There are no unnecessary calculations.

This was my conclusion, but I figured I'd ask anyway.



Though I just noticed.. my transformations are wrong. I made a mistake somewhere. Oops. Will have to fix that later.