Centipede code for my ZZT clone (in Pascal) help

Discuss how totally awesome Bang! is here.

Moderator: Terryn

c99koder
Ordinery
Posts: 46
Joined: Sat May 13, 2006 8:06 pm
Location: East Windsor, NJ
Contact:

Post 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
Post Reply