R0J0hound's Forum Posts

  • I think what was mentioned was modular events. They had feature poll back in the day mentioning it, and more recently there was a blog post mentioning is as an idea. Using that to make plugins was also thrown around. I don’t think any of this is fleshed out though.

    Most plugins that interface with some third party JavaScript library would probably not benefit from it.

    You can already do somewhat modular events now but it’s very tied in to the project usually.

    If it ever becomes a thing I think it won’t be soon.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It’s only 4 ifs. You could get or make a plugin that runs some text as an expression, but that’s probably overkill. You could use the conditional expression to pack the ifs together to do everything in one event.

    Global number a=0

    Global text op=""

    Global number b=0

    Global number result=0

    Every 1 seconds

    — set a to int(random(100))

    — set op to mid("+-*/", int(random(4)), 1)

    — set b to int(random(100))

    — set result to 0

    — set result to (op="+")?a+b:result

    — set result to (op="-")?a-b:result

    — set result to (op="*")?a*b:result

    — set result to (op="/")?a/b:result

    — set text to a&op&b&"="&result

  • Offhand you can do the math directly to map x from a,b to c,d.

    X = c+(d-c)*(X-a)/(b-a)

    Or if you want to use some built in expressions you could do this.

    X = lerp(c, d, unlerp(a, b, x))

  • That looks cool and all but it’s not something I’ve wanted to do.

    The only optimization i do is simplifying and organizing events to be straightforward and easy to use as possible. Speed rarely is a concern to me. I’d rather things work right than have it work fast.

  • As far as I understand it, effects are handled basically the same way in c2 and c3. The only additional effect parameters you can add are numbers. You can’t pass additional textures to construct effects at this time.

    However it is possible to do it from a plugin’s drawgl function. Tell construct’s renderer to finish drawing, and then do any custom webgl you like. The pro of this is you can do anything. The cons are you have to deal with a fair amount of webgl and you’ll have to change the webgl state back when you’re done. The closest example I have is here, but it touches on more things than you’ll need.

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

    It’s fairly low level but could be a useful starting point.

    Either way your effect is pretty cool.

  • I’d just use whatever is simplest and easiest to use for your game. I don’t know what the performance differences may be, but they are likely negligible. With card games most things are done with input or after a timer. These are one off things that even if done slow will have no impact whatsoever with FPS or cpu usage. At least nothing you’d notice.

    If you get pauses you can deal with that later.

  • Well, using the math in that link here is a curve through many points. It's basically a cubic bezier between each.

    dropbox.com/s/1fjnow11g4zn04b/curve_polyline.capx

    That's kind of stuck as one curve, so here's a tweak to make it work for multiple. Event's 9-12 need to be spaced out like that. After creating objects you need to wait till the next toplevel event to allow them to be pickable.

    dropbox.com/s/q7cd4whip7fsguq/curve_polyline_multi.capx

    To move along these curves you'd either have to save the cubic() parameters or just lerp along the generated points. A plus about the latter is you can make the speed constant.

    Here's a dump of other examples that either draw curves, and/or do motion along a curve.

    construct.net/en/forum/construct-2/general-discussion-17/follow-path-behavior-42924

    construct.net/en/forum/construct-2/how-do-i-18/smooth-movement-following-path-109114

    construct.net/en/forum/construct-2/how-do-i-18/an-extreme-slide-type-of-move-96270

  • 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

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