Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Griegs

I'd like to be able to have say the head of my snake and then have a bunch of entities follow the leader as it were but unsure how to implement that so that no matter how the head moves, the followers should follow the same track.

Or is there a better way to do this?

1 decade ago by Griegs

Never mind, I found a way to do this using Math.sin.

update: function () {
this.posX = this.posX - ig.game.scrollSpeed;
var y = Math.sin((this.posX) * Math.PI / 180);
if (y >= 0) y = 100 - (y - 0) * 60;
if (y < 0) y = 100 + (0 - y) * 60;
this.pos.y = y;

this.parent();
},

Each snake segment is responsible for moving itself and doesn't rely on any preceeding segments.
Page 1 of 1
« first « previous next › last »