View Single Post
  #5  
Old 02-04-2010, 12:01 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
How I did the movement on Classic was by having a function that works a long a "primary axis". That could be x-axis, y-axis, or say 45deg.

Then it moves along that access, then when it encounters a wall in its path, it will slide perpendicular to the primary axis.

I made it even more complex (for the sake of efficiency), by doing a conquer-and-divide algorithm along the movement path. With built-in onwall() and onwall2() it literally had 0% impact on CPU. With our scripted onwall (i.e., loop through every player, npc, blocking tile and check if they are blocking & intersect), it matched default performance.

Getting it pixel perfect was a little annoying, but the script came out nicely in the end (probably about 200 lines if all the extra documentation and lines were removed). It supports variable speeds and sizes as well.

I might release it in Code Gallery at some point, but it'd require some cleaning up so it wouldn't rely on some of the other systems we have on Classic, so that is a project for when I have free time.
Reply With Quote