R0J0hound's Recent Forum Activity

  • This will give a signed angle diff between two angles.

    angle(0,0,cos(a-b),sin(a-b))

    It's in the range of -180 to 180. It always picks the shortest distance but it's negative if CCW and positive if CW.

    Alternatively you could leverage the CW and CCW conditions or calculate if the angle diff is CW or CCW with

    (sin(a-b)<0?-1:1)

    global sign=1

    global short_angdiff=0

    global long_angdiff=0

    every tick

    --- set sign to (sin(a-b)<0?-1:1)

    --- set short_angdiff to anglediff(a,b)*sign

    --- set long_angdiff to (360-anglediff(a,b))*-1*sign

  • Here's the gist of accessing objects and picked objects in python:

    Behaviors are accessed like so. If the object is called Sprite and the behavior is Platform then the behavior is SpritePlatform from python. Be aware python is case sensitive.

    To access the behavior paired with the object you do it like so depending on the way you access Sprite.

    Sprite

    SpritePlatform

    Sprite

    SpritePlatform

    SOL.Sprite

    SOL.SpritePlatform

    SOL.Sprite

    SOL.SpritePlatform

    You can also see a list of them from python by setting some text to the dictionary with a snippet like this:

    Python("str(dir())")

    Also you can look at a list of methods available in a similar way:

    Python("str(dir(SpritePlatform))")

  • You can do this in C2 expressions. Just replace rad,

    rad*180/PI

  • Why not ask here? That way if I'm not available to answer right away other experienced users can answer as well.

  • Yes, you can.

  • Do you have any particular questions on how to do something? I won't be making a tutorial, but I'd be happy to answer questions if I can.

  • It has no licience. Feel free to use it in your projects.

  • You can restrict it to a box or circle. Arbitrary shapes are quite a bit more complicated. Here's how to restrict to a circle:

    global number dist=0
    global number ang=0
    
    joystick is dragging
    --- set dist to distance(joystick_panel.x, joystick_panel.y, joystick.x, joystick.y)
    --- set ang to angle(joystick_panel.x, joystick_panel.y, joystick.x, joystick.y)
    --- joystick: set position to joystick_panel
    --- joystick: move max(75, dist) at angle ang[/code:swv2lxcq]
    Just change 75 to the max distance you want the joystick to go.
    
    To make the player move according to the joystick you likely can do it by comparing the x positions of joystick and joystick_panel, or even as a sub event of "is dragging" and use the ang variable.
  • nutmix

    a) This is because of how a computer samples the mouse. The solution is to use a line from position to position or draw at in between positions like Coin-coin le Canapin's example.

    b) With the canvas plugin you can by using canvas.alphaAt(x,y) for each pixel or use the slightly more esoteric yet faster canvas.AsJSON expession to get the pixel data into an array.

  • christina

    Here is a capx with the idea I posted. The only error was "screeny = ((v-0.5)/z + 0.5)*h2 + o2.y" needed to be changed into "screeny = (v/z)*h2 + o2.y".

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

    I tested it with a plane rendered with two different field of views and it seems to become less accurate if I use a fov other than 60. It probably needs to account for that somehow.

    Your last capx isn't working right because it's it's scaling from the left instead of the center. See 2 above^

    Also for your original capx changing the set y expression to "board.Y + (relativeY*board.Height) /lerp(2,1,relativeY)" seems to get the y working better. You can adjust 2 to change the strength of the effect.

  • I didn't test it so there may be errors. Also I can't look at the capx till tomorrow.

    Z is the distance from the eye, which is at z=0. The camera is at z=1. Anything further will have a greater z which in turn will look smaller since the perspective is calculated with x/z, y/z. Basically the bottom width divided by 1.7 should equal the top width.

    1. The idea I had was to find how far away the back edge would have to be if it was that width. Without perspective the top edge should be just as wide as the bottom. With perspective the same projection formula can be used proj_width=width/z. Sovlving for z it come out to z=proj_width/width, and then it's just a matter of interpolating by y or v.

    2. The 0.5 is so we're scaling at the center instead of the left edge. U and v are in the range of 0 to 1, so 0.5 is halfway. Also /z is scaling.

    As a simple example say you wanted to double the x distance from 320 you'd do:

    X=(x-320)*2+320 if instead we wanted to just scale from 0 it would be

    X=x*2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This may work:

    In it's basic form a perspective projection in just dividing x and y by z.

    This is the 2d map.
    o1 is the top-left corner and p is a point to project.
    
       w
    o1----+
    |     |
    | p   |h
    |     |
    +-----+
    
    Convert them to u and v to get coordinates from 0-1
    u=(p.x-o1.x)/w
    v=(p.y-o1.y)/h
    
    Next we have the perspective sprite.  w1 and w2 are the widths of the top and bottom. o2 is the top-left and h2 is the height.
          w1
    o2  ______     -+
       /      \     |
      /        \    | h2
     /          \   |
    /____________\ -+
          w2
    
    We find the z from v with:
    z = w2/lerp(w1, w2, v)
    
    Then we can do the perspective transform with:
    screenx = ((u-0.5)/z + 0.5)*w2 + o2.x
    screeny = ((v-0.5)/z + 0.5)*h2 + o2.y
    [/code:1ikwzr29]