I'm making somewhat of an effort to add marine craft to my game; I've successfully managed to enable them to get in and out of the boats, and only be able to "drive" on water and nothing else, But then I figured 'Hey, why not make the boats 64x32?' So I arrive at my problem.

The craft are from an aerial view, and I've got the states set up so that they both always face the same way and stuff, but I'm not quite sure what to do to make the rear end of the boat follow the front.
icon = 'boat.dmi'
icon_state = "speedboatback"
density = 1

icon = 'boat.dmi'
icon_state = "speedboatfront"
obj/back = /obj/boatrear
for(var/mob/M in world)
if(M.vehicle == src)
src.loc = locate(M.loc)
var/turf/T = locate(src.x,src.y-1,src.z)
back.loc = T
back.dir = src.dir
var/turf/T = locate(src.x,src.y+1,src.z)
back.loc = T
back.dir = src.dir
var/turf/T = locate(src.x-1,src.y,src.z)
back.loc = T
back.dir = src.dir
var/turf/T = locate(src.x+1,src.y,src.z)
back.loc = T
back.dir = src.dir
Ugh. That Move() has HEAPS of errors in it. Instead of spending an hour going through them all, let me just fix it for you.

<code>mob Speedboat var/obj/boatrear/back = new var/list/peopleonboat=list() // Add people to this list when they get on, and remove them when they get off Move(Loc,Dir) .=..() // Looping through everyone on the boat is much faster than looping through everyone in the world. // As Move() is called pretty frequently, it needs to be as optimised as possible. for (var/mob/M in peopleonboat) M.loc=src.loc // You can replace that entire messy switch() with three lines. (Although it's not a switch() because you forgot to put in the switch() line... whoops!) var/turf/T=get_step(src,turn(dir,180)) if (T) back.loc=T back.dir=src.dir</code>

Tada. The only thing wrong with that is that the back of the speedboat will swing around all over the place, but I'm guessing you can live with that as that's how you designed it in the first place. =) A better way might be to swivel the front around and have the back of the speedboat be the bit that gets controlled; that wouldn't require many changes, basically just switch the icons around and replace "turn(dir,180)" with just "dir".
In response to Crispy
Cool, thanks.

One more thing to pester you with; is there a more effective way to "lock" the rear end of the boat to the front so it doesn't separate from it so oddly?

I don't mind that the boat just kinda "snaps" to its' new location, just keeping the two pieces together is all I'm worried about.
In response to Enigmaster2002
Whoops, forgot about that! The var you're looking for is animate_movement. Try setting it to SYNC_STEPS on the tail of the boat. Hopefully that will synchronize it nicely; I'm not sure if that will actually work in this case though.

If it still looks dodgy, a workaround is to set animate_movement to NO_STEPS on both the head and the tail; it should then hold together perfectly, but it will jump abruptly from tile to tile rather than sliding between them. If you don't mind that, it's probably the safer option to use anyway.

Edit: I remember in Lode Wars that the vehicles, despite (I assume) being set to SYNC_STEPS, would still jiggle around a bit. Leftley got around this by designing the graphics so that it wouldn't matter if they got jolted a few pixels each way; it would just look like the vehicle was bouncing up and down on a bumpy surface. Which he actually managed to get looking quite classy (apart from the occasional lag spike which would wildly separate the two parts, but there's not much to be done about that). =)