R0J0hound's Recent Forum Activity

  • 1

    Performance is likely not an issue with this. C2 is already very fast at loading layouts, and loading would be the only thing affected. Size may be a bit smaller depending how you store it, but it will be pretty negligible especially with only 20 levels.

    2

    You could do that, or use one of the array editors on the forum to get a json string to load in an array... There's lots of ways to do it, and not really any best way.

    Your example isn't the best reason to make your own level format to load. Layouts with objects placed with a snap to grid is perfect for a thing like that. But then again how many blocks are you talking?

  • No use a loop. ex:

    +--------------------+
    |Start of layout     | set array size to (100,1,1)
    +--------------------+
       |array: for each x| set array at array.curX to array.curX
       +-----------------+[/code:rz3kjviz]
  • If that's giving you zeros then the array may still be all zeros. Did you fill numbers into the array? The other way you used just gives a random number so you could get repeated numbers.

  • kmsravindra

    Two ways I can think of would be either a math way or checking the pixel color.

    The math way would check the mouse position with all the elements such as lines and pick the closest one. You'll have to look up the math to find the distance from a point to a line. Other elements like arcs and curves would take some ingenuity.

    The color checking method would be done with another invisible canvas where everything is drawn the same except each line is a different color so you can just check the color to lookup what element it is. To make them easier to click you can make the lines thicker. Also the antianalyzing may cause issues with that method so you may need to do a pixel perfect version of each like the capx a page or so back.

  • kmsravindra

    You could draw an identical arc over it, only instead of black use white. A better way would be to keep a list of all the things drawn and then remove the arc from the list, clear the canvas and redraw everything from the list.

  • sqiddster

    It may be slower than iterative methods since calculating intersection points isn't too cheap. With many objects it would be a problem, so any techniques to cull objects you don't need to cast to should help. The main use I have for it is to find an exact point of collision, and also the angle of the edge hit (although that's not present in the capx).

  • Maybe use int() instead of round() in round(random(0,arrayFrame.width)).

    Using round() can cause frameArray to equal arrayFrame.width and trying to delete that index will have no effect.

  • If you want to go the racasting route, here's an example with a re-usable raycaster event group that I've been using. It only needs the Function object to copy over.

    https://www.dropbox.com/s/qfjyoluo4eo83 ... .capx?dl=0

    To use set the start and end points of the ray with "raycast.set ray".

    Then call "raycast.cast to" with the endpoints of every line segment you want to cast to.

    Then use the functions "raycast.get x", "raycast.get y" to get the collision point or the end of the ray line segment if no collision occurred.

  • you can use "time" which gives you seconds. On the plus side is it's a decimal number so you can get a time of 0.456 or something. To get milliseconds you can multiply it by 1000.

  • [quote:1nb3nvgu]Well that's too bad because it seems like the OnCollision Trigger "knows" there was a collision and must know where it is on the screen. Too bad it doesn't return or populate a system variable like: Sprite.OnActiveCollisionX and Sprite.OnActiveCollisionY

    It doesn't know where the collision occurred, it would have to be calculated in js in the same way as listed here.

    sqiddster

    A plugin could access the collision polygon. The physics, polygon and chipmunk already do internally. In just events you could place imagepoints in the places of the collision polygon points for a brute force way. Then you can do line intersections with:

    http://paulbourke.net/geometry/pointlineplane/

    I can find a capx where i've implemented it if needed. A plugin could be made to hide the complexity, but I don't enjoy the process of updating and fixing plugins currently.

  • Try Construct 3

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

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

    Yeah, it looks like it's from the previous position. You can try adding these two lines to line#6528 :

    binstA.updateC2(binstA.body);

    binstB.updateC2(binstB.body);

    That should update the c2 object from it's physics body. I haven't tested it, so I don't know if it has any other side effects, because usually it's only done at the end of the tick. Looking at the function it may but I don't have the time to really analyze and debug it.

  • The fact the laser is growing fast or that the objects are moving is not really a problem. The same idea can be used. If the laser at any point overlaps the object, then in with a loop make the laser a little shorter until it's not overlapping the object. At that point the end of the laser is the collision point.

    Another way would be to do a raycast with math, which basically amounts to calculating the intersection points of the laser line and the edges of the object and keeping the closest intersection.

    You could also utilize the chipmunk behavior as it has some stuff built-in to get the collision point. Vanilla C2 collision detection only finds if two objects intersect, at no point is a collision point calculated so you'll have to use one of the above approaches.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound