Snake-like movement and animation

0 favourites
  • 6 posts
From the Asset Store
Snake
$9.99 USD
Template for snake, fully documented in comments and video
  • I was wondering how can I implement a snake-like movement and animation.

    I mean the old snake game found in nokias where you have to catch apples.

    Do i use one block and attach one every time i catch and apple? should i make and array?

    I'm lost.

  • You may do it by the easiest way.

    • Make the head and 2 or 3 body parts;
    • Set the origin point of each image to be at bottom or right, or left, or up, but keep the same for all of them;
    • Add a new point on the opposite side;
    • Set their X and Y origin to match the second point of the sequenced body part, example, the first body part will pin to the head, then, ahead;
    • Make a number instance variable for the body parts and call it by "ID";
    • The body parts and head on the canvas, you'll set their ID manually, but each time the snake eat a apple, you'll need to add one to the ID count and set to create a new body part, attaching it to the body part with the ID-1;

    You can improve it by doing a tail on a new frame animation for the body parts, and checking if it's the highest ID, if so, change its sprite number, also, make the animation speed to 0.

    For more information, please, read this tutorial, it may help understand how to get a specific item on the canvas and for future projects! =]

    scirra.com/tutorials/361/understanding-uid-iid-health-of-enemies-and-rocket-smoke-trail

  • Snake type game example R101

    <img src="https://dl.dropbox.com/u/22173473/snakesplash.png" border="0">

    Use arrow keys to control the snake.

    PLAY

    DOWNLOAD CAPX

    All graphics and textures my be..feel free to use or modify.

  • Wow, thanks both of you!

    chrisbros is there a way on your demo to kill the snake when it collides with itself?

    TELES0808 Im going to try your method!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for this. It's a lot better than my attempts with GameMaker and PyGame. GameMaker has a nasty lag problem with keyboard events that ruins games like this.

  • Snake type game example R101

    <img src="https://dl.dropbox.com/u/22173473/snakesplash.png" border="0">

    Use arrow keys to control the snake.

    PLAY

    DOWNLOAD CAPX

    All graphics and textures my be..feel free to use or modify.

    chrisbrobs hi, can you reupload? thx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)