R0J0hound's Recent Forum Activity

  • Here's the wip of the triangulation. It works with the the polygon defined by sprite instances in a CW order.

    Using a mesh to display the triangles didn't quite pan out because it gives thin transparent slivers due to math rounding. So it also lets you draw the triangles with the canvas as well since it doesn't have the slivers. It doesn't look worthwhile to extend it to generate convex polygons or triangle strips at this point. It will need reworking if you want to define the polygon in another way other than sprite instances. Doesn't work with self intersecting or CCW polygons, but the CCW case can be solved by detecting the order and reversing the list.

    dropbox.com/scl/fi/png6jg6a1qresctjq5ra6/triangulate_ear_clip_mesh_wip.c3p

    Alternately, if you want to use js for this you could look into this one:

    github.com/mapbox/earcut

    Or you could take the triangulation function out the old c2 chipmunk plugin. That one generates convex polygons.

    Edit:

    Just noticed that points ordered in CCW order could be used for a convex hull.

  • If the orbit is controlled by physics then to make it be able to orbit slower you need to reduce the gravity force. Or maybe just don’t give physics to the moon and move it with the orbit behavior instead.

  • The 14.2 mb is the compressed png size. That should remain the same which means faster downloads. When the game runs, the images need to be decompressed to use.

    45*650*540*4 =~ 63.2 mb

    Depending on the hardware texture sizes are only power of two so 650x540 may have to take up 1024x1024 which would give:

    ~188.7 mb

    Also keep in mind there will be other memory usage needed for the renderer in general. I think Ashley made a blog about it.

  • Self.x+dist*cos(ang)

    Self.y+dist*sin(ang)

  • A few ideas:

    Since you’re hitting the limit of the algo that the canvas object uses to convert a concave polygon to multiple convex ones, you could feed your polygon to another js library to do that and just draw the list of convex polygons it generates.

    Also as a tangent you could use a mesh distort to render convex polygons.

    For example for a 100 point polygon you’d do it roughly by:

    Set mesh size to (50x2)
    Repeat 50 times
    — set mesh at (loopindex,0) to point(loopindex).xy
    — set mesh at (50-loopindex-1,1) to point(50+loopindex).xy

    And actually you aren’t limited to just convex polygons. In general you can do any triangle strip in this way which includes some concave polygons. Also if you adjust the uvs you can get a textured polygon without using blend modes, but I guess that’s unrelated to what you’re doing.

    Anyways, the idea to explore is convert any polygon to multiple triangle strips and use mesh distorts to display them. To do that you’d slightly modify a triangulation algorithm like “Ear clipping”, which basically adds triangles at convex points if no other points are inside that triangle. To make it generate triangle strips instead of just triangles you’d zig zag moving cw then ccw on the plolygon when adding triangles.

    Alternatively you could triangulate, then merge triangles sharing edges if the result is still convex.

    I’ll be attempting to make an example of the idea when I get time.

  • Almost there. You need to click on one of the sub forums first.

  • That’s all I have at the moment.

    The array is a history of the positions of the head which basically can be thought of as a polyline. You can move along the polyline by a specific distance. A simple starting point would be to move a distance along a single line segments. Anyways, many path following examples do that.

    Another idea is to just move each section toward the section ahead of it till they overlap.

    Just some ideas. I won’t be making any examples any time soon.

  • You could change it to only add points to the array if the head is moving instead of every tick. Basically:

    Compare: distance(head.x,head.y,array.at(0,0), array.at(0,1)) > 0

    That would keep it from stacking on top of itself if it stopped. Possibly good enough.

  • You could also have the function return nothing and set some global variables instead that you’d use after calling the function. For example:

    Global number retx=0
    Global number rety=0
    
    Function rotate90(x,y)
    — set retx to -y
    — set rety to x
    
    Every 1 seconds
    — function: rotate90(sprite.platform.vectorX, sprite.platform.vectorY)
    — sprite: platform: set vectorX to retx
    — sprite: platform: set vectorY to rety

    You can do that with anything. Instead of returning a value you just save the result somewhere. Or if you want it to be more dynamic you could say, create an array, fill it with values and return the uid of the array. There are tradeoffs for readability and ease to use though.

  • Hi,

    No need to ever tag me. I don’t look at alerts and I skim over all the new posts when I visit the forum.

    I’m guessing you’re trying to do it by moving the head and having it leave a trail that everything else follows. One way to do it is add the head’s position to the front of an array, and just always position the body parts from an offset in the array. Finally you’d want a way to remove stuff off the back of the array when it gets too big.

    The main complexity here is the offset calculation. A simpler formula could be (self.iid+1)*30 to just have each part be 30 frames (or 0.5 seconds at 60fps) behind the part before it.

    (self.iid+1) gives 1,2,3,…etc
    (self.iid+1)*32 gives a distance of every 32 pixels: 32,64,…etc
    (self.iid+1)*32/100 if the head always has a speed of 100 this converts the distances to times
    (self.iid+1)*32/100*60 Finally this converts the times to frames. 

    So events would look like this

    Start of layout
    — array: set size to (0,2,1)
    — body: set offset to (self.iid+1)*32/100*60
    
    Every tick
    — array: push front head.x
    — array: set at (0,1) to head.y
    — body: set x to array.at(self.offset,0)
    — body: set y to array.at(self.offset,1)
    
    Array.width>6000
    — array: pop back

    You’d just move the head however you like. And at 60fps and the head moving at 100 pixels per second the body parts would be connected. There are likely many improvements to this idea but that’s the simple gist.

  • Without a layer you could draw them to a drawing canvas at 100 opacity and then make the canvas have opacity.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Probably add a “for each mover” condition to the top of that event.