R0J0hound's Recent Forum Activity

  • Couldn’t you just compare the x position first?

    Player x < 800

    — set camera x to lerp( self.x, player.x, 0.01)

    Or I guess you could also add an else after that to lerp to the x boundary

    Else

    — set camera x to lerp(self.x, 800, 0.01)

    Or you could utilize the min() expression to keep it in the every tick. May not be as flexible later, and could be harder to read.

    Every tick

    — camera: set x to lerp(self.x, min(player.x, 800), 0.01)

    If you want a left boundary instead, use max() instead. If you have a left and right boundary, use clamp() instead:

    Lerp(self.x, clamp(player.x, 50, 800), 0.01)

  • This only considers three points. Doing multiple back to back are basically just independent.

    You’d probably want to do something like this to go through multiple points:

    stackoverflow.com/questions/1257168/how-do-i-create-a-bezier-curve-to-represent-a-smoothed-polyline

    Which is multiple cubic beziers placed one by one. It just sets the control points so the slope is the same from one to another. Another option are catmull-rom curves.

  • Here are some more tests.

    This one is is based on the idea you can make any triangle from two right triangles. The result is being able to draw any filled triangle with vanilla C2 without using js. It also includes my favorite new use of a modification of qarp() to make a curve through 3 points.

    dropbox.com/s/2t8s5qeaxb3txnj/triFill.capx

    This takes a polygon and triangulates it. Mostly alogrithmic stuff.

    dropbox.com/s/hs0e6xqioym6kkw/trianglate.capx

    Here are some things I've posted elsewhere that might be more useful to find here.

    Some custom webgl to draw 3d inside C2. Makes heavy use of js via the browser

    construct.net/en/forum/construct-3/how-do-i-8/how-do-i-get-this-example-to-w-140574

    Yet another 3d test. Event based this time.

    construct.net/en/forum/construct-3/how-do-i-8/how-do-i-make-ball-movement-li-140735

    Some tests of custom physics to do bubbles.

    construct.net/en/forum/construct-2/general-discussion-17/can-we-make-natural-effect-lik-139909

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Glad it's useful. Dividing by 9 makes the last sprite be created at the end. 10 stops shy, but that could be preferred if chaining multiple curves together. But you're right, that's probably a better default.

  • The compressor effect can be used to keep multiple sounds from getting loud. Works well in my tests. I just used the default values. Just throwing that out there as another idea.

  • Ah. I withdraw my idea about no layers. The canvas plugin is more restricted than I thought.

    I salute you for trying trial and error, I just did mine with some math. I googled “Bézier curve through three points”, or something like that and found a nice solution.

    Say your three control points are: x0,y0, x1,y1, x2,y2

    And you use qarp() to do the curve:

    Repeat 10 times

    — set t to loopindex/10

    — X = qarp(x0, x1, x2, t)

    — ... same for y...

    The curve won’t pass over x1 though. To correct it do this:

    X = qarp(x0, (4*x1-x0-x2)/2, x2, t)

    ... same for y ...

    Now the curve will hit all three.

  • You’re welcome. Glad it solved it.

  • Try adding a “for each stone” after the condition that checks the health.

    Without it if multiple stones have a health less than zero, only the first will be saved.

  • Look in the capx I posted. In the curve function there are 3 control points x0,y0, x1,y1, and x2,y2.

    The first action that sets them sets them from the function parameters. The second actions that set x1,y1 correct the math so that control point is on the curve.

    I haven’t tried the new canvas function, but you should be able to do multiple objects without layers. Just juggle the visibility of things when drawing to the canvas with a blend mode.

  • The curve can be done with qarp(). It's a quadratic bezier curve. A little extra math was used to make the middle control point on the curve.

    Then it's just a matter of making a curve per edge. I guess there's many ways to go about it. This example uses one.

    dropbox.com/s/9wwrln9f6tkxn0y/curve_box.capx

    Basically it's just creating a bunch of points along the curve, then used stretched sprites for lines. Anyways you probably could use the canvas to draw it filled. Just add the points to the polygon instead of creating sprites.

  • I got around some wifi, so here is a working example:

    dropbox.com/s/0cygc1w5noarffs/3dball.capx

    Something to play with at least.

  • Here are some notes on how I’d go about it, and most of the math worked out. Hopefully I’ve provided sufficient explanations.

    The 3D physics of the ball is probably the easiest. We already have xy and we can do z with a instance variable. Just add three other instance variables to keep track of velocities: vx,vy,vz. Also we can use a variable g for gravity.

    Then the motion can be done with:

    g=300

    Add g*dt to vz

    Set x to x+vx*dt

    Set y to y+vy*dt

    Set z to z+vz*dt

    The result is parabolic motion on the z axis. You can make it bounce off the ground with:

    Z>0

    — set z to -abs(z)

    You can control where the ball will land by setting the initial velocities.

    t = distance(x,y, goalx, goaly)/speed

    Vx = (goalx-x) /t

    Vy = (goaly-y) /t

    Vy = -g*t

    To see the z motion we need to rotate everything around in 3D somehow. You can do that on the same objects, but it’s probably simpler to just position new objects from the old ones. It turns out a 3D rotation is basically the same as a 2d one.

    Rotate on the YZ plane:

    a = the amount to rotate

    y, z = the point to rotate

    cy, cz = the center of rotation

    NewY = (y-cy)*cos(a)-(z-cz)*sin(a)+cy

    NewZ = (y-cy)*sin(a)+(z-cz)*cos(a)+cz

    We can then add perspective fairly easily. It’s basically just dividing x and y by z.

    Perspective:

    X,y,z = the position

    Cx, cy = the center of perspective

    Fov = field of vision. 300 is a decent default.

    Eye = camera distance from scene.

    NewX = (x-cx)*fov/(z+eye) +cx

    NewY = (y-cy)*fov/(z+eye) +cy

    Scale = 1*fov/(z+eye)

    Perspective is wonky when behind or too close. Increase eye till everything is in front.