Sign in to follow this  
Ansimuz

Snake Enemy

Recommended Posts

Hi,

 

What would be the logic or best way to create a entity followed by other entities to create a snake made of linked entities.

 

For example a head entity that will be followed by other entities that form the body of the snake.

 

BTW i am using impactJS

 

snake-links.png

Share this post


Link to post
Share on other sites

So this is what I did here http://rezoner.net/labs/superrotoshooter

 

There is an invisible dot that follows some path - and each let's say 25 ms this dot is spawning a point

this.points.push[this.x, this.y];

Also remember this

if (this.points.length > this.segments.length) this.points.unshift();

Now the only thing that left is to pass these point positions to corresponding segments and make them move towards new destination.

 

You can realize this using some kind of tween (easing) or implementing simple physics with velocity.

 

I am pretty sure that there are more (clever) ways to do this tho.

Share this post


Link to post
Share on other sites

So this is what I did here http://rezoner.net/labs/superrotoshooter

 

There is an invisible dot that follows some path - and each let's say 25 ms this dot is spawning a point

this.points.push[this.x, this.y];

Also remember this

if (this.points.length > this.segments.length) this.points.unshift();

Now the only thing that left is to pass these point positions to corresponding segments and make them move towards new destination.

 

You can realize this using some kind of tween (easing) or implementing simple physics with velocity.

 

I am pretty sure that there are more (clever) ways to do this tho.

 

Your game looks amazing!

 

By the time a read your post i implemented a solution. This is what i did i spawned the body parts with a delay each part follow the same path so it looks like they are linked even thought they are just one after another following the same path. Like cars in a road.

 

You implementation is a clever way. It may work to others.

 

Thanks for everybody for your help.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.