Couldn't find this anywhere on the forum...

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • First off, I'd like to apologize if I'm just plain missing this somewhere else on the forum, but I've been looking for an hour and have had no luck.

    I've got a very basic day/night cycle in a project of mine, as well as a random chance of "rain" at the start of each day. I'm portraying the changes in time by using the "set color filter" on all of my tiles, but here's the thing, I want to be able to tell construct to fade between the filters...how do I do this?

    I want to be able to pick a point in my day/night cycle, and have construct change the color filter gradually over time so that it hits the final filter setting at the time in the cycle that I want it to.

    Thank you in advance...

  • If you right click on the part that lets you set the color you will get a context menu asking "use expression.

    You can click that, and in the in the box put the expression rgb(r,g,b) with the r,g,and b in parenthesis set to your color.

    After that you'll need a counter something like:

    rgb(r+variable,g+variable,b+variable)

    add 1 to variable

    You'll want to add to the values as rgb(255,255,255) equals white, and rgb(0,0,0) equals black.

  • what about if its not a straight fade with gray, right now I'm using slightly tinted filters, over cast is a straight gray and night is a blue gray, and is there anyway to set it up using timedelta maybe? I know ABOUT timedelta, but I really have no idea how to use it

  • Filter on all tiles ? Isn't it better to just fill the viewable area with a tiledbackground (you can paint a 1-2px width gradient as texture)? Then you just have to change it's opacity with a function, like :

    + Function: On function "FadeOut"
       + System: Repeat 100 times
         + System: Is global variable 'Opac' Less than 100
             -> Wait: Delay 10 ms
             -> System: Add 1 to global variable 'Opac'
             -> TiledBackground: Set opacity to global('Opac')[/code:2kt3afzb]
    
    Well, something like that anyway, i guess.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm using the filters because it allows me more control over the colors as well as it seems to appear to maintain more of the detail in the tiles than an overlay does, might just be my eyes playing tricks on me, it just seems that way.

  • Well you dont have to set all colors at the same time, but to set them separately you'll need multiple variables.

    rgb(lerp(r+variablea,255,1-0.5^timedelta),lerp(g+variableb,255,1-0.05^timedelta),lerp(b+variablec,255,1-0.5^timedelta)

    add to variablea 0.5

    add to variableb 1.5

    add to variablec 0.05

    And you can also vary the timing on the timedelta multiplier.

  • ok, the specific numbers I'm dealing with are...

    Day = rgb(255,255,255) - white

    *if it rains (which is a random chance) day then fades quickly to

    Overcast = rgb(127,127,127) - mid/dark gray

    either Day or Overcast then needs to fade to

    Night = rgb(45,57,60)

    so I need a function that can recalculate itself based on whether or not the rain is active, so I need two events, one that goes from Day to Night over a set amount of time (which I need to be able to change easily to fine tune the feel of the change), and one that goes from Day to Overcast to Night over a set amount of time.

    I guess what I really need to know is how to get construct to do the math from rgb(a,b,c) to rgb(x,y,z) over t milliseconds

    and have a become x, b become y, and c become z all at the same time regardless of the distance between each pair

  • yeah, lerp and timedelta just wooshed right over my head haha

    edit: I really appreciate all the help so far though lol, at the very least you guys are getting me to think through the problem a bit, my shortcomings are definitely in programming calculations as I've never been a coder (I couldn't even learn VB :$)

  • Newt did all the work

    I'm not a coder either... actually i don't even know how to use lerp hahaha... haha.

  • If I could understand the meaning behind the syntax and the specifics of what the syntax is referring to then I could understand what I'm doing lol, but yeah, I realize it must not be that hard a problem to solve. What I'm trying to do seems pretty straight forward, I'm just not sure what commands/syntax to use to get construct to do it. I friggin love construct by the way lol. I'm in University going for a BA in Digital Media and they're trying to find an alternative to Flash to use for teaching basic game production and interactive motion media. I think I may have one of the instructors sold on Construct 2 once it gets proper functionality lol

  • It helps to not think of it as coding, for me its more like thinking of it as an idea, or mental construct.

    What you needed was a graduated timer, and lerp does that, among many other things.

    So basically all your doing is saying I'm going to put a graduated timer in here, and input the values I want to use.

    Or perhaps you could even think of it as a plugin, within a plugin.

    The nice thing about Construct is that, that's exactly how it's set up. It can handle all the syntax for you, and it gives you a list via the user interface of all the possibilities.

    Think of it like a WYSIWYG, but instead of what you see, its what you think.

    Check out the Wiki, there's a list of all the expressions, and luckily if you have any questions you can ask here.

    http://sourceforge.net/apps/mediawiki/construct/index.php?title=System_Expressions

  • thats perfect newt, thank you

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)