Why is my snake not growing?!

0 favourites
  • 8 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • This is driving me mad!

    Trying to make a simple snake type game where the mouse cursor controls the snake.

    I have followed an excellent tutorial on how to get the snake to have multiple sections and I love how the snake moves around the screen.

    I'm really struggling with how to get the snake to grow by 1 segment each time he eats an apple.

    I have a global variable called "SnakeLength" That sets the length of the snake on the start of the layout and then I have an event that when an apple is eaten it adds +1 to "SnakeLength" but this does not affect the length of the snake during the game?????

    If anybody would be willing to take a look at my .capx https://dl.dropboxusercontent.com/u/155402113/Mouse_Snake.capx and see how i can get my snake to grow I would really appreciate it!

    Thank you,

    Matt

  • Have you tried rubbing it?

  • I knew i'd end up with a response like that!

  • sorry... I had to!

    Anyway, the problem is that you are only running the actions that create the snakebody once, on the start of the layout. What you have to do is put the actions to make a new snakebody sprite and pinning it, in the event where you add 1 to score.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I thought it would be something like that.

    Any chance you could show me exactly what i would need to change?

    Thank you for your (second serious) speedy response

  • Still struggling with this.

    Have tried BunnehBoy 's suggestion but now I just end up with the snake not only growing a section of body he also grows another body too!

    Has anybody else got any ideas?

  • Add a global Variable "LastUID"

    In event 4, add an action "Set LastUID to Body.UID" (this will allow us to pick that body part later.

    Event 10 add a blank subevent.

    Add a local variable (NewUID)

    Create a body part (like in event 4) and set NewUID to Body.UID (the newly created body part.

    Then as a subevent of this subevent, Pick all Body, Body pick instance with UID LastUID, Tailpiece2 pick instance with UID NewUID.

    Actions : TailPiece2 Set position to Body.X + 32, Body.Y

    TailPiece2 Pin to Body Rope Style

    Set LastUID to TailPiece2.UID

    Capx

  • Thank you so much Kyatric

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