R0J0hound's Recent Forum Activity

  • If you're using the on collision event you specify the type to check for collision with, so you could use the angle() expression. Just use the other object type instead of other.

    Or if you make a family, call it other, and then use an event like this:

    Sprite: on collision with other

    That way you can use your expression exactly. Also this is the recommended way to handle collisions between two objects of the same type.

  • To do any 3d scaling like that you need to take into account z position.

    when z=1 then the object is at the screen, if z=0 then it's at your eye. Usually you want to destroy/hide the object before reaching the eye.

    Consider this example:

    https://dl.dropboxusercontent.com/u/542 ... edo3d.capx

    I just drew up some simple graphics. I placed the road so it disappears at a vanishing point (320,240).

    I then placed the "building" sprites on either side of the road where I'd want them to be if they were at the screen. I then resized them so the edges match the edge of the road.

    Looking at just the right "building" it has a position of (556,426) and a size of (161,105).

    Next is the math part. We want it to move and scale as the z changes.

    Set position to ((556-320)/z+320 ,(426-240)/z+240)

    Set size to (161/z, 105/z)

    In the above equations 320 and 240 is the vanishing point,

    556 and 426 is the object's original position,

    and 161 and 105 is the original size.

    z is how far into the screen you want the object to be.

    Z sorting can be done with something simple like:

    for each sprite ordered by sprite.z ascending

    --- sprite: move to back

    Collision detection can be done by seeing if the z is in range of the other's z:

    sprite: on collision with building

    building: z > sprite.z-0.01

    building: z < sprite.z+0.01

    --- destroy sprite

  • add a start of layout condition to the for event. Events are run top down every frame so the "for" would be run every frame.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can delete it if you like. I used it to limit how far the wheel can rotate.

  • There is no capx. This was for Construct Classic, but the cap file link still works.

  • mattb

    The way I look at it the angles of the two gears are related like this:

    gearB.angle = (gearA.angle-gearA.initialAngle)*ratio + gearB.initialAngle

    So when gearA.angle is zero gearB.angle is:

    = -gear.InitialAngle*ratio + gearB.initialAngle

    Make that negative and we get the phase:

    phase = gear.initialAngle*ratio-gearB.initialAngle

    Ok, to simplify the angle calculations make sure the angle of every gear is between 0 and 180 degrees. Then using the following makes rotations spot on in your capx:

    phase = -gear.Angle+fGear.n/Gear.n*-fgear.Angle

  • You could also utilize the "pick by comparison" with the distance expression. So if the tiles are 32x32 pick the tiles that are less than 33 pixels away. 1 extra pixel to account for float.

    Global number iid=0

    On Sprite clicked

    set iid to Sprite.iid

    On Sprite clicked

    Pick all Sprite

    Pick Sprite by comparison: distance(Sprite.x,Sprite.y,sprite(iid).x,sprite(iid).y) <=33

    [Negate] pick Sprite by uid sprite(iid).uid

    Sprite: set animation frame to 2

  • The editor is made in c++ with OpenGL to draw stuff. JavaScript is also used to for the plugins to communicate with the editor. When you run or export your project it's all html5 and JavaScript.

  • The idea is just to create them all and hide them as needed.

    The for loop to create the squares can be done once in a start of layout event. The for each ordered can be done once right after all the squares are created to define the order they get shown. You can then do the hiding with the first two events in my previous post. "Health" was the example variable that the squares represent.

  • Do you have a particular order you'd like the blocks to be added or removed?

    One brute force way would be to add all the square in the editor and give them an instance variable that you set to the value. Then

    Global number health= 100

    Every tick

    --- square: make invisible

    Square: var <= health

    --- square: make visible

    You could also place all the blocks with events.

    For "x" from 0 to 9

    For "y" from 0 to 4

    --- create square at ( 100+16*loopindex("x"), 150+16*loopindex("y") )

    --- square: set var to loopindex("y")*10+loopindex("x")+1

    Where 16 is the size of the squares and 100 and 150 are the top left corner coordinates.

    The way you set "var" controls the order they appear. Above it adds then a row at a time.

    To make it ordered like your pic you could try this to set var.

    For each square ordered by 1000*(X+y)+y descending

    --- set var to loopindex

  • For more realism a rudder would not affect the angle of the ship, instead it only controls how fast it can turn.

    Either way, instead of using the angle of an object, add the signed angle difference to a variable and use that.

    A signed angle difference is like the anglediff() expression except it's negative when counter-clockwise.

    Using that you can limit the turn of the wheel to something like 3 rotations either direction. Also it makes it simpler to make the ship turn with a ratio of the wheel.

    https://dl.dropboxusercontent.com/u/542 ... ntrol.capx

  • Here's a capx:

    https://dl.dropboxusercontent.com/u/542 ... _jump.capx

    To find the height of the wall you can use a loop with either "overlaps at offset" or looking at the tile itself with "tile at".

    To calculate the jumpstrength use this formula:

    jumpstrength = sqrt(2*gravity*height)

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound