R0J0hound's Recent Forum Activity

  • 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)
  • 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.

  • Pardon the late reply. It’s been a long week.

    The action that sets the y position has as I recall a +200*dt*dt at the end of it. The 200 is the gravity and you can change that to whatever you want.

    Changing it isn’t really the way to do different materials. The algo I used is basically only one type of cloth. It could be made stiffer by doing more iterations of constraining the points together or adding diagonal constraints too.

    There may be other algo with more tuning parameters.

  • pillaystation

    It’s more effort than I have time for to make videos of these. I also don’t have a YouTube account.

    Anyways, they are all vanilla c2 so it should be quick to try, even in the free version I’d imagine. They do utilize some js so they won’t work as is in c3.

  • Oh true. I forgot about the behavior enforcing the max speed for you.

    He said he was expecting an orbit, but real gravity would be similar.

    To stop the orbit you could apply a brake to the tangent speed so it would fall straight down. The break could be just a velocity opposite the tangent velocity and you could make it inversely proportional to the distance. Basically that would make it brake faster the closer it is.

    a = angle(sprite to target)+90

    tanvel = vectorX*cos(a)+vectorY*sin(a)

    d = distance(sprite to target)

    If d>0

    vectorX = vectorX - tanvel/d*cos(a)

    VectorY = vectorY - tanvel/d*sin(a)

  • It’s a bit hard to debug big formulas like those, but basically you’re accelerating toward the target and limiting the the speed?

    I’d break it up into multiple steps and once that works you can combine it again.

    Local number a

    Local number speed

    Every tick

    Set a to angle(sprite.x, sprite.y, target.x, target.y)

    Set vectorX to vectorX + accel*dt*cos(a)

    Set vectorY to vectorY + accel*dt*sin(a)

    Set speed to sqrt(vectorX^2+vectorY^2)

    Compare: speed>maxspeed

    Set vectorX to vectorX/speed*maxspeed

    Set vectorY to vectorY/speed*maxspeed

  • That’s just a matter of toggling the “fixed” Boolean. False will move and true won’t.

  • The gradient does seem to add depth to it.

    I haven't used the distort mesh feature of c3 yet. I don't see it being good for a perspective transform though. When you make a square into a trapezoid the two triangles that make up the quad become very visible.

    I think the best we can do with vanilla C2 is a sprite sliced up into 1 pixel thick slices. Then reverse the math to do the distort. It's not optimal with 480 sprites for just one quad, but it matches the perspective model used. In c3 you could use the tiled background plugin instead. It adds image offset and image scale, so you don't have to actually slice up the image. It even has image rotation so you could possibly do full mode7 without shaders, maybe.

    uca98967710c3b7affbc492f621d.dl.dropboxusercontent.com/cd/0/get/Ch5B6JnAIawAF9dV-Q-O6lWZPmWXUdvsOTC6mxuof3CyRMaJhqSMdXiq5lI52iXIIpKa-6L01RUbexPBNS9krZf7smhSQ-xSs0lZ-0YFt-gegTxDX4qFfTw4AGawUZRycX79FQM2qbYgoIHs8g_sfMXe/file

    Anyways, mikal's fqz plugin would probably be simpler for c3.

  • The only one that comes to mind is the paster plugin. It has a draw textured quad action.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It can but not with vanilla C2. In C1 and C3 there is the distort mesh feature that you can use to distort the image from the points. You'd just hide the point sprites.

    With C2 you can only do the distort with third party methods which don't transfer to C3.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound