GM:S 1.4 Simple Stopwatch/Timer

Discussion in 'Programming' started by John Assounga, Jul 23, 2016.

  1. John Assounga

    John Assounga Member

    Joined:
    Jul 10, 2016
    Posts:
    5
    Hi Guys,

    I'm making a simple racing game and I would like to know how to display a stopwatch.
    It can literally just start from 0:00:00 and go up, no fancy sprites.

    I've looked all over and a lot of people seem to be doing a countdown timer but not a stopwatch, could anyone help me out please.

    Regards!
     
  2. Morseton

    Morseton Member

    Joined:
    Jun 20, 2016
    Posts:
    122
    create event:
    minutes = 0;
    seconds = 0;
    steps = 0;

    step event:
    steps += 1;
    if steps >= room_speed
    {
    steps = 0;
    seconds += 1;

    if seconds >= 60
    {
    seconds = 0;
    minutes += 1;
    }
    }

    this can give you an idea how to make a stopwatch
     
  3. tienhagioi

    tienhagioi Guest

    Use delta_time , your timer more exactly
     
  4. The Shatner

    The Shatner Member

    Joined:
    Jun 25, 2016
    Posts:
    116
    tienhagioi is totally right, if you don't use delta_time your timer may have a "delay with real life", because the hardware may sometimes fail to deliver fps = room_speed. Delta-timing is essential!
    I'd just like to add that, according to the optimization guide, GM actually does multiplication faster than division, so if your game is going to have a lot of processing, maybe you could make it like this:
    Code:
    secs += (delta_time*0.000001)*room_speed;
     
  5. BlueDeath

    BlueDeath Guest

    A question about delta_time. Can I use it to measure the seconds (well...miliseconds) between two event?
     
  6. Remix The Idiot

    Remix The Idiot Member

    Joined:
    Sep 29, 2017
    Posts:
    15
    how do we show the timer? Like on the upper left of the screen per say.
     
  7. Bingdom

    Bingdom Googledom

    Joined:
    Jul 1, 2016
    Posts:
    1,678
    No, it's more to do with in-between steps.

    draw_text
    You can specify the coordinates.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice