Complicated snake on a grid

Get help using Construct 2

Post » Tue Aug 20, 2013 1:49 am

Here's yet another question related to my board game :)

I'm trying to create a complicated snake. When the user moves a unit on the grid, it generates 'body parts' until it has reached its maximum. The idea is that once the max is reached, the unit will stop generating parts, and instead the other parts will move with the unit like a snake. A visual example is below:

Before movement:



First movement:



Second movement:



Final movement, here is the problem:



Basically, in the last image, the other two parts should move with the unit like a snake.

How might one accomplish this?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Tue Aug 20, 2013 9:15 pm

I've given some more thought into this, and I think the easier method is simply to delete the last instance and create a new instance behind the object. This would 'simulate' the tail without going into the complexities of actually causing the parts to have to follow.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Wed Aug 21, 2013 7:33 am

Alright, I almost have it. The problem is, it only seems to work with the first instance of a particular type:



The events I'm using to handle this is the following:



I did check in the debugger to confirm that both objects in the first picture that had more than 2 'parts' did indeed have PartsActive = 3 while PartsMax = 2 for both of them.

Does anyone know why this might be happening?

BoardGame.capx
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Wed Aug 21, 2013 10:53 pm

I've moved the deletion of the furthest part to a function for on-demand access. I also ran a few tests in the debugger and nothing has changed - programs still have PartsActive > PartsMax and the function doesn't seem to be getting called the second/third time around.

Can someone take a look?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 5:16 pm

I checked your function "DestroyFurthestPart", and you're only calling it once. Everytime your condition is met, be it by one or more instances of the family PlayerPrograms, the function will only be called once, with the first instance that meet the condition. You should do a for each family member under the condition PartsActive > Self.PartsMax.Magistross2013-08-22 17:21:44
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Thu Aug 22, 2013 6:12 pm

We (another experienced C2 user and I) have done this.

Adding a For-Each does not fix the issue.





There is no 'obvious' fix to this problem. I have tried the 'obvious' fixes, hacky workarounds, and more, and it is still not working.

It appears to only pick the first instance that meets the conditions while ignoring the others. I'm not sure what is going on at this moment. I am not the only one who has tried to solve this particular problem and lost as to why it doesn't work. We've isolated code, deleted code, and more. It may be time to ask @r0j0hound to investigate.

I'll be seeing if I can reproduce this issue with a simpler case.Excal2013-08-22 18:19:19
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 6:52 pm

You should usually do the picking BEFORE the for each, no need to iterate through objects that does not meet the PartsActive > Self.PartsMax condition.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503


Return to How do I....?

Who is online

Users browsing this forum: Microbex and 15 guests