Why is my snake not growing?!

Get help using Construct 2

Post » Thu May 19, 2016 2:57 pm

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
B
8
Posts: 26
Reputation: 347

Post » Thu May 19, 2016 3:07 pm

Have you tried rubbing it? :D
B
8
S
2
Posts: 24
Reputation: 536

Post » Thu May 19, 2016 3:11 pm

I knew i'd end up with a response like that! :lol:
B
8
Posts: 26
Reputation: 347

Post » Thu May 19, 2016 3:14 pm

sorry... I had to! :D

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.
B
8
S
2
Posts: 24
Reputation: 536

Post » Thu May 19, 2016 3:20 pm

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
B
8
Posts: 26
Reputation: 347

Post » Fri May 20, 2016 9:56 am

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?
B
8
Posts: 26
Reputation: 347

Post » Fri May 20, 2016 10:25 am

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
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Fri May 20, 2016 10:47 am

Thank you so much @Kyatric
B
8
Posts: 26
Reputation: 347


Return to How do I....?

Who is online

Users browsing this forum: Linetaru and 9 guests