R0J0hound's Forum Posts

  • 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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Sounds like it’s completely broken if it does that. I don’t have a fix.

    You could try the polygon plugin made by yann as an alternative.

  • It doesn’t use any 3D library. I just use webgl directly.

    Why? Because it seemed interesting.

    It’s different from triangle3d because I ended up changing how it worked significantly.

    I haven’t used the others plugins.

    Edit:

    It’s a single object because I didn’t want to deal with picking.

    It doesn’t use an existing library because I couldn’t get them to work the way I wanted to and they are too bloated for my use case. This plugin is able to be drawn between other normal construct objects without an image copy per frame. Other plugins run on a separate canvas that’s copied every frame or layered over the game canvas.

  • Hi.

    1. There is per object color, and the color has alpha. Is that what you’re after? When an object is transparent you need to turn on “transparent” in the object settings so it draws things in order.

    2.

    I’m not sure what you mean by transition modes. Can you clarify?

    3.

    I can see that being useful. Right now we use only a diffuse texture and color which is pretty simple. I’d like to make the shading model more deluxe when I work on that.

    4.

    Yeah, even in my tests the directional light isn’t enough.

    Adding more lights and light types is something I’m interested in attempting.

    5.

    I won’t be making that a live link at this time. Using the sprite condition “on frame changed” is a decent solution at the moment.

    Thanks for your interest.

  • It’s been a while, and I don’t have the plugin installed but as I recall you’d do these actions:

    Begin path

    Move to 0,0

    Line to 100, 100

    Line to 0, 100

    Fill path with “red”

    Stroke path with “back”

    Or something like that.