R0J0hound's Recent Forum Activity

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Yes, they’d probably be the same draw call. No idea the performance difference.

    I’d guess using one tilemap is optimal, but if it makes what you’re doing simpler with 5 then I’d say go for it.

  • Yes in c2, at least usually.

    They both have the same texture so they’d both be in the same batch I’d imagine. A batch is just a list of quads sent to the gpu in one go and told to draw.

  • Hello,

    I haven’t opened your project file but here are some thoughts:

    For the right click issue:

    I’d remove the wait actions. They just complicate when stuff runs.

    When you right click, the two right click events are run in order from the top down. So the first sets stuff up so the second can run. Maybe using one right click event and else in sub events would be a workable solution.

    On right click

    — slot empty ?

    —— place object in slot

    — else

    — — add one to item count in slot

    For your second issue it’s basically you want to pick two instances at the same time. There are two strategies for that.

    One is to pick them one at a time, save the info you want to some variables and then pick the other. IIDs are useful here sometimes. So that would look like:

    Variable firstObjColor=0

    Some event

    — pick a object

    —— set firstObjColor to object.color

    — pick a different object

    — object.color = firstObjColor

    —— console log: can craft

    Or if you want to use an iid to make picking the first object later easier:

    Variable firstObj=0

    Some event

    — pick first obj

    —— set firstObj to obj.iid

    — pick other object

    — obj.color = obj(firstObj).color

    —— log colors match

    Anyways the other way to handle picking two instances of the same object type is to make a family with just that type. So if the object is “sprite”, make a family, add sprite, and call it “otherSprite”

    Then you could do this:

    Sprite.x = 100

    OtherSprite.x=200

    — do something