R0J0hound's Forum Posts

  • The videos all look the same.

    Again as in my first reply you want to apply a force opposite the velocity to do proper friction where it will move to a stop instead of just getting slower and slower.

  • I don’t see what’s not smooth. Velocities are decreasing down to 0.

  • Glad it was helpful. I don't need any graphics at this time but I appreciate the offer. Also no money or donations needed. This is a zero cost hobby for me. It’s mostly just a fun mind exercise.

  • Well, I have nothing but suggestions. These examples are meant as ideas that maybe you can run with.

    The first idea is to do pathfinding over a path of connected nodes you define in the editor. Made this yesterday. The pathfinding algorithm is just a breadth first search that moves the unit to the closest node.

    dropbox.com/scl/fi/gjktm17fyb2azud1gmbqg/pathfind_ladder.c3p

    The second idea is to just do a bunch of logic to decide what keys for the ai to press. Like move left or right toward the player, and if the destination is a platform above move to the closest ladder first. Basically, in this way you'd handle as many specific cases as needed till it looks ok. This is much less general purpose, and it tailored to the level design. Realistically you'd both have to either tweak your levels or logic.

    This particular logic can handle two platform levels and ladders. AI jumps over holes and up ledges, but I ran out of events before handling falling down holes.

    dropbox.com/scl/fi/i9z6ptjjqo9msobjd98av/pathfind_ladder_behavior.c3p

    Arrow keys to move manually. Hold down left mouse button to ai move toward the mouse.

    Anyways, those are two ideas developed up to a point. Neither are perfect but hopefully they give some ideas on how you could go about it.

    After messing with both approaches, I think next time I'd do a hybrid of the two

  • It says video is private

  • Would multiplying the velocity by a number smaller than 0.1 stop faster?

    You could also try to instead apply a force opposite to the velocity to slow it down. That would act more like friction. Maybe something like this?

    apply force 10 at angle angle(0,0,vx,vy)+180

  • Those are some pretty tight constraints on what kind of reply is acceptable. Any shared solution would just end up being a suggestion or an idea, even if a way was found. But I'm all for abiding by constraints.

  • 1.

    Take a look at the choose() expression. Choose(random(-45,45), random(-45,45)+180)

    2.

    I think the original pong basically treated the front of the paddle as a curved edge so you could tweak the bounce angle depending where it was hit. There are lots of ways to go about that. One could be to make the collision polygon curved in the image editor. Another could take the ball.y-paddle.y and add that to the angle when bouncing. Or some scaled version of that.

    There is no recommended stopping point. My mode is to go at a problem till I’m bored of it or have made things function at a satisfactory level. Perfection never has to be achieved before moving on. The idea is the more you do the more you’ll get better at doing stuff. But if something ceases to be fun then do some other project that is fun. You only need to know a very small amount of construct features to make most stuff.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could set a variable inside the function when you knockback the player. Then just check to see if that variable is set in the function to prevent repeats. Then you’d just reset the variable later. Either at the end of the frame or after some time later.

    Or some variation of that.

    Another idea could be to accumulate the impulse into variables then a one point in your events clamp the value and apply it.

  • Construct physics doesn't provide the ability to intercept a collision to do your own logic. The underlying library probably does but it’s not exposed.

    You could go the route of using a js library to do the physics with that. You’d just need to add code to sync the physics sim with construct objects and vise versa. Main annoyance would be to get the library to use construct object collisions. Especially for some objects like tilemap. Anyways then you’d use a postCollide callback or something in the library to intercept the collision response and do your own thing.

    There may be something simpler you can do. If you kept tract of the objects previous position and velocity you could set the object to that after a collision with a slope and manually advance the object till its in contact with the slope. Could be fiddly if you end up having to fight the physics behavior.

    Logic for that would be to save the position and velocity to some variables at the end of every tick. Then under a player “collides with slope” condition you’d know that the physics hit and slid down the slope a bit in the last update so you’d set the position and velocity to the saved values. Next to close the gap you could manually advance the position till in contact with a loop similar to:

    repeat 100 times
    — player: move 0.5 pixels at angle angle(0,0,self.physics.velocityX, self.physics.velocityY)
    — player: overlaps slope
    — — stop loop
    — — player: set velocity to 0,0
    — — //any other logic you want

    You can adjust the step size to be more accurate. That assumes linear motion in the last step so to incorporate the acceleration from gravity you’d set the position instead of moving at angle which would look similar to this:

    Set x to self.x+self.vx*step
    Set y to self.y+self.vy*step+0.5*gravity*step*step

    Units are strange in the physics behavior so you may have to modify the gravity value a bit by a factor of 50. Either /50 or *50 but I forget. For step you’d use a value smaller than dt to get a more accurate collision.

    Some may argue that you could use a raycast to calculate where the object may hit the slope. However, it would miss collisions near the edges and would only work well for round players.

    Rolling your own physics with events may be viable too depending how complex you want it. Biggest chunk would be collision detection and resolution. But if you want to have rotating physics objects then it may just be easier to use the physics behavior instead or calculating contact points.

    Revisiting the idea of doing your own collision detection. The idea I posted above is basically moving things in sub-steps to get a semi accurate collision point. If you wanted to get the collision normal then you’d need to use some raycasts in that care to find that (especially if your slopes are just rotated walls) or maybe you could cheese it by utilizing the angle of the wall.

    There are more elaborate collision detection that both detect collision and give you the closest directing to move objects apart (but that will result in sliding). Some kind of shape casting algorithm can get you the position exactly where the objects touch without sliding, but that’s in straight lines and isn’t trivial for all shapes. But I’m rambling a bit.

  • Well we can’t change things on a different layout than the one we are on. You could make the ingredients global so they transcend layouts. Aka, they won’t get destroyed when you change layouts. But you’d need to clean up the ones you didn’t want to transfer.

    You could just store a list of the ingredients in an array or global variable, then when you move to the other layout you’d look at that the list and create objects from that.

    Simpler still to me could be to make the game all it one layout. Just jump the scroll position between the two areas.

    Anyways, just some ideas.

  • I'm less concerned with a way to mask the fluids inside the container than I am to figure out how high the fluid should be to have a certain volume. It ends up simpler to calculate the area of a polygon than it is to calculate the amount of fluid pixels in an image.

    If we are just talking masking, then what I ended up doing is using blend modes to mask out an area and draw within it. By controlling the draw order, you can do this multiple times on the same layer as long as you fill in the mask completely before moving to the next object. Destination-out to define the mask shape, and destination-atop to draw in the mask.

    Masking with a shader or a clipped polygon have their own sets of quirks and shortcomings.

    Anyways, if you want to check out how I made those images here is a modified project you could pick apart to get ideas.

    dropbox.com/scl/fi/t1bjw1ybu5gaptqwnwj4s/testtube_fill2.c3p

    The algorithm takes about 52 iterations to converge on a near perfect result, but it's good enough with a lot less. I could see it converging faster by interpolating the areas between y's but that would complicate it a bit. The loops could be eliminated altogether by making an approximate area vs y graph formula for multiple angles and interpolating between them.

  • I was messing around with a way to adjust the fluid levels so that the amount of fluid is the same no matter the test tube angle or even no matter the shape. For example, all four of these containers have the same amount of fluid.

    The strategy is to define the container as a polygon, then you can clip the poly by the fluid level and then you can calculate the area of the clipped poly. I just adjusted the level in a trial-and-error loop till the area is at a certain area. Doubt I'll post a c3p at this point since it's a cluttered 14 events. It did satisfy my puzzle solving urge for the moment though.

    I realize you may not be looking for technical solutions at this point. However, from a design perspective you may want to add a lot more to make it more fun than say the dozens of games like that.

  • You can just create the mirrored side with events if you like:

    + System: On start of layout
    + System: For each Sprite
    -> System: Create object Sprite on layer 0 at (320-(Sprite(loopindex).X-320), Sprite(loopindex).Y), create hierarchy: False, template: ""
    -> Sprite: Set size to (Sprite(loopindex).Width, Sprite(loopindex).Height)
    -> Sprite: Set angle to 180-Sprite(loopindex).Angle degrees

    320 can be changed to whatever the center x position on the screen is.

    EDIT:

    Wait, you can just select all the sprites, press enter to wrap the selection and change the width to mirror it too.

  • Shaders manipulate pixels and have access to the depth so you can do 3d lighting stuff already. Couldn't you already do 3d water similar to the 2d water shader?

    Or maybe you mean vertex shaders? Like what mesh distorts do but run in a shader? Since construct mostly just draws quads I guess moving the corners around isn't too interesting at this point.

    I guess it could be more powerful if we were able to provide more data to shaders besides just number uniforms. For example: arrays, additional images, matrices and vectors. But that all may be out of the scope of what construct wants to provide.