R0J0hound's Recent Forum Activity

  • Ah, the issue was how i was doing the keyboard stuff. The joy variables were being set in the key triggers but they'd be 0 by the time the move event came up so it wouldn't move.

    Anyways here's the working version:

    dropbox.com/s/ibw8ac9wtlb7czq/move_between_circles.capx

    Edit:

    You can tune it a bit by changing the /1000. I picked that so the perpendicular distance had a low influence. You can set it lower to make it affect it more.

  • I think I need to actually test it to see what’s up. Sorry about that.

    One thing that comes to mind is maybe you should move the selection to the closest dot in every tick. It may not be exactly on it since pin is delayed a frame.

  • Seems like an interesting problem. Thanks for everyone for the examples. It took me a bit to realize what they did since I’m on my phone.

    Here’s my event based solution. The first part is just for input, the last event is the meat.

    First it skips the dot the cursor is on.

    Next it picks all the dots in a cone in the direction pressed.

    Then it utilizes “for each ordered” to sort them by distance. It would be the same as “pick closest” but it also adds a fraction of the perpendicular distance so it prefers the dots closer to the direction pressed as opposed to just one of them when they are all the same distance away.

    variable joyx=0
    variable joyy=0
    variable dir=0
    variable move=false
    
    every tick
    -- set move to true
    -- set joyx to 0
    -- set joyy to 0
    
    on left pressed
    -- add -1 to joyx
    
    on right pressed
    -- add 1 to joyx
    
    on up pressed
    -- add -1 to joyy
    
    on down pressed
    -- add 1 to joyy
    
    compare: abs(joyx)+abs(joyy)=0
    -- set move to false
    else
    -- set dir to angle(0,0,joyx,joyy)
    
    move is true
    pick dot by evaluate: dot.x<>cursor.x & dot.y<>cursor.y
    pick dot by evaluate: 45>anglediff(dir, angle(cursor.x, cursor.y, dot.x, dot.y))
    for each dot ordered by distance(cursor.x, cursor.y, dot.x, dot.y) + abs(cos(dir+90)*(dot.x-cursor.x)+sin(dir+90)*(dot.y-cursor.y))/1000 ascending
    -- stop loop
    -- cursor: set position to dot
  • You do not have permission to view this post

  • The code only does the one rotation. You’d have to add code to rotate a tilt.

  • Probably replace 1024 with 1025 but I haven’t tested it.

  • I don’t have time to work on such a thing. Seems like the kind of thing independent of the cloth sim. I mean in something from scratch can you attach a sprite to another sprite?

    Also the zorder is completely subjective with this cloth sim. Make it 3D and there would be an order but I’m taking a step away from this for a while.

  • Hi,

    That plug-in hasn’t been ported unfortunately. Aside from my low interest in making plugins and barely using C3, I simply don’t have a lot of time to dedicate to doing much coding at all.

  • Here is a more generic version.

    1. Place the cloth sprites wherever you want some cloth. It supports multiple instances.

    2. change the instance variables of the cloth sprite to change up the settings.

    a. resX, resY is the size of the grid that you want to simulate. bigger sizes are slower.

    b. diagonals turns on diagonal constraints. Makes cloth a bit stiffer.

    c. iterations will make the cloth less stretchy the higher it is. 1 is the default and fastest. More than 10 would be very stiff but very slow.

    dropbox.com/s/cl1205kk9cwjh3c/verlet_cloth_paster2.capx

  • I think it may be one of those things that construct doesn't update the values of until things are drawn. So the result is the calculation gives a position one frame behind.

    I haven't used those equations but I had the same issue when trying to get the screen left right after setting the scroll position. My solution was to calculate it manually.

    Off the top of my head this should give you the x,y position of the center of the screen on the 90,90 parallax layer. I haven't tested it though.

    x = scrollx*0.90

    y = scrolly*0.90

  • You can rough it out by doing a loop. x0,y0 would be the first point, and x1,y1 would be the second.

    repeat 10 times
    -- create coin at (lerp(x0, x1, loopindex/9), qarp(y0, y0-200, y1, loopindex/9)

    you can make it place more or less depending on the width of the gap.

    repeat (x1-x0)/32 times
    -- create coin at (lerp(x0, x1, loopindex/int((x1-x0)/32-1)), qarp(y0, y0-200, y1, loopindex/int((x1-x0)/32-1))

    The 32 is to space the coins out horizontally every 32 pixels.

    The 200 to strength of the parabola.

    Here's also a way to automate calculating the two positions between each two plats from left to right.

    global number prev=0
    global number x0=0
    global number y0=0
    global number x1=0
    global number y1=0
    
    start of layout
    for each plat ordered by plat.x ascending
    -- loopindex > 0
    -- -- set x0 to plat(prev).x+plat(prev).width
    -- -- set y0 to plat(prev).y-plat(prev).height
    -- -- set x1 to plat.x
    -- -- set y1 to plat.y-plat.height
    -- -- repeat ....
    -- -- -- do stuff
    -- set prev to plat.iid

    Anyways the coins will basically be equally spaced horizontally, but vertically they will vary in spacing. We can make them equally spaced along the path, but it's more complex. It amounts to making a path of straight lines, and measuring the length between each point, and adding them all together to get the total length. Then it's possible to move along the path by a certain distance at a time. I probably won't do a description justice. The example in the end does it.

    Another thing you can do is relate the arcing of the parabola to the platform behavior's jumpStrength and gravity. You asked what the formula for a parabola is, and for the platform behavior it's:

    x = x0 +vx*t

    y = y0 +vy*t + 0.5*gravity*t*t

    You can use that to solve for t to by plugging in -jumpStrenth into vy. That would give you the total time of the jump. Then you can do this to get a path close to the platform movement jump.

    set totalTime to (JumpStrength+sqrt(JumpStrength^2+2*Gravity*(y1-y0)))/Gravity
    repeat 10 times
    -- set t to loopindex/9
    -- create coin at (lerp(x0, x1, t), y0-jumpStrength*t*totalTime + 0.5*gravity*(t*totalTime)^2)

    At any rate here's the example of me playing around with the idea. Maybe some of it is useful.

    dropbox.com/s/ud2lfm0mp8znvqy/inf_coins.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Since this is C3 you could also use the tiledBackground instead of the canvas. You'd still create an instance per slice, but you can set the "offset y" to select the correct part of the image. Could be even used for per pixel, it's just more instances.

    The pro is it would use less vram since it's just reusing the one texture.