R0J0hound's Recent Forum Activity

  • It's probably in how events work or something. I don't have a link.

  • It probably covers that elsewhere in the manual. By default all instances are picked. Conditions filter the instances that are picked, but some are just logical conditions and do no picking. When an object is created it becomes the only instance of that type that is picked for the rest of that event or until another instance is created.

    That's basically the meat of picking but there is also some nuance to "else", "or" and how created instances are added but you don't have to typically worry about those.

  • Another option to make it faster is to do the same thing in JavaScript. That would churn through the loops faster than the event sheet. Further down that rabbit trail is wasm but not sure it’s worth all the extra effort. Faster still could be to somehow leverage the gpu to do it in parallel. Maybe pack all the data into a texture, run that through a shader onto an output shader, and read back the pixels for the result. I may be mistaken though since I’ve never attempted that and your sim may not be able to be parallelized.

  • I think we are limited to being within the primary window with html5 and js. In theory it might be possible with nwjs or that new windows export since it could be extended to do stuff beyond browser stuff. But the main issue I see is you’d need to handle the rendering, input etc in those windows completely separate from construct since I can’t think of a way to have constructs renderer handle that. Overall I don’t think it’s feasible to do with construct without significant effort and time.

  • There’s a branch of math that deals with stuff like that called

    en.m.wikipedia.org/wiki/Mathematical_optimization

    But Wikipedia probably doesn’t have the most understandable examples. A simple example of that is maximizing the a fenced in area with the least amount of fence. Although I’m not certain it has any helpful tricks in your case since the triple loop is the one causing the calculation to take longer.

    Algorithmically you might be able to shorten the loops by sorting the lists of a,c and c by cost so you could use stop the loops when you know the rest of the instances were too expensive. Something like this:

    For each A ordered by cost
    - if A> income then stop loop 
    - for each B ordered by cost
    - - if A+B> income then stop loop
    - - for each C ordered by cost
    - - - if A+B+C>income then stop loop
    - - - look at priority…

    Since it is a simulation and if you’re happy with a good solution but not necessarily the best solution you could just compare three random instances of A,b,c multiple times. Could seem more realistic in a way since given the same problem humans would do that. Something like this:

    repeat 100 times
    Pick random A
    Pick random B
    Pick random C
    — do stuff

    Even that probably could be done better with a weighted random with a sorted list so that higher priority stuff is looked at more than low priority stuff. Or maybe sort the lists by cost and pick random instances by a normal random distribution (bell curve). That would make the stuff in the middle of the cost range be picked more than the the expensive or cheap stuff. To do that you’d need an array of the instances sorted by cost and a function to get a normally distributed random instead of the standard uniform one. I forget if c3 provides that.

    Array of A instances
    Sort array by cost
    i=int(normalRandom(array.width))

    Anyways just some ideas.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • megatronx

    That’s how the pasting was made to work. It’s just drawn in place where the object overlaps the paster object. Hence the stamp icon.

    The quad draw function wasn’t meant to use an object’s effects, only its texture.

  • Over time the ball could lose some height with most all the behaviors.

    Here’s a way to not lose speed or height over time. The height will vary slightly but stay around the same.

    Var gravity=500
    Var vx=100
    Var vy=0
    
    Every tick
    — add gravity*dt/2 to vy
    — ball: set position to self.x+vx*dt, self.y+vy*dt
    — add gravity*dt/2 to vy
    
    Ball: collides with wall
    — set vx to -vx
    
    Ball: collides with ground
    — set vy to -600
  • What you showed was the non-interactive part which could be a fixed video, although I’ve seen that ad where it is interactive.

    It’s probably a mix of pre-baked videos of the fluid and actual fluid simulation in local areas, although it’s just a guess. Most fluid simulations are grid based or particle based or some mixture of the two. Or maybe they were clever and found a way to just reuse water animations and blend them together.

    This channel shows two ways that fluid simulations can be done in general (it’s not construct related).

    m.youtube.com/watch

    m.youtube.com/watch

    You poke around the forum for construct related examples. The simplest would be to using a lot of small physics balls to do the simulation. It doesn’t scale well though. Another is just simulating the surface.

    Overall the event system is a bit heavy to implement a water sim. The physics behavior is a bit better but it doesn’t behave the same and also is a bit heavy with that many objects. JavaScript would be the fastest way to go, or maybe using an existing library. It’s just the matter of getting it to play nice with constructs engine.

    The main issue getting some custom library to render in construct. You need to modify how the library renders so it just uses constructs renderer which may or may not have all the features you need. Another approach is trying to modify constructs renderer instead, but it’s not designed to allow that easily and officially it’s discouraged and not supported. A third way is to just have a separate canvas with its own renderer and you’d layer the canvas’ on top of each other.

    Anyways. Just some general ideas. Personally I’d try to somehow fake it as much as possible.

  • megatronx

    Sorry, I'd avoiding any aspect of making plugins and I'm not a fan of debugging ai generated stuff.

    megamente Br

    Alexander Wiseman

    I haven't used this plugin in months but I tried it and it works here. You'd load the texture to a tag, say "tex" then set the object's texture to that tag. As long as your mesh uv's are good then it should show the texture.

  • Well what’s causing it will be hard to spot. The waits make it hard to know the exact order things are run. Maybe don’t let the function run until the previous one completes. After all the order you want things to run is fixed. You could also try the timeline or just make it in one function so it’s easier to follow the logic.

  • So as you have it now the “every 0.01 seconds” it would trigger ~100 times a second on a 240fps screen, and 60 times a second on a 60fps screen ( since anything lower than dt is dt with every x seconds.

    If you want it to update at the same fixed rate you could remove the every 0.01 seconds and do something like this.

    Var t=0
    
    Every tick
    — set t to t%1
    — add 100*dt to t
    
    Repeat int(t) times
    — do stuff

    Or did you want it to be continuous instead of doing the steps you were using?

    For that, remove the every 0.01 seconds and change the set x’s from:

    Set x to self.x+rate

    to

    Set x to self.x+rate*100*dt

  • I think if you add a for each enemyspawnarea to event 157 it should fix it.

    The on timer trigger doesn’t seem to trigger for each instance individually. Instead all the instances that finished their timer in the last tick are picked in the trigger.

    For example without the “for each” if two spawners finish their timer in the last tick and they are both “white to red” then only one would be added to the count. The for each would make it add 1 for each.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound