//remapping collision detection system

atom/proc/Collision(atom/movable/A)//algorithms

atom/movable/proc/Collided(atom/A)

atom/proc/Radius() return collisionradius

atom/proc{pxpos()return x*64-16+pixel_x;pypos()return y*64-16+pixel_y}

atom/var/collisionradius = -1 //make sure you can't collide with nondense

proc/CheckDist(atom/A,atom/M)

var/ax = A.pxpos() // A.x*32-16+A.pixel_x//find A's centerpoint

var/ay = A.pypos() // A.y*32-16+A.pixel_y

var/mx = M.pxpos() // M.x*32-16+M.pixel_x//find M's centerpoint

var/my = M.pypos() // M.y*32-16+M.pixel_y

var/dist = abs(sqrt((abs(ax-mx))^2+(abs(ay-my))^2)) //based from pythagorean theorum

// world << "[dist] [A.Radius()],[M.Radius()]"

world << abs(sqrt((abs(ax-mx))^2+(abs(ay-my))^2))

if(dist < A.Radius()+M.Radius()) return 0

else return 1

mob/Move(turf/T)

var/no = null

for(var/atom/A in range(2,src)-src)

if(!CheckDist(A,src))

spawn A.Collision(src)

spawn src.Collided(A)

src << "You have collided with [A]!"

no = 1

if(!no)

if(loc)loc.Exit(src)

if(T)T.Enter(src)

if(T)src.loc = T

mob/collisionradius = 12

mob/Collided() velocity = 0

Copyright © 2015 BYOND.
All rights reserved.

The reason your results are coming out wrong is that you used the wrong operator. You used ^ when you should have used **. In some languages, ^ is for exponentiation, but in BYOND it's for a bitwise XOR.

I wouldn't recommend using **, however, or your code's gonna be dog slow. You also don't need to use sqrt(), which will be dog slow as well. Instead, use this:

Lummox JR