How do I calculate distance between the same Sprite using the content of their varaibles?

0 favourites
  • 10 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Basically, I am using only one object and copies of it. What differentiate some of the copies is their variable : Ownership (which is whether owned or unowned)

    Now I need to calculate if the distance between a owned object and an unowned one is less or equal to 8.

    For now I am using the Line of sight behavior to do so but I feel like it makes performence drop to much for some reason and want to know if there is an alternative to it .

  • I don't see any logic related to calculating distance. What is cut off at the top, is that a group ?

  • The line of sight can see up to 8 pixel, so by checking if there's any sprite in its reach I can also insure that they are all within 8 pixel. Thats how I calculate the distance.

  • Ok and the answer to the other bit ?

  • Its only an event to activate what's below when the button is clicked.

    It's in a group. But i think the lag is caused because I have too much objectes (40'000 sprites)

  • If it lags every time you click the mouse for that event then I guess it's from checking the LOS of 40,000 sprites.

  • It lags all the time and i think its only checking around the sprites having the “france” variable.

    So the issue really is the massive amount of sprite? Setting them to be non-visible outside the screen doesn’t change anything (it takes even more CPU) and changing the sprites for SVG image doesnt fix anything about lag.

    Also I can’t really reduce the amount of sprite because together they form the a map that change colour depending on the variable and each hold information so a tile map wont work since its only 1 object.

    Doesn’t it mean that a project like this one can t be done efficiently in Construct3?

  • So did you actually have any problem with calculating distance ? because it sounds like you are saying the problem is lag? This makes the post confusing.

    If it lags all the time then it could be any of your events, or it could the graphic memory usage so maybe check this. In general though I'm surprised you added 40,000 objects to the screen as this seems like a poor game-making strategy in any engine.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I thought it was the line of sight behaviour that was causing the lag thats why I wanted an alternative to it,but now it’s probably that there’s to much sprite.

    I dont know I could change that since I want to be able to paint the map and larger sprite wouldn t look good.

    EXEMPLE:

    *Every cells are 5x5 pixels of resolution

  • Ok if this is just about the lag, you already created a duplicate post so we can leave this one.

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