1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Windows Single stream

Discussion in 'Programming' started by zzzzza1, Apr 5, 2018.

  1. zzzzza1

    zzzzza1 Member

    Joined:
    Jan 21, 2017
    Posts:
    33
    Hi all!

    I make long calculations and at this time I can not draw.

    Can I somehow display information about the state of calculations?

    Thank you in advance!
     
  2. RollyBug

    RollyBug Member

    Joined:
    Feb 23, 2018
    Posts:
    38
    Please be more specific. What do you mean by "I cannot draw?" Are you maybe not much of an artist or is something going on preventing you from drawing in-game? And what is "the state of calculations?"
     
  3. Cat

    Cat Member

    Joined:
    Jun 22, 2016
    Posts:
    70
    If I'm not mistaken, show_debug_message() should help here.
     
  4. zzzzza1

    zzzzza1 Member

    Joined:
    Jan 21, 2017
    Posts:
    33
    Let's say I use "while (1)", which calculate for one minute. While it's working, I can not use "Draw", since this is still one step.
    And I have a need to show how many percent of the calculations are performed from 100%
     
  5. the_dude_abides

    the_dude_abides Member

    Joined:
    Jun 23, 2016
    Posts:
    604
    Something that I do to see things being plotted during a for loop, is to put that data into a ds_list and then draw the list. However, this quickly leads to the screen filling up with information as steps are repeated.

    So that I could see everything that was happening I eventually decided to use the file write function, and save it to a text file instead. You won't be able to see it during the process, but you can open the file afterwards and have a permanent record of what has happened.

    It would be fairly slow to run in a game, but for the purposes of checking data and processes may help you.
     
  6. zzzzza1

    zzzzza1 Member

    Joined:
    Jan 21, 2017
    Posts:
    33
    Thanks for the advice, but I need to show the information along with the calculations.

    Is it possible to do this?
     
  7. the_dude_abides

    the_dude_abides Member

    Joined:
    Jun 23, 2016
    Posts:
    604
    You can see the calculations. Every element would need to be set to a variable, and then the outcome would need to be set to a variable. Then you put all of them into a ds_list add call, or whatever. Like this (I'm using a for loop for the example here, but it wouldn't really be different in practice with a while loop):

    for (a = 0; a < 1000; a++)
    {var length_left = 50 * a;
    var dir = 10 * a;
    var left_x = x + lengthdir_x(length_left, dir);
    var left_y = y + lengthdir_y(length_left, dir);
    ds_list_add(list, a, length_left, dir, left_x, left_y} // etc etc

    Whatever you want to know - set a variable to it, so it can be accessed. And if it can be accessed it can be put into whatever you want to store it, and then be drawn onscreen by looping through the storage.
     
  8. flyingsaucerinvasion

    flyingsaucerinvasion Member

    Joined:
    Jun 20, 2016
    Posts:
    2,088
    Nothing will be able to be drawn while the loop is running. So if you want some kind of progress report on the current status of your calculations, you'll need to break up your calculations into multiple parts. In each step event, pick up from where you left off in the previous step.
     
    RollyBug likes this.
  9. zzzzza1

    zzzzza1 Member

    Joined:
    Jan 21, 2017
    Posts:
    33
    Very sad, thank you!
     
  10. Hyomoto

    Hyomoto Member

    Joined:
    Jul 7, 2016
    Posts:
    1,060
    @flyingsaucerinvasion is right, you can do this but you have to solve your problem by solving it: the issue is you want to view the changes over time, that requires the process to take place over time in the program. In old versions of GM you could force a draw event, but you can not do that any more. That means instead of using a while loop, you need to use the step event as your loop. That way you can also perform draw events, thus visualize your data however you want.

    It's not hard, but it does require you to look at the problem from a practical angle, not an idealized one. Sometimes you have to write the code you need, not the code you want.
     

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