R0J0hound's Recent Forum Activity

  • You can calculate the total velocity of an object with the physics behavior with:

    sqrt(sprite.physics.VelocityX^2+sprite.physics.VelocityY^2)

    Then compare that with your 'velocity threshold' with a 'on collison' trigger.

  • Here's one such way to implement it:

    https://dl.dropboxusercontent.com/u/5426011/examples18/tile_engine.capx

    With 32x32 sized tiles then a total of 336 objects would be used.

  • 1) Use the the "for" loop condition to set ranges in an array. For example with a array of size 100x100 this will set the bottom right quarter of it to one:

    For "col" from 50 to 99

    For "row" from 50 to 99

    --- Array: set at (loopindex("col"), loopindex("row")) to 1

    2)Same answer as for 1, just use different ranges with the for loops.

    3) There are a few topics on this. Best results come from finding a method and tweaking it till it's satisfactory. If you specify exactly what you want the terrain to look like then we could help you better.

  • Guizmus I like the idea of adding another layer to the array to keep track of the number of neighbors. Here is an updated example that also has a major optimization of only scanning through the edge positions where a cell can be made. It should be much faster, and the main slowdown will be from drawing all the sprites.

    sirrance i added some comments to help show what's being done.

    dropbox.com/s/gr2b0phywb7ycvq/maze_prim_faster.capx

    Edit: thinking about it there may be a certain amount of bias with me using the repeat condition. There is no visual indication of this but not all the edges will be considered as the 10 created ones won't be picked until the next toplevel event. It may be of no relevance at all now but may be an issue if the capx were redesigned to make the maze instantly instead of progressively.

  • I had a crack at it and here's my result:

    dropbox.com/s/ufmptfuadafxz76/maze_prims.capx

    I used an array of size (20,20,2) to store the weights and weather or not a bit was plotted there (0 or 1).

    It is rather slow since it scans the entire grid every time a piece is added. It can be made much faster if you find a way to only scan through neighboring cells.

  • Yes, it is possible. You could use webstorage to store the state and time of last access, and when you open it you could see how much time has elapsed and cause things to happen as if it was running the whole time.

  • While there are ways to calculate the slope on any point on a parabola I find a simpler method is to save the old position of the objects and set the angle from the old to current position. The event would look like this:

    +every tick

    set angle to angle(self.old_x, self.old_y, self.x, self.y)

    set old_x to self.x

    set old_y to self.y

    This method has the added benefit that it can be used with any motion.

  • Perhaps something like this?

    http://www.scirra.com/forum/1d-water_topic47386.html

  • If you devise some kind of grid based motion you could make a block get created at the old position once a motion is completed.

  • This topic is relevant:

    http://www.scirra.com/forum/parabola-tracjectory-tracing-with-physics-box2d_topic61895_page2.html

    But you're right it does use the physics behavior so here is a capx the behavior replaced by four actions:

    https://dl.dropboxusercontent.com/u/5426011/examples18/proj_path_no_phys.capx

    It has the math worked out so the initial launch angle points somewhere above the target and from that a speed is calculated so the target is reached. It's a sightly different approach than what I outlined before. The initial angle can be anywhere in the range of the angle to the target and straight up.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With just two points all you exactly have defined is a line. You'll need three points to define a curve.

    The standard formula for a parabola is the following:

    y=a*x^2+b*x+c

    Plugging in the x,y positions for the three points into the formula will give you three equations where the only unknowns are a,b and c. Then it's just a matter of using standard algebra to solve for the unknowns.

    If that doesn't help, do you have more info about what you're trying to do?

    In general the process is called curve fitting:

    http://en.wikipedia.org/wiki/Curve_fitting

  • For most pattern movement you can do an equation.

    Figure 8 for example:

    set x = radius*cos(speed*time)+center_x

    set y = radius/2*sin(2*speed*time)+center_y

    For multiple objects on the same path add a instance variable and call it offset and give it the value from 0-360.

    set x = radius*cos(speed*time+self.offset)+center_x

    set y = radius/2*sin(2*speed*time+self.offset)+center_y

    You can also replicate it with the two sine behaviors as well. One vertical and one horizontal. Just make the vertical period half the period of the horizontal. Most zig zag patterns can be done with one sine behavior and one bullet.