R0J0hound's Forum Posts

  • Testing more you'll need to add 0.5 if the origin is centered:

    (x-self.x)/self.width+0.5

    (y-self.y)/self.height+0.5

    If the origin is top left it would be 0,0

    Also here's an example if you want to work with rotation: dropbox.com/s/qpriwtyej3ngylb/layoutXYtoDistort.c3p

  • Here's a code based way to do the animation as well.

    dropbox.com/s/45sc1227zvak0vb/wormMove1.c3p

    dropbox.com/s/2ejripn5sja4rtj/wormMove2.c3p

  • Yea, It assumes the sprite angle is 0. If it's not zero we'd need to unrotate the xy first but that may be more trouble than it's worth.

  • Here's another example as well.

    dropbox.com/s/an2pbq49au6rkxd/thumb_sticks_2.capx

  • With absolute mode you can do this to distort to an xy position.

    (x-self.x)/self.width

    (y-self.y)/self.height

  • Is level=9 when the timer finishes?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Updated link to handle fullscreen scaling.

  • Ok, fiddled with it more and got it to work. The link is updated

    Found that fixed resolution canvas' scale the image when loading pixel data, so left it at automatic. Also changed the line detection to use a tolerance.

    Found that pasting repeatedly blurs the lines so I combined the pixel data directly with some javascript.

    The only issue now is that the delay from making the mask is noticeable.

  • In javascript if you can access the canvas element you can center it with some css:

    canvas.style.position="fixed";
    canvas.style.left = Math.max(0,(window.innerWidth -canvas.width )/2)+"px";
    canvas.style.top = Math.max(0,(window.innerHeight-canvas.height)/2)+"px";
  • Example is done:

    dropbox.com/s/339te0solmn4yws/marchingSquares.c3p

    Should work as long as the image isn't touching the edge of the canvas. I didn't add the polygon simplifying step. Also it just uses the first polygon it finds if there are multiple.

    For debugging the outline used is drawn onto the canvas, and the collision shape is visible.

    I haven't gotten to figuring out how to deal with how any fullscreen scaling changes the resolution of the canvas.

  • I guess it depends on how the sine behavior does the math internally.

    But instead of finding a way to look at the workings of the behavior, and maybe finding a correction you could just do the sine motion directly with math instead.

    It’s fairly simple to do it in a way that I’d frame rate independent. Here it does horizontal motion:

    X = startX + magnitude*sin(time*360/period + offset)

    I suspect the sine behavior moves objects in a more relative way since you can use it with other motions.

    This would do it in a relative way but still be frame rate independent.

    Previous = current
    t = t + 360/period* dt
    Current = mag*sin(t)
    X = x + current-previous

    As I said, the behavior must do something different.

  • Im not sure either. By default the resolution of the canvas will change when the view size changes, although there is a setting to make the canvas have a fixed resolution.

    When I tested it it didn’t seem to work either way. Mainly the fill seemed to pass the lines due to things being blurred a bit from resizing, so the lines were no longer fully black.

    My thought was to have the canvas use a fixed resolution and maybe at most have to adjust the mouse location, but trying it didn’t seem to work but I’m not sure.

  • Here's one way to do it. The 3d features in construct aren't always up to par but you can utilize some math to do it.

    dropbox.com/s/xre95xeumgsmw8l/orbit_camera.c3p

  • One promising approach is to use the marching squares algorithm on the image to get the edges. It would allow you to get a nice approximation without looking at all the pixels.

    You could get multiple polygons from that when multiple shapes are drawn or there are holes inside the shapes. Since you want only one shape you could calculate the area of each and keep the biggest, or maybe find the convex hull of all of them perhaps, but the former would be better. Handling holes could be possible too but that would need more work. Essentially we’d make a cut from the hole to the outside of the polygon.

    Next step could be to simplify the polygon a bit so there are less points. One simple way would be to look at every three points and remove the middle one if the angle between the three is a threshold from 180 degrees.

    The final step would be to use distort mesh to make the shape. Size would be count/2 x 2. And set each on the mesh in a clockwise way. I’ve done it for a convex shape but since we are just concerned with the collision shape it should work with any polygon, but it just won’t draw correctly.

    Seems like something I’d want to attempt sometime this week if I get time.

  • Sure, but I see construct getting in the way depending on the kind of game engine you’re making.