R0J0hound's Recent Forum Activity

  • The chipmunk physics behavior has a way to get the point of collision, but other than that you'll have to calculate it yourself for anything else.

    For one idea you could look here:

    That capx has a way to calculate a normal. If you create an object at the ball, and then move it by the radius in direction of the normal with the "move at angle" action, then you should get a point of collision.

    I'd make a capx but my pc seems to be dying bit by bit and C2 has been the latest victim. I'll see if a reboot helps.

    For the absolute most precise way you could use the SAT (separating axis theorem) on the ball and wall. That's usually used for resolving a collision, but it can also give you the point of collision. I've made some capx's of it elsewhere on the forum.

    Or you can do the math directly. Find the formula for the distance between a point and a line and use it to find the distances to the four lines of the box, only check that the point if projected on it land within the segment, then find the distances from the four corners. The closest of any of those will be the one you use to get the normal and collision point.

    I've done both before, and they work well although can be a bit complex to setup. An approximation is usually good enough as with the first idea.

  • irina

    I'd just paste that paster onto a smaller paster object in the area you want to save and then use the .imageUrl of that to save with the browser object. Keep in mind it only saves as png, not jpg.

    sir LoLz

    You could use Paster.ImageUrl to access the image so you could load it.

  • Well... hmm, you could just create the highlighted squares around the center one with a bunch of create actions. But I consider that a brute force way and I'm very lazy when it comes to repetitive stuff like that.

    On a side note you certainly can control objects you created with events. There just are a few picking things you need to consider.

    For instance:

  • Well you could just make the shapes be sprites with the drag and drop behavior. The connections and verifying the correct position would be a lot trickier, but as always any problem can be solved by breaking the problem down into simpler sub problems.

    The most I've done is some node based stuff here:

    Similar perhaps, so it could help with ideas.

    D3.js is cool and all but it's something on it's own which isn't really combinable with C2. I mean you could but it would be simpler to just use it.

  • Try Construct 3

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

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

    You can't do it with just one formula, you need a variable that you change over time to do it.

    One you could use is speed. It starts as 0 and it increases over time so you get an easing in effect.

    Add 100*dt to speed

    rotate self.speed*dt degrees toward target_angle

    In the actions above the 100 is the acceleration.

    You can also make an easing out effect with it by giving speed an initial speed and using negative acceleration to slow it down.

    Set speed to max(self.speed-100*dt, 0)

    rotate self.speed*dt degrees toward target_angle

    The max() is used above so the speed never becomes negative. The one problem is you need to handle is if the start speed is too low the sprite will stop short. To fix that we can calculate what the speed should start at with:

    speed= sqrt(anglediff(self.angle, target_angle)*2*100)

    Or instead of 100 use whatever you're using as an acceleration.

    Next to do an easing in-out effect (which is basically what the first capx I posted) you can accelerate or deccelerate depending on the stopping distance which can be calculated with:

    dist = (speed^2)/(2*acceleration)

    So then it can be reduced to two actions as follows:

    global number acceleration=100

    global number target_angle =270

    every tick:

    --- set speed to max(0,(((self.speed^2)/(2*acceleration)<anglediff(self.angle, target_angle))?acceleration:-)acceleration)

    --- rotate self.speed*dt degrees toward target_angle

    You may also want to reset the speed to 0 when the target is reached.

    Here's a capx:

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

    It differs from the first capx in that it doesn't try to be physically accurate.

  • Juicy

    It sorts the order the sprites are drawn so the ones higher on the screen are behind the ones lower.

  • irina

    First you need to load that js library. You can do that by running this js at the start of the layout:

    "var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://antimatter15.com/ocrad.js/ocrad.js';
    script.onreadystatechange = script.onload = function(){console.log('occad.js loaded');};
    head.appendChild(script);"[/code:2pnob2x6]
    
    It can take time to load, so you shouldn't try using it right away.  You can tweak it so you're signaled when it's done loading but it makes things more complicated, so for now you can wait a second or so before trying to use it.
    
    The one function used in that link is OCRAD(c), where "c" is an html5 canvas.  The only readily available one would be the game canvas which can be gotten with document.getElementById('c2canvas').
    
    In my test I did this to get the result:
    
    time=1 seconds:
    --- set text to Browser.ExecJS("OCRAD(document.getElementById('c2canvas'))")
  • dahu

    One way is to paste an object that is using the destination out blend

  • You could just store the uid of one array in another. Then you'd pick the other array by uid before using it.

    Or taking the idea further you could use iid's instead. Which would still require you to pick the array before setting values, but you could then get values with:

    Array2(Array1.at(1,4,5)).at(4,6)

  • I made this a while ago:

    I'm unsure if it would be helpful, it comes across as fairly complicated.

    Basically what you could do first is place all your tiles down as sprites. Next put the tile sprite in a family and give them a boolean variable called "selected". The reason for a family is so two separate instances can be referenced.

    You then can expand the selection one unit in all directions with:

    Family1: boolean "selected" is true

    Sprite: is overlapping family1

    --- sprite: set selected to true

    Throw a repeat above that if you want it done multiple times:

    repeat 2 times

    Family1: boolean "selected" is true

    Sprite: is overlapping family1

    --- sprite: set selected to true

    The only issue now is diagonal tiles are also selected. To fix that make the tile's collision polygon with beveled corners or more octagon shaped.

  • ethanpil

    It already has this feature: Canvas.imageUrl which is the entire canvas. To paste a smaller area, first paste it to a smaller canvas object and save that.