1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Question - Code Game Speed question

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Novithian, Nov 2, 2016.

  1. Novithian

    Novithian Member

    Joined:
    Nov 2, 2016
    Posts:
    7
    So I understand that we no longer set the room_speed individually, but using game_set_speed now. The documentation says that game_set_speed requires only 1 argument, the speed you're wanting to set. BUT the editor is asking for 2 arguments, which obviously the documentation for game_set_speed doesn't explain. I'm just wondering what is this second argument "type".
    [​IMG]

    [​IMG]

    [​IMG]
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,978
    Yep, that doc will be updated in the next update. Changes were made and I didn't have time to squeeze that one in for the initial Beta build.

    To quote the soon-to-be-updated docs:

    For example:

    Code:
    game_set_speed(60, gamespeed_fps);
    Hope that helps!
     
    Blackened, Phil Strahl and Novithian like this.
  3. Yazuka

    Yazuka YoYo Games Staff GMC Elder

    Joined:
    Apr 15, 2016
    Posts:
    53
    Hey there,

    The functions are expecting either gamespeed_fps or gamespeed_microseconds as their secondary arguments.

    We'll look into getting this fixed in the manual.
     
    Blackened and Novithian like this.
  4. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,978
    You've been ninja'd... :p
     
  5. Novithian

    Novithian Member

    Joined:
    Nov 2, 2016
    Posts:
    7
    :cool:

    Thanks for the quick responses!
     
  6. Ludorverr

    Ludorverr Member

    Joined:
    Jun 20, 2016
    Posts:
    33
    Does game speed behave differently than room_speed?

    Curious that the default setting is still 30 considering the traps new developers have fallen into, like hard-coding their entire game around 30 (because it's the default value) and being stuck with it. Hyper Light Drifter comes to mind.
     
  7. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,978
    Game speed is essentially the same as room speed, only it is global and not on a per-room basis. As for it being at 30, that's simply because GM users are accustomed to it being at 30 and for increased compatibility with 1.4 projects.
     
    Novithian likes this.
  8. Drewster

    Drewster Member

    Joined:
    Jun 21, 2016
    Posts:
    222
    Obviously not something that matters that much, but why have two ways to set it -- which are some simple math apart from each other? .. just curious.
     
  9. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,978
    Okay, so GMS2 has a better image editor and vastly improved visual scripting (DnD), and we are expecting to attract more people to the program from different fields and tools... and some of those people will be used to working in frames per second, and others will be used to working in frames per game tick. So, this simply is a convenience to help make transitioning from other tools and backgrounds into GMS easier. :)
     
    NazGhuL likes this.
  10. Zeralith

    Zeralith Member

    Joined:
    Nov 2, 2016
    Posts:
    29

    Attached Files:

  11. hdarren

    hdarren Member

    Joined:
    Jun 21, 2016
    Posts:
    280
    What is the difference? Does this mean for example that if you use the micro-seconds method then you can allow players to set their own game speed without it affecting animations/alarms/etc?
     
  12. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,978
    There is no difference. BOTH will set the speed that the game tries to maintain. If you use 30 FPS, then the game will try to maintain a speed of 30 frames per second. If you set 33333 MPF (microseconds per frame), then the game will try to maintain each frame at 33333 microseconds. The end result is the same... it's exactly the same as setting the room speed previously, only now it affects the whole game and not just individual rooms.
     
  13. hdarren

    hdarren Member

    Joined:
    Jun 21, 2016
    Posts:
    280
    If they are the same then that seems like pointless clutter to me. I imagine the majority of people will use seconds because that's what GM has always used so why change it by adding a pointless extra arguement? Why can't people just get used to using how GM does it or write 30*1000 or just add game_set_speed_micro()? Why make it more cluttersome for the vast majority because the minority are lazy? Especially beause this means everybody will have to change that function now when importing an old project.
     
  14. NPT

    NPT Guest

    Because peole who use delta-time like the granularity of working microseconds.
     
    Drewster likes this.
  15. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,978
    Laziness has nothing to do with it. It's about previous knowledge and habit. We want to (and CAN) accomodate the two different methods so why not? Also, "everybody will have to change that function"??? What function? it's new in GMS2 so nobody has to change anything and just use it as they wish with the option that suits them best. :)
     
  16. Baku

    Baku Member

    Joined:
    Jun 21, 2016
    Posts:
    11
    Accustomed? Sure. Also fairly annoyed.

    It'd be awesome if there at least was a setting in the Preferences, where we could set the default game speed for future projects. Even if it started at 30, it'd only require a one-time change by me to have all my future things default to 60, compared to having to go in and set every project to 60 manually like I do now. And those who are content with making unresponsive games would be able to go on with their lives like nothing ever happened.

    Going through the entire Preferences the other day, and seeing the insane amounts of things we can fiddle with now, I had honestly expected to find something like that, but nope


    Well damn, scratch that. The default options of new projects seem to be copied over from a "base" project in C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.0.1.16\BaseProject, and it seems we can simply change this project to our liking (such as setting it to 60fps) and all new ones will inherit the changes :D:D:D
     
    Last edited: Nov 20, 2016
  17. Drewster

    Drewster Member

    Joined:
    Jun 21, 2016
    Posts:
    222
    Lol okay. :) I guess that's a good answer.
     
  18. Drewster

    Drewster Member

    Joined:
    Jun 21, 2016
    Posts:
    222
    Yikes! hard-coding your whole game around a fixed value sounds like..... not best practice? Bummer that.
     
  19. Oranjoose

    Oranjoose Guest

    Actually, @hdarren is correct here. It is a basic principle of UI/UX design that it is more usable when the thing behaves as the user expects it to.

    In this case, if you show a developer the game_set_speed function, whether they are the seconds or microseconds type, they will figure it out very quickly if it takes one argument (say, in seconds). With that required second argument using global names as flags, it is virtually impossible for anyone to figure out how to use the function without seeing some kind of documentation.

    This is just one reason that it is actually more usable and "accommodat[ing]" for either type of user.

    To prevent breaking changes, I recommend making the second argument of game_set_speed optional, where the default is in seconds. This is the best of both worlds.
     
  20. User1331

    User1331 Guest


    This function doesn't seem to work by me, maybe I'm doing something wrong

    I have this in the step event:

    var g_speed = 0
    if keyboard_key_press(vk_up) then g_speed = 0
    if keyboard_key_press(vk_down) then g_speed = 1





    if g_speed = 0 then game_set_speed(30,gamespeed_fps)
    if g_speed = 1 then game_set_speed(10,gamespeed_fps)


    And It changes absolutely nothing.
     
  21. Dog Slobber

    Dog Slobber Member

    Joined:
    May 20, 2017
    Posts:
    283
    It's a bug in your code.

    Every step you're resetting it back to 30 because the default for var g_speed (no key being pressed) is the same as when vk_up is presed.
     

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