R0J0hound's Recent Forum Activity

  • Here's one way to do it. Namely event 4. The rest is physics and such which isn't needed.

    Basically it treats the objects as circles and moves them away from each other if too close. Works between object of the same type. You can change the radius in the set dist action. Currently it uses 24 but you can change that.

    dropbox.com/s/mlm73dkgtjvvw42/againstTheCrowd.capx

  • So here is a slightly different example.

    * The rotation is driven by pressing a key.

    * It now lets you use any value for the rotation speed.

    * I moved the variables into the sprite so we can have multiple rolling squares.

    * Lastly, it rounds the angle and position to the nearest integer when a 90 degree rotation is done. Do to rounding errors the position and angle wouldn't be slightly off a perfect value.

    dropbox.com/s/4vfgdw3mzx6lwkb/box_roll2.capx

  • Well k is just an arbitrary number. Having k=1 may make the perspective effect too severe, but a higher number such as 500 would make it more subtle in a reasonable way. If more careful about the units it relates to the field of vision of the camera.

    z is the third dimensional position of an object. I know we are dealing in 2d but to have the perspective we need to know how far into the screen an object is to scale it.

    a is just the amount of degrees you wanted to rotate.

    Here is a possible example but i got a bit carried away beyond the basic ideas. I guess 3d tends to snowball depending what you're doing. The meat of it is event 15. It sets the camera orientation, transforms the object positions from that orientation, applies a perspective transform, and finally zsorts everything.

    dropbox.com/s/oggk1776al45ka1/3d_camera_events.capx

  • So you just want to change the view? You can use the 3d camera object to do that to some extent. You can position objects xy and zElevation.

    Control wise all the movement behaviors are 2d on the xy plane so you'll need to do the z axis motion with events.

    If you don't want to use 3d and instead want to do the rotation/perspective with math and just sort the objects in 2d then the two building blocks for that are:

    1. Rotation of a position around a center. Here it does it on the xy plane but you can do it on the xz or yz plane too. The equations are the same, just change what axis is used.

    newX = (x-centerX)*cos(a) - (y-centerY)*sin(a) + centerX

    newY = (x-centerX)*sin(a) + (y-centerY)*cos(a) + centerY

    2. perspective transform and scaling. Here k is some scaling factor that adjusts the perspective. Keep in mind you'll want to hide objects with a z<1 as they are behind the camera, and you'll need to sort the objects by z.

    screenX = k*(x-scrollx)/z + scrollx

    screenY = k*(y-scrolly)/z + scrolly

    objScale = k/z

  • That was a bit older example, and I was going for a certain look but as you pointed out it doesn't move accurately. I'd probably need to figure out the formulas again to account for that. Probably simpler to use the other capx though.

    Like in that video the box is rotated around a corner and every time the box lands on an edge (every 90 degrees) it changes which corner to rotate around.

  • dropbox.com/s/q3fejozejh7s2ix/closest_value_in_list.capx

    As a similar idea to yours just loop over the list and you can see how close two values are with abs(value1-value2). So the code below would first use the first item in the list as the closest then it would select any item that was closer than the current closest.

    var list="1,44,33,66,7"
    var item=0
    var value=33
    var closest=0
    repeat tokencount(list, ",") times
    -- set item to int(tokenat(list, loopindex, ","))
    -- if loopindex=0 or abs(item-value)<abs(closest-value)
    -- -- set closest to item

    This checks all the values and works if the list isn't sorted.

    Yours stops as needed since your list is sorted.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you explain what you’re after a bit more? It’s not clear to me.

    Your images are different views of 3D meshes. So if you placed cubes down and adjusted the camera you can get the same look. But your descriptions made it seem like you’re after something else

  • I see what you mean by the blob not being a solid color after using the alpha clamp effect. At least with any color but black. I think it has to do with how the effect handles premultiplied alpha perhaps if someone wishes to make a modified effect.

    As for the quality of the edge you can use different gradients to change that a bit. I’ve found the soft brush in the C2 image editor makes a nicer gradient than the soft brush in C3’s image editor, but other image editors could create better ones.

  • Finally got around to finding a decent solution to this.

    To do the jump I have it squish horizontally as if it was a muscle. I works pretty well as it jumps only if on the ground.

    dropbox.com/s/5ao27efbsdox8bm/jello_no3rdParty_keyboard2.capx

  • I was going to attempt to make an example but I found a lot of previous tests that may be helpful. There are probably more but my naming convention is inconsistent. Some use physics for the motion, and some do the motion with math in events. I skimmed over them briefly but maybe a third of them have the forces between every pair of objects.

    dropbox.com/s/8bimqsdnysh5bov/orbital_simple.capx

    dropbox.com/s/eldpa0s7zvfr333/orbit2.capx

    dropbox.com/s/tk76c6cmc4vlocd/orbit.capx

    dropbox.com/s/5dpb882vdi03d00/orbit.capx

    dropbox.com/s/gle6gz7lbo18cq7/orbit_physics.capx

    dropbox.com/s/9zx2ivqzli2ewbx/orbital.capx

  • Ah, so you mean just rolling a sprite then?

    dropbox.com/s/gora2uebn0e4wov/box_roll.capx

    Even found an old example that does it in a different way.

    dropbox.com/s/kx8kbfpqpimuec5/box_walk.capx

  • Roughly you’d do this to apply gravity between two objects a and b. You’ll have to tune it though. Adjust the masses of the objects, and the g variable.

    Var g=10000
    Var ang=0
    Var force=0
    
    Every tick
    — set ang to angle(a.x,a.y,b.x,b.y)
    — set force to g*a.mass*b.mass/distance(a.x,a.y,b.x,b.y)^2
    — a: apply force (force*cos(ang), force*sin(ang))
    — b: apply force (-force*cos(ang), -force*sin(ang))

    That handles the gravity between a pair of objects. You’d just have to do that between every pair.

    If you search my posts I’ve made an example or two in the past if that helps.