R0J0hound's Recent Forum Activity

  • It was a specific shape. each action has an angle and distance to specify the lines that make up the shape. For example a triangle can be made up of three lines: red,blue and green.

    That said, it can be made generic but in c2 I can't access the collision polygon so I'd use imagepoints instead. As long as the points make up a convex shape and points are placed clockwise. Although the winding order can be worked around.

    edit:

    Here you go:

    dropbox.com/s/xp1tprnefmdwf0b/convex_clamping_generic_with_imagepoints.capx

    Just as long as it's a convex shape and the origin is within that shape. CW or CCW doesn't matter.

  • Cool. Glad it was useful.

  • So if I'm looking at that right looks like you have the origin of the wave at the front so you're doing something like this?:

    on wave collides with ship
    -- create explosion at (wave.x, wave.y)
    -- destroy wave

    The main idea i have is you can clamp the explosion position to the shape of the ship. This is simpler when the shape is simple.

    Since the ship isn't rotating is you can clamp the position that you create the wave to the bounding box of the ship. Anyways that works well for unrotated box shapes, so the ship from the right could still have floating hits.

    on wave collides with ship
    -- create explosion at (clamp(wave.x,ship.bboxleft,ship.bboxright), clamp(wave.y, ship.bboxtop, ship.bboxbottom))
    -- destroy wave

    If you want to clamp to a rotated box it would be this as long as the ship's origin is centered.

    on wave collides with ship
    -- create explosion at (wave.x-ship.x, wave.y-ship.y)
    -- set explosion position to (self.x*cos(ship.angle)+self.y*sin(ship.angle), self.x*cos(ship.angle+90)+self.y*sin(ship.angle+90)
    -- set explosion position to (clamp(self.x, -ship.width/2, ship.width/2), clamp(self.y, -ship.height/2, ship.height/2))
    -- set explosion position to (self.x*cos(ship.angle)+self.y*cos(ship.angle+90)+ship.x, self.x*sin(ship.angle)+self.y*sin(ship.angle+90)+ship.y)
    -- destroy wave

    Similarly you can clamp to a circle shape. Here a circle with radius 100.

    on wave collides with ship
    -- create explosion at (angle(ship.x,ship.y,wave.x,wave.y), min(100, distance(ship.x,ship.y,wave.x,wave.y)))
    -- set explosion position to ( ship.x+self.y*cos(self.x), ship.y+self.y*sin(self.x))
    -- destroy wave

    Or even any convex shape. Although that can take more thought. Here is a triangle.

    on wave collides with ship
    -- create explosion at (wave.x, wave.y)
    -- explosion: move -max(0, (self.x-ship.x)*cos(180)+(self.y-ship.y)*sin(180)-50) pixels at angle: 180
    -- explosion: move -max(0, (self.x-ship.x)*cos(-60)+(self.y-ship.y)*sin(-60)-50) pixels at angle: -60
    -- explosion: move -max(0, (self.x-ship.x)*cos(60)+(self.y-ship.y)*sin(60)-50) pixels at angle: 60
    -- destroy wave

    And here's another way to do the rotated rectangle:

    on wave collides with ship
    -- create explosion at (wave.x, wave.y)
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle)+(self.y-ship.y)*sin(ship.angle)-ship.width/2) pixels at angle: ship.angle
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle+90)+(self.y-ship.y)*sin(ship.angle+90)-ship.height/2) pixels at angle: ship.angle+90
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle+180)+(self.y-ship.y)*sin(ship.angle+180)-ship.width/2) pixels at angle: ship.angle+180
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle-90)+(self.y-ship.y)*sin(ship.angle-90)-ship.height/2) pixels at angle: ship.angle-90
    -- destroy wave

    Sometimes you can have complex shapes be made up of multiple simpler ones. It just depends on what you're after.

    Anyways, just an idea.

    Edit:

    here's an example:

    dropbox.com/s/xcg99crdntoa3lf/convex_clamping.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I never use waits when I can.

    On function getXY
    While
    — set myX to int(random(300))
    — set myY to int(random(400))
    — array: at (myX,myY) =0
    — — stop loop

    The only issue is it will loop forever if there are no 0s in the array. It also could take a while if there only a few 0s. Depending on how robust you want it you could have it try random places first, then make a list of all the locations with zero and pick one at random, and lastly if there are no zeros you could set the variables to -1 or nan or something.

  • You can use cosp inside anglelerp:

    angleLerp(a0, a1, cosp(0,1,t))

  • Sounds good. Most tutorials and examples of gltf use webgl or OpenGL which is ideal for how the data is laid out.

    Gltf also only has lists of triangles but I think you could combine pairs of triangles that share an edge into quads when you first load things.

    I hadn’t planned on doing any more with this very soon. My free time and how I spend it changes a lot day to day. But I’ll likely reference it for later stuff.

  • So I had a more serious look at the gltf file format and partially made a loader for it.

    It requires gltf embedded files. My goal was to only get the transformed vertices from skinning and the scene graph, and play back animations. The meat of it is in js and isn't tied to webgl at all.

    I was originally visualizing it with sprites, but it was too slow so I made a setting to use c2's render directly to draw points.

    dropbox.com/s/sd48sbafaxbg0tf/js_gltf_test.capx

  • Construct seems to do funky sorting when objects have the same zelevation.

  • I probably won't make a game with this.

    Anyways, here's the balls rolling on a 3d terrain (they can't get airborne).

    Also, figured out a way to do per vertex shading. Just with a direct light currently (point lights would be tricky*).

    dropbox.com/s/rkomtba52rlqw3t/mesh_sphere_roll_terrain.c3p

    There are a few annoyances I've found with 3d.

    *The main one is distort meshes have their own coordinate system which is different than the layout's coordinate system. Overall that makes everything more fiddly.

    When objects have the same zelevation they seem to lose depth? not sure.

  • Another test. It does 3d rotation in a more generic way. Also tried out doing some rolling physics.

    dropbox.com/s/2l2dtel4t0zf9jw/mesh_sphere_roll.c3p

  • Ok, here is an updated version. You can have functions use as many parameters as you need.

    dropbox.com/s/0bwec4ef6j54w8f/expression%20parser%201.capx

  • Hi,

    I haven’t had a chance to mess with it this week. Right now it was setup for handling a max of two parameters. With more the extra values are discarded atm.

    Anyways, it’s something that can be fixed. I’ll look it over this weekend.