R0J0hound's Forum Posts

  • The new vanishing point feature can’t do that. It’s useful for some stylized effects or say you have a toolbar on the left half of your screen you can make the vanishing point centered on the right side area.

    To rotate the camera a bit like in that video you need to use a third party plugin. That guy actually used a camera plugin made by a user named mikal to do that.

  • Hi,

    Thanks for all the interest, and I’m glad it’s been useful. I ended up having to sideline further development for a bit. Life and stuff. Hope to get back to this eventually. Hopefully sooner than later.

    As to the requests:

    - Changing the texture filtering should be doable.

    - utilizing a sprites texture should be doable as well. Just have to take into account sprite sheeting.

    - I don’t have any immediate plans to allow adding/removing/modifying triangles from a mesh. Adding/modifying is a maybe. As is, I’d go with redoing the mesh from scratch per frame. I’m shooting with simple, easy to use and flexible. But I may change my mind after playing around with it.

    - I kind of like how the triangles are two sided, I can see how having single sided stuff allows for a texture on each side would be useful. May test later.

    - It would be nice to have some kind of animation like mesh deforms and skeleton skinning, but that would be a later feature as I’m not familiar with much of the various aspects of it. Currently, you can do stop motion style stuff with multiple object files. You’re only limited by memory there. Most any file format should be readable with varying degrees of difficulty. It’s the handling of that data that’s the most time consuming I think.

    - I have some ideas for collision detection and response. Ray casts would be nice too, but we’ll see how things go.

    My current tentative overall design would be:

    - Use tags for meshes, textures, and objects.

    - objects would be instead of the draw matrix. Instead you could specify as many objects as you liked. Each would have their own position, size, orientation and color. The you could change the mesh, and texture on the fly. While at it I’d like to make parenting too.

    The camera would treated as one of these objects so that would remove some redundancy.

    3D math within the event system gets busy looking fast so I’d like to add some more transformation features to simplify that. For example, rotate around an arbitrary axis, or moving at a 3D direction. We’ll see though.

    - rendering at least shadows from one light source would be cool too. It’s the type of thing that may be trickier than it seems. But as with everything else we shall see.

    Anyways. That’s the rough plan more or less.

  • Hi,

    I’m not updating this plugin anymore. It’s strictly C2 but the built in C3 canvas plugin may be useful.

  • I think this line idea would work as long as the base of the wall is some kind of convex polygon. Bear in mind it’s counting on all the walls being sorted correctly as the only things that will be changing zorder are the moving objects represented by points.

    “Z order sort” is more for sorting everting. Let’s call it an absolute sort.

    Here we are doing a relative sort.

  • So if everything is on the ground plane, and you make your level with all the blocks visually sorted. All that’s left is to move the player as he moves around.

    If each block has two imagepoints like in this image we can sort the player. Basically if they are below the line they are in front otherwise they are behind.

    The event would look like this:

     glabal number x0=0
    global number y0=0
    global number x1=0
    global number y1=0
    
    player overlaps block
    for each block
    -- set x0 to block.imagepointx(1)
    -- set y0 to block.imagepointy(1)
    -- set x1 to block.imagepointx(2)
    -- set y1 to block.imagepointy(2)
    -- compare: player.y<(y1-y0)/(x1-x0)*(player.x-x0)+y0
    -- -- player: move behind block
    -- else
    -- -- player: move in front of block

    Sorting Player vs enemy, npc or other simple objects would be simpler. You’d just compare the y positions.

  • Best I’ve found is mostly covered here:

    bannalia.blogspot.com/2008/02/filmation-math.html

    The building blocks of that is to compare two objects to see which should be in front. Them you’d sort all the objects with something called a topological sort. You only need to sort the objects visually overlapping each other.

    As seen on that page there are some cases where the the sort will fail, so in those cases it would be good to be able to split the objects.

    That said, depending on your levels, you can design around that to avoid the failing cases.

    If everything is on the ground plane I think it should be possible to do something similar.

  • This may be a useful reference.

    betterprogramming.pub/making-a-verlet-physics-engine-in-javascript-1dff066d7bc5

    Notable difference to what you’re doing is when limiting the distance between nodes it takes the mass of each node into consideration.

    Another thought is to take mass into consideration when applying damping. Something like this:

    (X-px)- (1-damping)*(x-px)/mass

    For the gravity it looks like what you have is in line with verlet physics. You probably just need to use smaller gravity values.

    For collisions it would be a matter of pushing the nodes out of shapes in the closest direction. For circles it’s basically the same as what limits the distance between nodes. For a box it’s a bit more involved.

    You asked how to make it change length. Probably by changing the rest length. Adding/removing nodes on the fly seems like an interesting idea too but may take a bit more logic.

    As to make it more stable, you need more iterations. It’s trying to solve the limits one at a time so only the last one is perfect. Each iteration brings everything closer. Also the longer the chain is you’ll need more iterations.

    So you could limit the speeds of the player and enemy. Or if higher speeds are needed you could move over several smaller steps in a loop with that iteration loop to solve the limits.

  • Since you said you’re plotting it you can just use a sin() equation:

    Value = amplitude*sin(frequency*t+phase)

    As a simple example say you want to plot a sine wave you can do that with a loop:

    Start of layout

    Repeat 640 times

    — create sprite at (loopindex, 240+100*sin(10*loopindex))

    Or if you wanted to plot a portion of it each frame you could do:

    variable x =0

    variable prevtime=0

    Repeat (time-prevtime)*60 times

    — add 1/60 to prevtime

    — add 0.1 to x

    — create sprite at (x, 240+sin(10*x))

  • If only two instances were colliding then an overlap condition would work. You’d get either instance with pick nth instance with 0 or 1. That won’t work if more overlap since we want to loop over all the colliding pairs.

    Roughly to loop over the pairs you’d do this:

    var i=0
    var j=0
    For “i” from 0 to family.count-2
    For “j” from i+1to family.count-1
    — set i to loopindex("i")
    — set j to loopindex("j")
    — compare abs(family(i).x-family(j).x)<32
    — — do something

    The collision expression is basic here. It don’t have a better one off the top of my head atm. But the idea is you use an expression to see if the two objects collide instead of the overlap condition. Then to modify the instances you pick the nth instance using i and j.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are a few ways to do it a bit different with some trade offs.

    I tend to use one object with one family containing that object. The advantage is you can access instance variables from both. The con is you have only one object type but I find it fine. You can use different animation frames.

    Another option is multiple object types and one family. We can then utilize iids to reference two different instances at once. Then to modify them you can use pick nth instance. The con is you couldn’t use the overlapping events, so you’d have to roll your own which isn’t too terrible for circles and boxes. Although the loop is a bit more nuanced.

    One nuisance of using two families is having instance variables shared between the two. I guess the custom movement behavior is one way around that, but I’ve found that behavior not very useful since applying velocity is fairly simple to apply velocity to make movement.

    But if staying with two families you could have each family have similarly named instance variables and copy between the two. Or maybe use a function to access them instead.

    As is, you can remove the for each in the bottom two events and it’ll still work, since the actions only reference themselves.

  • What kind of shape did you have in mind?

    Squares, circles and convex polygons are simpler.

    The logic would be if not inside the shape move the object to the closest point on the edge of the shape.

    For polygons the prices needed are:

    Finding of a point is inside of a polygon, distance to a point, and distance to a line segment.

    For irregular polygons with concave parts I think the above wouldn’t work super well.

    For that I think you could consider a line from its position to its new position, and stop and slide on the first edge it intersects.

    If you had a particular shape in mind there may be simpler ways to do it.

  • Boxes are a bit more involved.

    For a circle you use the distance between the points and the center of the circle. For a box you use the distance from the closest point on the edge of the box.

    For a non rotated box you could get that point with:

    X = clamp(p.x, box.bbleft, box.bbright)

    Y = clamp(p.y, box.bbtop, box.bbbottom)

    At least that’s a start. That gives points inside the box.

    I’ve run out of time again. Time management for me is very poor lately.

  • Ah, well moving 15 pixels instead of 1 would work but I think you missed what the original solution was.

    When a wall is hit it turns it 180 degrees.

    Then it does a loop to see if it’s overlapping a wall and move 1 pixel at a time till it’s out of the wall. That way it will move as many pixels as necessary to get out of the wall.

  • No regex was used here. In c you’d have more options of ways to do it. You could do it the same, just the string functions would be named differently. C also has that conditional operator ?:

    Probably in c you’d use an array instead of the token at.

    This would be basically the same in c. I didn’t do the part to extract the name.

    char right(char* s)
    { 
     int i=0;
     while(s[i]) i++;
     return s[i-1];
    }
    char* getBest(char* a, char* b, char* c)
    {
     char* best = right(a)>right(b)?a:b;
     best = right(best)>right(c)?best:c;
     return best;
    }
    
    int main()
    {
    char* apple="apple3", pear="pear4", mango="mango1";
    char* best = getBest(apple, pear, mango);
    
    int prices[] = {50, 100, 200, 800};
    int cost = prices[right(best)-'0'];
    }
  • The solution sounds complicated.

    This would set best to the var with the highest digit.

    best = right(apple,1)>right(pear,1)?apple:pear

    best = right(best,1)>right(mango,1)?best:mango

    Then we can split the name and number.

    name = left(best, len(best)-1)

    num = int(right(best,1))

    And you can lookup the prices with:

    If name=“apple”

    — price = tolenat("50,100,150,200", num-1, ",")

    And similarly for pear and mango.

    Anyways, cheers