ID:144786
 
Code:
        MouseDrag(obj/cell/over_object)
if(currentartist != usr) return
if(!(istype(over_object,/obj/cell))) return
if(brush == DIAGONAL)
for(var/obj/cell/P in temp)
Recolor(P,P.oldr,P.oldg,P.oldb,0)
temp = list(over_object)
var/obj/cell/Currentcell = Start
var/Distance = 0
var/CurX = 0
var/CurY = 0
do
if(Start == null)
Start = src
CurX = Start.cell_x+round(sin(round(Get_Angle(Start,over_object),45))*Distance)
CurY = Start.cell_y+round(cos(round(Get_Angle(Start,over_object),45))*Distance)
if(CurX > 56||CurY > 48||CurX < 1||CurY <1)
break
Currentcell = cells[CurX][CurY]
if(Currentcell)
Recolor(Currentcell,R,G,B,0)
temp.Add(Currentcell)
if(Start.cell_x <= over_object.cell_x)
if(Start.cell_y <= over_object.cell_y)
if(Currentcell.cell_x >= over_object.cell_x&&Currentcell.cell_y >= over_object.cell_y)
break
else
if(Currentcell.cell_x >= over_object.cell_x&&Currentcell.cell_y <= over_object.cell_y)
break
else
if(Start.cell_y >= over_object.cell_y)
if(Currentcell.cell_x <= over_object.cell_x&&Currentcell.cell_y <= over_object.cell_y)
break
else
if(Currentcell.cell_x <= over_object.cell_x&&Currentcell.cell_y >= over_object.cell_y)
break
Distance++
while(1)


proc/Get_Angle(obj/cell/start, obj/cell/end)
if(!start || !end) return 0
var/dy
var/dx
dy = end.cell_y - start.cell_y
dx = end.cell_x - start.cell_x
if(!dy)
return (dx>=0) ? 90 : 270
. = arctan(dx/dy)
if(dy<0)
. += 180
else if(dx<0)
.+=360


Problem description: If you move the mouse in a circle, it jumps to the far sides for vertical and horizontal lines. It just does it, for no apparent reason and I'm totally confused. :-(


-Doh


EDIT: This is SUPPOSED to "lock" the mouse in 45 degree angles, allowing you to draw perfect lines. An example would be to open MS Paint, hold down shift and drag the mouse to see what I mean.
Problem fixed thanks to Yota.

        MouseDrag(obj/cell/over_object)
if(currentartist != usr) return
if(!(istype(over_object,/obj/cell))) return
if(brush == DIAGONAL)
for(var/obj/cell/P in temp)
Recolor(P,P.oldr,P.oldg,P.oldb,0)
temp = list(over_object)
if(Start == null)
Start = over_object
var/obj/cell/Currentcell = Start
var/Distance = 0
var/x1 = Start.cell_x; var/x2 = over_object.cell_x
var/y1 = Start.cell_y; var/y2 = over_object.cell_y
var/dx = x2-x1
var/dy = y2-y1
var/maxdistance = max(abs(dx), abs(dy))
var/CurX = Start.cell_x
var/CurY = Start.cell_x
var/angle = round(Get_Angle(Start,over_object),45)
for(Distance = 0, Distance <= maxdistance, Distance ++)
CurX = Start.cell_x+round(sin(angle),1) * Distance
CurY = Start.cell_y+round(cos(angle),1) * Distance
if(CurX > 56||CurY > 48||CurX < 1||CurY <1)
break
Currentcell = cells[CurX][CurY]
if(Currentcell)
Recolor(Currentcell,R,G,B,0)
temp.Add(Currentcell)
if(Distance > maxdistance) break


- Doh