R0J0hound's Forum Posts

  • Just loop over the array and if the current value is dirt, the value above is empty do whatever.

    The actual event to do this is like this here:

    For each xy

    Array at (curx, cury) = 1

    Array at (curx, cury-1) = 0

    --- do something

    At least that's the simple case of air to dirt.

  • It has to do when a newly created object is pickable. You can find details about this with a search about toplevel events.

    This link has info about that:

  • I think after an overlap condition like that you use pick nth instance to pick one or the other. An instance won't overlap itself, you can test this by setting it's opacity to 50 or something to visualize it.

    Another approach I've used is to have a seperate detector object, which you can set to the position of one object and then detect the other ones.

    For comparing angles and such you can pick one instance, save it's iid to a variable then pick all and do the comparison from there.

    Or you can just follow a pattern like this:

    +---------------------------------------------------------------------+
    | for "a" from 0 to sprite.count-1                                    |
    | for "b" from loopindex+1 to sprite.count-1                          |
    | compare sprite(loopindex("a")).angle = sprite(loopindex("b")).angle |
    +---------------------------------------------------------------------+
       +------------------------------------------------------------------+
       | pick sprite instance loopindex("a")                              |
       +------------------------------------------------------------------+
       +------------------------------------------------------------------+
       | pick sprite instance loopindex("b")                              |
       +------------------------------------------------------------------+[/code:x9i4nh5x]Or some simplification to that effect.
    
    There are other ways too, and basically it involves picking one, and saving values to variables then picking the other.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The simplest way would be to use the physics behavior and just move the player instead of the terrain. Or you could use the chipmunk physics plugin instead since it works fine if you move an object. The normal physics behavior throws the object when you move it which is why you can't use it to begin with I guess?

  • bloodshot

    You can search my posts and I have made several different examples of doing physics with events. None are comprehensive, instead they focus on doing certain things.

    In the example you're giving it's probably easier to use the physics behavior instead somehow. Unless you have a convincing reason not to.

    But hey, if you really want to you can do it yourself and the rules above would work somewhat. It becomes a little more involved since the football rotates. As part of resolving the collision you'll want the point and normal of collision (you can have multiple points with complex terrain). The next but gets slightly more involved. Basically you apply an impulse at that point onto the ball which will result in linear and rotational motion. You'll also want to consider motion perpendicular to the contact normal and apply a friction impulse. There's guides elsewhere online that have the formulas you'll need.

  • How would you do it if you did it on paper? Can you write out the steps you would take and what rules you want?

    Do that and you're most of the way there, and we can give suggestions about what features and events could be used to do each step.

  • Basically any trigger except "on collision" (which is run in place) can be run inspite of its location on the event sheet. Simple things like "on start of layout" and "on function" are example where you wouldn't want it to run when the event sheet gets to them. Another reason is if the condition is triggered multiple times. With mouse button is down that event would run only once per frame, wereas on click would run for every click. Now for the mouse this won't really happen since you can't click multiple times in 1/60th of a second. It is possible with something like on any key pressed.

  • In the general case you can set it up like this:

    Global number t=0
    Global number tt=0
    
    Every tick
    --- set t to (t+dt)%2
    
    t<1
    --- set tt to cubic(0,0.5,0.5,1,t)
    
    t>=1
    --- set tt to cubic(1,0.5,0.5,0,t-1)
    
    Every tick
    --- set X to lerp(A, B, tt)[/code:1i6tummh]
    t goes from 0 to 2 every two seconds. You can adjust it so it goes at a different speed, or just make it stop at the end. 
    
    tt maps t to a curve. There are actually two curve parts. Going toward the target and coming back. The cubic expressions is where you define the shape. Change only the two 0.5 parameters. So for example an ease in/out could look like this:
    Set tt to cubic(0, 0, 1, 1, t)
  • It's just a behavior. It's not affected by that setting.

  • The trigger "on click" is run when the mouse clicks, it's not run top down.

  • I haven't used effects in a while but here's a writeup about all the variables C2 provides:

    Tiledbg uses the plugin setting pf_predraw flag which seems to affect the drawing of effects. I haven't figured out how but the relevant part of the runtime is the renderEffectChain function in layout.js. This is probably where the choice between screen space and object space is used.

    Is there an easier way of getting absolute screen-space pixel coordinates?

    That way should be right based on what I found for that guide.

    If void main is called for every pixel, is it unnecessary to put certain calculations in there?

    The only way for it to calculate it once would be to calculate it before hand and put it in as an effect parameter as far as i know.

    Why isn't alpha reserved when I only adjust the rgb?

    It has to do with pre-multiplied alpha.

    I'm not sure about the other issues. There's a lot going on in the renderEffectChain function in layout.js, and it probably explains when object space is used and when screen space is used, but in the interst of time it's probably a good question for ASHLEY.

  • Actually both canvas2d and webgl have their quirks.

    With canvas2d the tiledbg is a rectangle with an image pattern fill. Sprites are drawn with the drawimage function, which doesn't have repeat, and is faster than a pattern fill. But yeah, a repeat property could be used to easily switch between the two rendering methods.

    With webgl the tiledbaground image needs to be power of two to be able to repeat. The runtime does the resizing for you when the object type is first created, and this may also be why things are different with effects. Other than the size issue, the difference between sprite and tiledbackground is mainly just a webgl texture setting as I recall. Webgl2 allows for non-power of two texture repeating but it's a long way off. Another possibility would be to write a shader to do the repeating but this wouldn't be as fast.

  • I don't know how a wait command can be used. Another idea occurred to me, just make a repeat loop to eat up time.

    global number time_eater=0

    system: compare fps>15

    --- add 10000 to time_eater

    else

    --- subtract 10000 from time_eater

    repeat time_eater times

    ---

  • You may have more luck with using the chipmunk physics behavior instead. It provides more control over adding joints. The built in physics behavior only attaches joints to the origin or image points of objects.

    So as I understand it, the basic Idea would be:

    1. give the physics (or chipmunk) behavior to all the bones, and have it disabled at the start.

    2. when you want to ragdoll, enable the physics and add joints between the bones at the pivot points (like the knee for example).

    Adding the joints is the only tedious part. Here's the capx you posted with the chipmunk behavior used. Press space to ragdoll (or mostly just scuttle) the player. I quickly added imagepoints on the objects to define where the joint should be, and attached the head all the way to one foot. It's not perfect, but this was mainly just for a proof of concept so I didn't fine tune it. However if you put the time in you can get it fully working.

    https://dl.dropboxusercontent.com/u/542 ... uttle.capx

  • There are two parts to that, visual and collisions.

    For the visual you can either pre-draw the terrain or use the paster object to draw a bunch of quads to distort an image. Here's an example that distorts a image, so maybe it could be useful. The math may not be useful in your case but the gist of it is just have a bunch of quads next to each other with the corners moved to distort things. If you've done uv texturing in 3d software, the idea can be used here and the more quads you use the smoother it will be.

    viewtopic.php?f=183&t=166708&p=1006165&hilit=trail#p1006165

    The collision portion is the next problem. Here's one that takes a vector image export and creates a bunch of lines to use as the terrain. Another option is to use the points of the quads from the visual portion and use them instead to place the collision lines.

    viewtopic.php?f=147&t=167397&p=1008607&hilit=curve#p1008607

    On a side note the ground tile can be added by using a blend mode.

    Here's a more specific example:

    /examples32/hillclimb.capx

    https://www.dropbox.com/s/mzfhqnp4u4isy ... .capx?dl=1

    It creates the hills using sprites used as lines. I wasn't super creative so I made the shape of the hills the combination of two sine waves. Look at the set y action in event 2.

    It also fills in the area below those sprites so it's a filled area. The tiled background is then pasted with the source in blend to texture that area.

    The final step is to loop over the line sprites again draw a textured quad on the surface for each one.

    It works, and shows a simple case, but it would need more work to do scrolling and such.