Yann's Forum Posts

  • for 4. you could use your own stack

    create an array, name it stack, give it the size 0,1,1

    save your function parameter by doing stack.push(back, value, on X-axis)

    after your wait action you do a

       set object.angle to stack.front

       stack: pop front value.

  • Joannesalfa

    The drawing part ressemble the draw line and fill action. But it's simplified since you don't have to do the beginPath, moveTo and lineTo, endPath, fillPath, strokePath etc

    you just have to do a serie of Add Vertex action followed by a draw Polygon action where you specify the fill color and line width/color.

    Everything else is handled under the hood.

    And since you give the vertices in local space, you can more or less dynamically position the origin. And also the collision polygon is automatically created to fit your polygon.

    So yes... ressemble canvas plugin but way more specialized toward polygons.

  • Ashley

    Alright (: since there are workarounds, I think it's not that big of a deal.

    Thanks for the explanation.

  • Other than using a plugin, you could simply build a list in an array

    on start of layout
       local text letters = "abcdefghijklmnopqresuvwxyz"
       set codeToChar size to (256,1,1)
       repeat 26 times:
          //letters
          set codeToChar.At(65+loopindex) = tokenat(upperCase,loopindex,"")
       repeat 10 times:
          //numbers
          set codeToChar.At(48+loopindex) = loopindex
          //numpad
          set codeToChar.At(96+loopindex) = "numpad "&loopindex

          //F1 to F12

       repeat 12 times:

          set codeToChar.At(112+loopindex) = "F"&(loopindex+1)

    so you can do

    codeToChar.At(keyboard.LastKeyCode)

    to get the key

    You'll have to fill the other possible key more... manually though (:

  • I adapted the algorithm Ashley came up with here for C2

    I also modified the comments for the smart aiming formula to make the explanations slightly easier to understand (although it's still complex math)

    aiming.capx

    Ah it ends up behing exactly equivalent to what squid came up with.

    since

    asin(targetSpeed * sin(angle(target,turret) - targetMovingAngle)

    = asin (((targetX-turretX)*targetVectorY - (targetY-turretY)*targetVectorX)/distance(target,turret))Yann2013-01-15 14:48:05

  • I'm currently working on a Polygon plugin. You basically feed it some vertices (in the proper order) in local space and then draw.

    It also handles collisions.

    What I have done so far:

    Condition:              ?

    • Is overlapping another object
    • Is overlapping at offset
    • Collisions enabled
    • On Drawn
    • Compare area

    Actions

    • Add Vertex (x,y) \\ in local space
    • Log Vertex List \\ outputs the vertex list in the js consol
    • Draw Polygon (fillColor,lineWidth,lineColor) \\ every change in vertex list needs a draw call to be seen
    • Move Vertex (index,x,y)
    • Remove Vertex (index)
    • Clear Polygon \\ empty the vertex list and erase the poly)
    • Load (JSON)
    • Download (JSON)

    Expression

    • VertexX(index) (in world space)
    • VertexY(index) (in world space)
    • VertexCount
    • Area
    • LocalVertexX(index) (the original values entered in Add Vertex)
    • LocalVertexY(index) (the original values entered in Add Vertex)
    • asJSON

    Basically everything in this list is done and I'm already using it for a project so I can thorouoghly test it.

    Also it might not be super easy to work with since I'm mixing local and world space. But that's what I found the most practical.

    You create vertices relative to the position of the object so you can feed the same vertex list to other instances an have the same shape drawn.

    And you retrive the vertex position in world space so you can "pin" some objects to them or do some calculations.

    You can copy polygons using either the LocalVertex expressions or Get as JSON -> Load

    I don't support textured polygon for now at least... If it's not too hard to implement and if it doesn't make the plugin too complex I might.

    I think I'll be releasing it this month so we'll be able to talk about it in its own topic =)

  • Hi! It's me again torturing this poor function object

    I just discovered that functions seem to destroy their parameters (local variables and function arguments) before any action after a wait triggers. So basically

    on Function "test"
       -> wait 0.01
       -> Text: set text to Function.param(0)[/code:1y45gh1g]will always print 0
    
    one work around for now is to do:[code:1y45gh1g]on Function "test"
       + local static text persist = ""
       -> set persist to Function.param(0)
       -> wait 0.01
       -> Text: set text to persist[/code:1y45gh1g]
    
    little capx just in case
    [url=https://app.box.com/s/jzhqvlifaxdv5xyd0vma]functionsDontWait.capx[/url]
  • rexrainbow

    Bitwise operations affect the bits themselves

    NOT(0000) = 1111

    but in signed int it's interpreted as -1

    and in unsigned int it's interpreted as 15

  • rexrainbow

    Hey didn't know you could do that (:

    Ok I'll implement your multiple idea in the coming days =)

    As far as NOT(0) being -1

    I think, since my plugin handle signed integers, it would be weird to make an exception with 0.

    And it might go against some common bitwise operation.

    I would prefer making signed and unsigned functions, like uNOT(0)/sNOT(0).

    In short, I don't like when weird operations are hidden from the user. For the sake of an apparent "better" result.

  • WesleyNR

    Thanks for the info, I'll see what I can do about it when I get home (:

  • Start of layout:
       -> Set scrollY to Player.Y
    
    Everytick
       -> Set scrollY to scrollY-scrollSpeed*dt
    
    Player.Y > scrollY + windowHeight/2
       -> die

    (In the last one, I consider that the Player has it's origin point at the bottom (at its feet) if it's in the middle, just do

    Player.Y > scrollY + windowHeight/2 - Player.Height/2
       -> die
  • To get the nth digit (0-based) of a number you just have to do:

    (floor(x/(10^n))%10

    For instance

    The third digit of 123456
    =(floor ( 123456/(10^2) ) %10)
    = floor (123456/100) %10)
    = floor (1234.56) % 10)
    = 1234 % 10
    = 4
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • lerp(a,b,p) = a + (b - a) * p

    So in short if you imagine a and b being a start and end of a linear path, p is the percentage travelled.

    Also dt is the time in second spent between two frames

    so dt varies slightly but stay around 0.017 (1/60 fps) so 0.5*dt is more or less constant.

    The only thing you really change is scrollVar which is always random.

    What you probably want to do is having a fixed point, and a variable offset. The variation would be random, but the range of the randomness would decrease in time.

    So it should look like

    Every tick
        -> set range to max(0,range - 0.5*dt)
        -> set xOffset to random(-range,range)
        -> set scroll X to xFix + xOffset

    This way you just have to change range to trigger the shaking

  • WesleyNR

    Hmm weird, expressions works well with me. Maybe you did something wrong with the syntax and maybe I should have provided examples

    Anyway, the proper syntax is:

    If you created a timer like that

    Sprite: Start timer "test" with length 10000, Repeat, Don't destroy when finished

    you can get the current count and the initial value this way:

    Sprite[Timer].count("test")
    Sprite[Timer].initialValue("test")

    This way you can even display some percentages like this

    round((Sprite[Timer].count("test") / Sprite[Timer].initialValue("test")) * 100)

    (Ah I saw a small little mistake, for the initialValue expression it the default is value, it should be name)

  • aragon

    I've never used the ComboBoxListBox plugin before so I might be wrong

    Nevertheless, you're not using the proper parameters in the tokenat() function

    What you probably want to do is:

    ComboBoxListBox: Add: tokenat (AJAX.LastData, loopindex, "|")

    I don't really know what you want to do in event 3 since your condition is more or less the same as saying "if a = a" or event "Every tick" since it's always true and your second action is overwriting the first one.

    And also, since I've seen your php implementation, I think you have a trailing | at the end of your list, so a blank token. You might need to address that.