Page 2 of 2

Posted: Sat Nov 18, 2006 4:38 pm
by c99koder
I've implemented Centipedes in DreamZZT, you can view the code here: http://svn.c99.org/viewvc/DreamZZT/trun ... iew=markup

Essentially, each segment keeps a pointer to the segment in front of and behind it, and whenever it moves it tells the segment behind it which way it moved, then that segment moves that direction on the next cycle.

ex:

cycle 1:
head: north
seg1: north
seg2: north

head hits a wall and moves east

cycle 2:
head: east
seg1: north
seg2: north

cycle 3:
head: east
seg1: east
seg2: north

cycle 4:
head: east
seg1: east
seg2: east

Hope that helps.

-Sam