tulamide's Recent Forum Activity

  • I used Else here too :

      + Balle: On collision between Balle and BricBrique
            + BricBrique: Pick closest to: Balle.X, Balle.Y
            + BricBrique: Value 'hitme' Less or equal 5
                -> BricBrique: Add 1 to 'hitme'
                -> BricBrique: Set animation to BricBrique.Value('hitme')
            + System: Else
            + BricBrique: Value 'hitme' Greater than 5   <== EDIT : i think this line can be removed
                -> System: Add 1 to global variable 'briques'
                -> BricBrique: Destroy[/code:3adycjmx]
    
    Anything wrong with it? I just wanna know if i can improve this. I like to keep the code very short, if possible.
    

    Oh, I'm sorry, I overread this. You are right with your edit. That line can be removed. Nice improvement of the code

  • The events order things is weird, but anyway, if it works I won't complain.

    Je comprend si tu parle en francais, mais stell dir mal vor ich w?rde die ganze Zeit deutsch reden

    To understand what really happens, and why the event order is so important, you may want to have a look at this thread: Introduction to branching

    Another way to do it without reversing the order is using "else" (see the thread above)

    + BricBrique: Animation "0" is playing
                         -> BricBrique: Set animation to "1"
    + Else
    + BricBrique: Animation "1" is playing
                         -> BricBrique: Set animation to "2"
    + Else
    + BricBrique: Animation "2" is playing
                         -> BricBrique: Set animation to "3"
    ...
    etc
    [/code:3vmp428i]
  • Finally I'm posting some new content for Talbot's Odyssey:

    Subscribe to Construct videos now

    Awesome as always! If this is not going to be the next topseller on Steam then the world is crazy

  • With the first advent sunday we can't ignore anymore that christmas is coming. This thread is for all of you who want to make a present to the community, one that is somehow related to the christmas season. It could be a song, a picture, an animation, a game, a poem, etc. Just don't link to other peoples work, it wouldn't be a real gift if it wasn't created by yourself

    Here is my gift:

    http://dl.dropbox.com/u/11182740/GoJingleNoBells.mp3

    And all the people among us who don't celebrate christmas: Please don't feel offended. This is nothing religious, just a thread to make presents to the community

  • + System: Always (every tick)
    -> sun: Set Y to clamp(.y,23,200)
    -> Sprite: Set horizontal skew to [b](sun.y/70)[/b]*(Sprite.x-sun.x)
    -> Sprite: Set height to [b]178[/b]-(Sprite.y-sun.y)
    -> sun2: Set opacity to lerp(70,0[b],clamp((sun.y-100),0,100)/100[/b])
    -> Sprite: Set opacity to lerp(70,10,[b]clamp((sun.y-100),0,100)/100[/b])
    [/code:38xc7ddl]
    
    Nice, but i wonder how you come up with such things as "clamp((sun.y-100),0,100)/100". Why sun.y-100?
    
    Also, i know you didn't write all this code, but why is the shadows height set to [b]178[/b] ? random value?
    what about skew with sun.y /[b]70[/b]?
    
    This is making my head spin... also, i suck at maths, and that really doesn't help me at all here lol
    
    Thanks
    

    First question: with that clamp values devided by 100, you get a value from 0 to 1. This is needed to interpolate between 70 and 10. In result the opacity will be 70, if the suns y < 100, and 10, if the suns y > 200, in between 100 and 200 the opacity reduces from 70 to 10. sun.y = 200 happens to be the highest possible value, because it is clamped to [23, 200], so you could have used max((sun.y - 100), 0) instead of clamping as well.

    Second question: Sprite.y = 191, suns lowest y is 23, 191-23 = 168. The value 178 was chosen to have a minimum height of 10.

    Third question: I think, that's a decision based on the visuals. The goal is to let the shadows virtual origin seem to be the sun. I would have set this to (sun.y/23)*((Sprite.x-sun.x) / 2), so that when the sun is at its (visually) highest possible position, the factor would be 1.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What would be really nice is a gradient object that works like Tulamides Gradients shader.

    I totally agree, and it wouldn't be much of a work to enhance the current gradient object to be switchable between 'linear' and 'radial' mode... Ashley, ROJO?

  • How do you get such a parameter from construct please ? I've searched in the event sheet, but i cannot interact with the effects parameters with it. Is there a way to calculate something in the events or so and send it to the shader ? Or interact with its declared parameters in the event sheet ?

    When I was talking about the world size, I didn't think of something interactive. You know the size of your world/layout, so you could just enter it in the panel. At least that's what I was thinking of.

    During runtime, you would do it this way. Let's say your effect is called "myshader", and one of its parameters is called "World Width" (the display name is the one we need, not the variable name). You apply "myshader" to a sprite with the name "mysprite".

    To set the "World Width" (in pseudo code):

    + Some Condition (e.g. Always)
    -> mysprite: myshader: Set World Width to LayoutWidth[/code:2xe85af2]
    Explanation: You access the shader's parameter with the wizard. After a doubleclick on the object with the shader, you will see a seperate tab for every effect applied to that object. (LayoutWidth is a system expression, in the wizard you find it under 'system', it is called "Get layout width") 
    
    You can also access the parameters of an effect that is applied to a layer. You find the appropriate action of the system object under 'Layer', it is called "Set layer effect param".
    
    There are no getters for effect parameters, you can only set them.
    
    Here is an example of an interaction with the parameters of an effect during runtime.
    [url=http://www.scirra.com/forum/viewtopic.php?f=29&t=5703][EFFECT] Disk[/url]
  • okey now i want to cut myself...

    in your cap, you have 11 frames, and i have 11 frames. in your all frames are correctly displayed coresponding to values. in my, max value frame is like only displayed when Current is higher then Total. the only diffrence is that your cap doesnt have the auto regeneration and doesnt uses decimal values.

    and yes i know i am stubborn but i still havent learned why my method doesnt work when basing on logic it should work.

    Without seeing your cap I can't exactly tell where the problem is. Here is another cap, this time not editable, but the shield regenerates slowly over time and mean meteoroids hit the ship occasionally, substracting from the shield's current value. And all of this with crooked floating numbers, like 678.542 for total or 29.943 for the regeneration value.

    Compare this cap to yours and find the differences, then you will learn why your method doesn't work.

    Download: shipstatus2.cap

  • About the variables from construct : the problem is that i cannot get values relative to the origin of the world. This would be cool to create effects such as colorShift for vegetation, to alterate wind effects, motion or so... and it only adds 1 instruction per shader. Well, maybe this will be added later.

    I see what you mean. Yes, that would be great (and having a timer value also).

    In the meantime, given your effect isn't too instruction heavy, you can get by with the following:

    Add parameters for the current position of the left/top-edge of the display relative to the world. If you prefer to store them as pixel values, that's fine. You can use an always event to update the parameters, or any other method that comes to mind.

    Now the calculation part. There are the variables pixelWidth and pixelHeight.

    1/pixelWidth gives you the current width of the display in pixel, 1/pixelHeight gives you the height of the display in pixel.

    You now have everything you need. For example: dLeft = 320, dTop= 112, dWidth = 1024, dHeight = 768

    You may also add parameters for the width and height of the world.

    And if you have pixel values but need relatives, just multiply horizontals by pixelWidth and verticals by pixelHeight. But make sure, the values are relative to the display, first.

  • I never used the avi object to date, but there is an action 'set repeat', you can set that to 'repeat' or 'no repeat'. I think that's for looping it?

    (v0.99.96)

  • The error message was thrown out, because you forgot the semicolon after sampler. But there were two more issues. You defined parameters for Construct, but didn't define them for the effect. You defined a float4 front but tried to access it as frontTex.

    Here is the corrected code:

    // World recolor
    // Valerien
    // PS 2.0
    // Overlaps an object's color depending on its position in the screen
    
    //#PARAM float redAdd 0.1 : RedShift : Adds red to the object.
    float redAdd;
    
    //#PARAM float greenAdd 0.1 : GreenShift : Adds green to the object.
    float greenAdd;
    
    //#PARAM float blueAdd 0.1 : BlueShift : Adds blue to the object.
    float blueAdd;
    
    //special values extracted from construct
    texture ForegroundTexture;
    // texture BackgroundTexture;
    int boxLeft;
    
    //sampler
    sampler2D foreground = sampler_state
    {
    Texture = (ForegroundTexture);
        MinFilter = Point;
        MagFilter = Point;
        MipFilter = Point;
    };
    
    //ColorShift function
    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
    {
    float4 front = tex2D(foreground, Tex.xy);
    float3 colorShifter;
    
    colorShifter.r = redAdd;
    colorShifter.g = greenAdd;
    colorShifter.b = blueAdd;
    
    boxLeft.x *= 0.1;
    //sin and cos functions are used for
    front.rgb *= ((sin(boxLeft.x) - 2*cos(boxLeft.x)) * colorShifter.rgb)/colorShifter.rgb;
    
    return front;
    }
    
    //technique
    technique ConstructEffect
    {
        pass p0
        {
            VertexShader = null;
            PixelShader = compile ps_2_0 EffectProcess();
        }
    }[/code:3ft8mo3u]
    
    [b]EDIT[/b]
    
    

    Also, is there a way to get the position of the object passed through the shader ? And to get a time value from construct please ?

    I guess you already had a look at this page?

    The only "time value" you get is frameCounter, I'm afraid. Yes, it is not much...

    For positions you have

    boxLeft

    boxTop

    hotspotX

    hotspotY

    pixelWidth

    pixelHeight

    all expressed as a number from 0 to 1, relative to the display.

  • I know it and you know it, newt, but irbis doesn't. In fact, that's why he asked for help. I still think omitting one of the key probs is not helping, but confusing more.

    Anyway, I've made a cap with a nice 11-frame status display and editboxes to play around with different values for 'total' and 'current' while running the app. You will see how simple and yet versatile the formula is.

    Download: shipstatus.cap

tulamide's avatar

tulamide

Member since 11 Sep, 2009

Twitter
tulamide has 3 followers

Trophy Case

  • 15-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

17/44
How to earn trophies