Complicated snake on a grid

0 favourites
  • 7 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • 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:

    <img src="" border="0" />

    First movement:

    <img src="" border="0" />

    Second movement:

    <img src="" border="0" />

    Final movement, here is the problem:

    <img src="" border="0" />

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

    How might one accomplish this?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright, I almost have it. The problem is, it only seems to work with the first instance of a particular type:

    <img src="" border="0">

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

    <img src="" border="0">

    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?


  • 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?

  • 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.

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

    Adding a For-Each does not fix the issue.

    <img src="" border="0" />

    <img src="" border="0" />

    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.

  • 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.

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