R0J0hound's Recent Forum Activity

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

    uc0661124de8e470254e767a8b97.dl.dropboxusercontent.com/cd/0/get/Ch8KHKH_XR4TRhRUsRLXq0x231NEStGlk25bd6CJ7Z73bC-I52yiV_9aygtUz1FoA8caTNhd-HteUP2Pr9yqx1ONTghal6WYRe6XGSJWBIxhDPQbxq9QMkxJYkUtl3Ro1Mc/file

    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.

  • 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

  • 20*log10(t)

    Where t is any number from 0 to 1 will do it.

  • Try Construct 3

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

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

    And yes, you can use that as the expression. There’s probably a low enough negative number you can use too if you like.

  • tunepunk

    I agree it would be more user friendly like that. It's just not a priority atm.

    Nepeo

    Glad you thought it interesting to port over.

    Jquery was just an easy way to get the js file loading with one line from the eventsheet in C2. So I kind of like it in that context. Project file loading works fine here, so I guess that's a C3 thing. I'm only concerned with web export though.

    It's probably the least hacky way to do 3d in C2 I've found so far. While it does use the same gl context to do the rendering, the only hacky thing is it takes over some object's drawgl as a entry point. Nothing really specific to Construct's renderer other than telling it to finish what it's doing with glw.endbatch(). The Fbo was only added to work around the gl context being created without a depth buffer.

    I don't mind brittle. Using js directly makes it very brittle with typos and stuff. Also the internal apis used are mostly documented in the sdk, but besides that it's not like C2's internals will change at this point, I'm not even using the latest release.

    All a plugin would add for me is making this work when using export with minifying. Otherwise it just makes developing more time consuming and tedious for me. Personal preference, really. I'm not really interested in making a plugin anyway. This is basically just me getting more fluent in webgl, and integrating it into C2 in some way.

  • You can get it to work with scrolling by setting the position relative to scrollx, scrolly

    So the monkey head could be 320-scrollx, 240-scrolly.

    Changing it to draw witching the object bounds per object is doable. Mostly shifting code around and adding more code to size it within those bounds. It kind of restricts what it can do. Less work to use, more work behind the scenes kind of thing. Probably something to try another day. I’m losing steam on changing how this one works for now.

    It’s at a point where it has sufficient flexibility I can try some other ideas out. Albeit by making things a bit more complex to use.

  • Yeah, it’s pretty much from scratch.

    The zorder used is from the sprite whose drawing function is hijacked. I think the js function that does the hijacking is called overrideObjectDrawgl or something. You just pass a uid and the name of a c2 function to be called when drawing. It can be thought of as a 3D layer in place of that sprite.

    You’d have to hijack another sprite to do a separate layer.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound