using DT to add an amount over time.

0 favourites
  • 8 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Howdy y'all, so I'm trying to figure out something that I can't quite get to work. I have a variable I'm calling "PaddleSpeed" and its supposed to hold a whole number.

    I've been experimenting with the DT, trying to get said number but its not quite working.

    I tried:

    1: Everytick -> add to "Paddlespeed" -->round((dt+1)/2)

    2: Everytick -> add to "Paddlespeed" -->floor((dt+1)/2)

    however, when I check these, it always says 0. I'm assuming because the setup in both cases never breaks over one.

    What my goal is, to add "1" to "Paddlespeed" ever, say second and a half or two seconds. I've avoided the "Every X Seconds" command because if I remember right, using "DT" is more accurate or stable. Also, pausing the game will affect anything running of "DT" (if I remember right.)

    any help would be greatly appreciated.

  • To simplify yourself use "Timers" instead as they use already dt internally.

    On Timer "Increase Speed": 
    ------------ad 1 to "Paddlespeed"
    ------------Start Timer "Increase Speed" for 1.5 sec 
    
  • I've avoided the "Every X Seconds" command because if I remember right, using "DT" is more accurate or stable.

    You don't need to avoid "Every X seconds". It's already framerate independent, because as the name suggests, it works in seconds, not frames.

    If you want to make your own time counter based on dt, then just adding dt is all you need to do. I'm not sure what you're trying to achieve with the calculation round((dt+1)/2) - there's no need to change it, just add dt by itself, and that's essentially a time counter in seconds. But you may as well use 'Every X seconds' or the Timer behavior for convenience.

  • To simplify yourself use "Timers" instead as they use already dt internally.

    > On Timer "Increase Speed": 
    ------------ad 1 to "Paddlespeed"
    ------------Start Timer "Paddlespeed" for 1.5 sec 
    

    I've been looking into timers, but I'm not sure it would fix what I'm after. Question, in that code; does it add 1 to "Paddlespeed" every 1.5 secs? Or, would I end up with 1 and a half?

  • > I've avoided the "Every X Seconds" command because if I remember right, using "DT" is more accurate or stable.

    You don't need to avoid "Every X seconds". It's already framerate independent, because as the name suggests, it works in seconds, not frames.

    If you want to make your own time counter based on dt, then just adding dt is all you need to do. I'm not sure what you're trying to achieve with the calculation round((dt+1)/2) - there's no need to change it, just add dt by itself, and that's essentially a time counter in seconds. But you may as well use 'Every X seconds' or the Timer behavior for convenience.

    I think you might of just answered my question. The idea was, I wanted to add 1 to "Paddlespeed". However, just using DT gave me two issues. The first was it was way to fast. The second, was that I didn't get whole numbers.

    So, using DT raw would give me 1,2,3,4,5.

    What I wanted was 1....2....3....4....5; essentially a pause between each number. Also, instead of seeing numbers like 1.322, 2.345; I wanted whole numbers. That's why I was trying to use Floor and Round but those never worked.

    But what your saying is that Timers and "Every X Seconds" work the same as just running dt?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > To simplify yourself use "Timers" instead as they use already dt internally.

    >

    >

    >

    > > On Timer "Increase Speed": 
    > ------------ad 1 to "Paddlespeed"
    > ------------Start Timer "Paddlespeed" for 1.5 sec 
    > 

    I've been looking into timers, but I'm not sure it would fix what I'm after. Question, in that code; does it add 1 to "Paddlespeed" every 1.5 secs? Or, would I end up with 1 and a half?

    Sorry, I misspelt that you should start the timer with the same tag "Increase Speed" not the name of the variable.

    On Timer "Increase Speed": 
    ------------ad 1 to "Paddlespeed"
    ------------Start Timer "Increase Speed" for 1.5 sec 
    

    Yes, it will add 1 to "Paddlespeed" every 1.5 second

    The best and quickest way to find out is to test it:

    https://www.dropbox.com/s/afhw6d3smk3xizs/Timers2.capx?dl=0

    Test Both the "Every X Seconds" and the "Timers" and see which one you like more is the same, I prefer the Timer just because has that trigger and its easier to visualize that you running a timer because of the icon, but if you prefer "Every X Seconds" then that is a good option too as its the same, it's all by preference.

  • > > To simplify yourself use "Timers" instead as they use already dt internally.

    > >

    > >

    > >

    > > > On Timer "Increase Speed": 
    > > ------------ad 1 to "Paddlespeed"
    > > ------------Start Timer "Paddlespeed" for 1.5 sec 
    > > 

    >

    > I've been looking into timers, but I'm not sure it would fix what I'm after. Question, in that code; does it add 1 to "Paddlespeed" every 1.5 secs? Or, would I end up with 1 and a half?

    Sorry, I misspelt that you should start the timer with the same tag "Increase Speed" not the name of the variable.

    > On Timer "Increase Speed": 
    ------------ad 1 to "Paddlespeed"
    ------------Start Timer "Increase Speed" for 1.5 sec 
    

    Yes, it will add 1 to "Paddlespeed" every 1.5 second

    The best and quickest way to find out is to test it:

    https://www.dropbox.com/s/afhw6d3smk3xizs/Timers2.capx?dl=0

    Test Both the "Every X Seconds" and the "Timers" and see which one you like more is the same, I prefer the Timer just because has that trigger and its easier to visualize that you running a timer because of the icon, but if you prefer "Every X Seconds" then that is a good option too as its the same, it's all by preference.

    Ah! Bangers and Mash! Thank you so much for your patience and help as well as clarification. I'm going to experiment with the times and the file you gave me. My last question, so it functions with DT, so if I want to "pause" the game, would both be paused at that point in time? Then, if I continue time it continues from that point as well? I assume I would set "time scale" to 0 to pause.

  • > > To simplify yourself use "Timers" instead as they use already dt internally.

    > >

    > >

    > >

    > > > On Timer "Increase Speed": 
    > > ------------ad 1 to "Paddlespeed"
    > > ------------Start Timer "Paddlespeed" for 1.5 sec 
    > > 

    >

    > I've been looking into timers, but I'm not sure it would fix what I'm after. Question, in that code; does it add 1 to "Paddlespeed" every 1.5 secs? Or, would I end up with 1 and a half?

    Sorry, I misspelt that you should start the timer with the same tag "Increase Speed" not the name of the variable.

    > On Timer "Increase Speed": 
    ------------ad 1 to "Paddlespeed"
    ------------Start Timer "Increase Speed" for 1.5 sec 
    

    Yes, it will add 1 to "Paddlespeed" every 1.5 second

    The best and quickest way to find out is to test it:

    https://www.dropbox.com/s/afhw6d3smk3xizs/Timers2.capx?dl=0

    Test Both the "Every X Seconds" and the "Timers" and see which one you like more is the same, I prefer the Timer just because has that trigger and its easier to visualize that you running a timer because of the icon, but if you prefer "Every X Seconds" then that is a good option too as its the same, it's all by preference.

    AH, so it does start and stop from the point you "pause" the game. I made a simple test using the capx you gave me. Left click will set time scale to 0 and right will set it to 1. Great way to visualize the actual effect, thank you kindly again.

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