How do I properly order this piece of code?

0 favourites
  • 3 posts
From the Asset Store
Two levels with two sistem Wave. with Source-code (.c3p) + HTML5 Exported.
  • As someone who's a big fan of the Fire Emblem series, I've decided to see how far I can get in Construct. I think I'm doing okay, but I've gotten stuck in programming the movement range with different terrain costs.

    I think I'm most of the way there, it's just that when I'm comparing the movement cost from each direction, it's defaulting to the last one, meaning that it's not accurately showing where a unit can move. I've tried to order the code in a way to make it to it in order, in multiple ways, but none seem to work.

    If it helps, below is a screenshot of what I'm using at the moment.

  • It’s not clear from your description and screenshot what you want the code to do.

    Looks like you are looping over an array of xy positions, and comparing if the cost is greater than the any of the neighbors.

    Then it checks if the neighbor isn’t the first index (indexof gives -1 when a value isn’t found) or if the cell is one of the first four in the array.

    Other than that keep in mind setting the return value doesn’t exit the function with the event system, so all four events will run if true.

    After that I’m not sure what it does. Returns the cost with some location maybe?

    What do you want this function to do and how is it not doing it now?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, I've managed to get it working now by moving it out of a function. Not really sure why I put it in one to begin with, but it's working now.

    I didn't go into the specifics because the main problem was that the four options seem to be executing at the same time, meaning that instead of going through them in order it's effectively ignoring the results of any previous block. Not really sure how this is different for functions, but at least I know there's a difference now.

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