HessamoddinS's Forum Posts

  • Is there a better way to do this? maybe without the Canvas plugin?

  • Hi

    I'm trying to copy my camera to a lot of places in the layout. See the file below to see what I'm trying to do (press space when you ran the game)

    https://www.dropbox.com/s/ormmp0ahpcg0z ... .capx?dl=0

    however I have a really high CPU usage which is because of the high amount of loops. I wanna know if there is a better way to do what I'm trying to achieve.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't we have the close path action?

    I really need it

    edit: doesn't matter I added Close Path to the plugin

  • You do not have permission to view this post

  • Hi

    The game I'm working on is heavily using the Shadow Cast plugin. However anti aliasing on the shadows is horrible. The edges are too obvious and it does not look good at all. Is there anyway to make them smoother? I remember back in Construct Classic there was an option to do so.

    That would be great if Construct would use Electron instead of NW.js

    And would add support to circular shaped objects (Shadow Cast and Collision) as well as fix the bug that would occur when the light is close to the object casting infinite shadow.

  • Hi

    How can I make an effect like this:

    When the objects starts moving, you can see its glowing from the back

    A lot of games use this effect

    I know the image and description is not good and I hope you get what I'm looking for.

    Thanks

  • 99Instances2Go ha, we were definitely thinking along the same lines. You must have a really nice laptop!

    HessamoddinS

    I just added another optimization that I was thinking about adding to the first version - limiting how many sprites it checks per tick.

    this version bumps the sprite count up to 300, but only checks 5 per tick. So, it takes a whole second for them all to have a turn looking for connections - but because there are so many, most of them will already have the connection made to them. Since it checks the same number every tick, there is no jerkiness.

    it runs very smoothly on my computer, cpu is under 50% as reported by C2 (but Windows says it really is only about 27%). If you watch really closely you can occasionally see where a connection should have been made but didn't get checked in time. But since there are so many other connections going on, I doubt anyone would ever notice.

    http://www.rieperts.com/games/forum/DotEffect2.capx

    if you play with the SpriteCount and CheckPerTick variables, keep SpriteCount an even multiple of CheckPerTick, otherwise some will never get checked, or it may even go into an infinite loop or something...

    That's great. Thank you

  • HessamoddinS

    I beleive that this is what you want to do.

    https://www.dropbox.com/s/2bxe5qcl3v8oq ... .capx?dl=0

    Runs like a slow poke in the debugger.

    Runs at 118 FPS on my laptop, outside the debugger.

    I like the idea of using a dictionary to keep the amount of lines as low as possible.

    But, then you gots to use the the dictonary's feature to not allow the same key twice. Look at how i solved that.

    Have fun.

    Edit: AllanR, did not see your last capx yet. Had this topic open while coding, so topic was not refreshed when posting this¨.

    Thank you, this is great. I think I have solved the problem of having the same key twice but it wasn't good.

    Really helpful Thank you guys this thread was great I learned a lot from your examples.

  • AllanR Thanks that was really helpful, I learned a lot

    The thing is I was trying to implement this effect in the background to the game I'm working on and I had plan to use a lot more than 100 sprites on the screen, which i think would not be possible. I just hope there was a more efficient way that could handle around 300 objects.

  • Asmodean ok thanks i will look into it

  • First, if you have performance problems. Put the events in groups, the less events in one group the better. Then check the CPU-Usage in the Profile-Tab in the Debug-Layout

    Your performance problem is the function call. You're calling the function from a loop and in the function there is another loop. You have up to 250 sprites and for each sprite you call the function, which is going again trough all sprites. That's an a amount of up to 62500 loops in one tick! (1/60 sec).

    I made a little change, don't know if that's still exactly what you want, but you will see I only check 2 sprites a tick, that will be call the function. So this are only 500 loops a tick.

    The change in the function you can ignore, it was only a test and it seems you're gaining nothing from this change.

    I hope I could explain this well enough, sorry for bad english.

    https://drive.google.com/uc?export=down ... TdYaFM2aHc

    Your code works but it has a problem. A Square can only connect to one square at a time, but I want squares to connect to all the squares that are in the distance of 50 or less pixels

  • Yes i know what the problem is. The loop inside the function makes the problem and that is why because i couldnt find a better way to compare the distance of each instance of a same sprite with other instances. So the whole idea is to create a line sprite if 2 instances are closer than 50 pixels with each other. So is there any better way to check the distance of each two instances?

  • Hi

    So I made something today, however it has high CPU usage. Here is the source file:

    https://www.dropbox.com/s/ap2hxpqlqoic2 ... .capx?dl=0

    (The code is messy and is not well written)

    Is there a more efficient way to do what i was trying to achieve?

  • Thanks guys helpful solutions