R0J0hound's Recent Forum Activity

  • So the first two digits are hours and the second two are minutes. So you could convert a string like "0245" to a decimal hours with:

    Int(Left(text,2)) + int(right(text,2))/60

    Which will give 2.75

    In simpler terms it's just this:

    Hours + minutes/60

  • The canvas and paster plugins allow you to create your own images.

  • tgeorgemihai

    For that you could add a pick all solidWall condition between the overlap conditions.

  • Ok, here's two examples, one using the physics behavior and one using the chipmunk behavior

  • I've done that before without the physics behavior here:

    It can be done with physics but the torque calculation needs the object's inertia

    torque = inertia*angularAcceleration.

    But for that you'll also need to manually calculate inertia from the object's mass since the behavior doesn't give it:

    inertia = mass * (width^2 + height^2)/12

    Also the units of the mass expression of the physics behavior is off.

    so to get a correct value you need to divide it by 50 to get a correct value.

    I forget if there are any other quirks that make it tricky. :/

    I'll try to get a example going over the next few days.

  • [quote:h6zl67ei]Is there a way to set linear or angular damping per object?

    It's not a built-in feature of the chipmunk library but you can do it by either:

    1. setting the velocity to say (velocityX*0.9, velocityY*0.9) where 0.9 is a value from 0 (total damping) to 1 (no damping)

    2. applying a force in the opposite direction as the velocity or angleOfMotion.

    [quote:h6zl67ei]Prevent rotation is another handy feature that's missing

    True. I just need to find a good way to work that in.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use instance variables for filtering. With it you can disable collisions of other layers and such. The stairs by far will be the trickiest to do. Well, other than implementing path finding and line of sight, you'll have to get creative for those.

    Here's an attempt at stairs you can go up and down. There's likely an easier and cleaner way but it escapes me at the moment.

  • global number t=0

    every tick:

    --- set t to abs(time%2-1)

    --- set x to cubic(a.x, a.x, b.x, b.x, t)

    --- set y to cubic(a.y, a.y-100, b.y-100, b.y, t)

  • You can use the Snapshot action instead. For for a 100x100 image centered on position 50x50 you could do this:

    ---Set canvas size to 100x100

    ---scroll to (50, 50)

    ---Take Snapshot

    on snapshot

    ---set canvas size to 640x480

    ---scroll to (320,240)

    ---invoke download of canvasScreenshot

    The second scroll to is to scroll back to the original scroll location. If the layout isn't using unbounded scrolling you could also use (0,0).

  • This example may help:

    Z is just the y distance from the shadow on the ground.

  • Why not use the physics behavior or this behavior?

    You can do it without the physics behaviors but you'll have to do some math.

    If ball is in the air then move it down.

    If the ball hits the ground then...

    1. find the angle of the ground.

    -- one way to do this is just have different sprites for different angles or you could even use the angle of the ground sprites.

    -- another way is to use two detector sprites. One a little to the left of the ball and another a little to the right. Then in a loop move each detector down till they hit the ground. Then just calculate the angle of the left detector to the right.

    2. Move and roll the ball down the slope. This is where the math comes in.

    -- the simplest way is of course to just use the move at angle action.

    -- the amount to rotate the ball can be calculated with distance_moved/ball_radius*180/pi. And make it rotate counter clockwise if the slope is to the left (or the angle is from 0 to -90 degrees.).

    That will give roughly ball motion. It can be improved instead by giving velocity and angular_velocity to give the ball momentum and calculating the accelerations on a slope for the angular_velocity. So basically the better you want it to look the more physics equations you need to use, which is something those behaviors already do for you. But it never hurts to learn how things work.

  • Updated to version 1.1:

    Fixed: bug with "set collision layers" action.

    Fixed: bug with "apply impulse" action.

    Fixed/Added: more support for Chipmunk2d's object sleeping behavior

    Fixed: Collision shape wasn't always aligned properly.

    Added: expression to get the uid of the other object of a joint.

    Added: action to sleep or wake up an object.

    Cosmetic change: moved the actions in the "velocity" action group to the "dynamics" action group.

    Here's example using segment shapes, collision layers and the "pick closest object" condition to do a sonic the hedgehog like loop.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound