Question about the Eat 'm all template

0 favourites
  • 3 posts
From the Asset Store
Fruit Slicer Template & Quality fruit and slice graphics (capx,c3p,png,illustrator files)
  • I've been looking at the Eat 'm all template. Just for fun, to see how it's made.

    But i'm baffled about 1 thing. And that this section

    + Player: On collision with Ghost

    + System: For each Ghost

    Trying to wrap my head around it I simulated a condition where it would really overlap 2 ghosts. But that made no difference at all. Also, a test project I created made no difference if I put the for each in the on collision or not. So the comment states that it's there to prevent from 2 lives being subtracted if it would accidentally overlap 2 ghosts at once. Well, according to me that's achieved by the wait logic inside the subevent.

    by waiting, the second ghost in the overlap doesn't match the IsAlive condition in the next tick, and it doesn't subtract the second score. In fact when I comment out the wait, it indeed does that, where as with the wait it correctly subtracts only 1 life.

    furthermore, I was thinking, so maybe it's there to add 2 times the score in the "isEscape" logic.

    But if you get rid of the For Each, it just as well subtracts 2 times the score, as opposed to when it was in. So no difference here either.

    So I'm thinking. Why actually is the for each ghost there? And why the comment? Did that work differently in C2 maybe?

    </TLDR>

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Looks like "Player on collision with Ghost" will never pick more than one ghost. In my tests, when player collides with two ghost instances, the event itself is triggered twice.

    So, yes, seems like "For each" is not needed here.

    But if this event could potentially pick two ghosts, then "For each" would be required because of that "Else" block in event 46. Without "For each" loop, if player collides with 2 ghosts, one of which has escape=true, and another escape=false, only event 45 will be triggered.

  • Thanks for thinking along with me!

    Good point, however that doesn't match up with the comment. It states that it's the idea that only 1 live is lost instead of 2 when colliding with 2 ghosts, if they are both uneaten. And that's exactly what would happen if only 1 of the 2 ghosts are eaten.

    So : 1 ghost is hit : no prob

    2 ghosts are hit, 2 are eaten : no prob, I've tested and the score is augmented twice, with or without the for each

    2 ghosts are hit, both are uneaten. Without the timer: I lose two lives, with or without the foreach, with the timer I lose 1 life, so the timer is responsible for not letting me lose 2 lives, not the for each unlike what the comment states

    2 ghosts are hit, 1 eaten, 1 not (your suggestion) : I did the test just now... simply by stopping the movement of the ghots, the ghosts spawn 2 over each other at the beginning of the game, so the ideal circumstance. I changed the condition from "is eaten" to UID = 135, which is one of the ghosts uid's. In that case, I lose 1 life AND I get 1 score. With or without the for each.

    I know I'm jabbering around over a small thing here, but I just wanted to profoundly understand, assuming that the code in the samples is flawless.

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