tunepunk's Forum Posts

  • > Heres an example of what Im trying to do. The problem is that the for each loop only runs once. So how do i repeat it?

    >

    >

    >

    You have the trigger once condition there, right?

    If you remove it, it might not only trigger once..

    I'm also wondering why you have the else statements, by the way..

    I would just do it like this

    system pick all z-order

    > z-order move to layer "infront"

    system pick z-order by comparison z-order.y+z-order.elevation > Playerbase.y

    > z-order move to layer "Behind"

    Thanks. I did that before, but what im trying to do at this point is to optimize my code to use less CPU, hence the trigger once conditions. What i dont want is for values to be set, layers to changed and zSorting done every tick.... For Example: The Z sorting could be done only when an object switches layer to either infront or behind. If im not doing that the Zsorting only will use about 10-20% CPU with lots of objects on screen. Sorting smart, I managed to get it down to 0.8% CPU for sorting, by only sorting only things that needs to be sorted, Like overlapping objects, only when they need to be sorted.

  • Heres an example of what Im trying to do. The problem is that the for each loop only runs once. So how do i repeat it?

  • I have a Family of objects. Whenever a particular instance variable on any of those change i want to call a function. What is the best way to go about this? I also want the function to be called once, not every tick while the value is not same.

    I tried hundreds of different things now but can't seem to grasp it. And this is how my latest try looks:

    For each "Family1"

    variable 1 = 0

    Else

    Trigger Once > call function

    I can't seem to get it to work as intended.

  • Because the collision boxes are not set at the outer limits of the sprites, it would be awesome if there was a way to check for any colliding BBbox instead.

  • What are you up to? Boids ? Or something else? A picture will help people to understand the case.

    Im trying to optimize my Z Ordering routine to use less CPU for mobile, so I only want to sort objects that are nearby or overlapping. I don't want to create a lot of dummy sprites to limit the sorting to the ones that are overlapping, so i figured i would use distance instead. So what i need to do is to pick every sprite that is near another sprite, because theres no point to sort sprites that are not overlapping in any way.

  • I've been scratching my head for a while now and i cant figure out how to do this.

    I want to pick every object on screen that has another object within a certain distance. Whenever objects get clumped together i want to change some attributes.

    Pick by comparison: distance(block.X,block.Y,Family1.X,Family1.Y) < 120

    didnt work at all.

    Any ideas?

  • You might want to look at the Sine behavior.

    Here's how I'd do it. Cheap and easy !

    nice example. thanks! Thats not a bad solution!

    I managed to make it using the sin expression instead.

  • I googled a bit but I'm not a math genius but i think I have to add another value.. to add (Sagitta) af an arch to the 'offset' value.

    So now comes the REAL question. How do i write this formula in construct?

  • Have you tried to use the Physics behavior?

    I'm not quite sure because I never used it, but I think it might be just what you need

    I've tried it but it doesn't really work in this case. I'm basically just looking for a way to calculate an arc.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To clarify.

    Each bullet has 2 instance variables which i use to calulate the decline.

    "bullet.traveldistance" = how many pixels the bullet will travel before it's destroyed.

    "bullet.offset" = They Y offset of of the sprite following the bullet, based on the distances between the player and the traveldistance instance variable.

    When the bullet is created the offset is '-40' ... when the bullet reaches the endpoint the offset value is '0'

    So somewhere inbetween here i need to do some adjustments to the offset in order to get an arc.

  • I want to calculate a smooth curve for a sprite following my hidden bulle to simulate gravity in an isometric view.

    I can manage make a linear decline based on the distance travelled, but i want a smooth curve similar to what I'm trying to illustrate in this image. Is it possible with math/expressions to get that kind of decline? and what expressions calculations should I use?

    What I'm trying to achieve is to adjust the Y position (distance between the bullet and the sprite) following the bullet in a more curved fashion, rather than a linear decline (showed in red)

  • On a second note I also noticed that limiting the amount of true's at any given point is beneficial. Optimising the code to have as few true's as possible using more conditions like 'every X seconds', comparing distances, and other checks. etc etc.... Every time something is false, nothing is done, and the system moves on to next event.

    A good example is when I was Z ordering every object in a family (40+ objects on screen)... I managed to optimize this code from using 10%+ CPU to less than 1% just by limiting the amount of true, and still get the same result.

  • I made some tests on my game, and it turns out trigger once actually make a difference in many cases. I identified a couple of places where trigger once would make sense. And checking debug, those areas(groups) in the code went from using 0,8%-1.2%cpu to 0,1%-0.2% cpu. Let's say i have 20 places in my code where i can get this kind of benefit it all adds up to some serious processing power saving, which is really noticeable on mobile.

    Biggest difference was noticed on places where i used "For each"...

  • I noticed that chrome is performing very poor compared to IE when i test my game. My game in IE uses somewhere between 10-15% CPU att all times. In Chrome, my game uses 25% CPU, and even higher just by turning on debug mode. I've been trying to optimise events but i think i took it as far as I can. It's kind of funny... when i test my game in windows phone browser it performs better than chrome on my desktop... :p

  • I love these type of top down racing games, can't wait to see how this turns out. Interesting that you made it point & click though. Never seen that before.