GMS 2 New Data Structures Series!

Discussion in 'Tutorials' started by Aaron Craig, Jan 25, 2018.

  1. Aaron Craig

    Aaron Craig Member

    Joined:
    Jun 20, 2016
    Posts:
    31
    GM Version: 1.4 & 2.
    Target Platform: All platforms.
    Download: NA
    Links: https://www.youtube.com/playlist?list=PLwfY1MeupeNYy9nvS5jjtQ8B9qo3hQHFd

    Introduction to Data Structures //I'll be going over what data structures are and why you shouldn't be afraid of them.
    Introduction to Arrays //Two part video, going in depth on 1D arrays with code and examples. Then covering 2D arrays with code and examples of for loops iterating over arrays.

    Projects on Google Drive

    Summary
    :
    Starting a new series on data structures in GameMaker Studio. The intro is up, and covers the basics of data structures in general, with some examples that include real life data structures. I'll be going over each data structure with in depth discussion and examples.
     
    Last edited: Jan 26, 2018
    SilentxxBunny likes this.
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,287
    For a for-loop-centric tutorial, above all you should be the one leading its proper use. Unfortunately, you aren't. Using the instance scope for temporary values like looping variables is an often underplayed bad rookie habit, and I'm disconcerted how little awareness of it there is about when it bites.

    This is the way you're doing it:
    Code:
    for (i = 0; i < array_length_1d(menu); ++i)
    This is the way it's supposed to be done:
    Code:
    for (var i = 0; i < array_length_1d(menu); ++i)
    Or better, save the return value in a local variable:
    Code:
    var isize = array_length_1d(menu);
    for (var i = 0; i < isize; ++i)
    I also propose that you inspect your project in the debugger's instance scope panel, once with your original loop and once with my loop. Your i sticks around taking up room, mine cleans up after itself. Think which one you'd rather look at in a more complex project where there may be many more different temporary values building up from various function calls.

    As a Q&A responder, I've lost count of the number of rookies claiming data structures are too hard. I'd love it if your videos could get them to shut up. But if it means they'll learn the no-var habit along the way and make a pig sty of their instance scopes, I'd have reservations about it.
     
    Gradius, Aaron Craig and Bentley like this.
  3. Bentley

    Bentley Member

    Joined:
    Jun 18, 2017
    Posts:
    765
    Edit: nevermind, silly question.
     
    Last edited: Jan 26, 2018
  4. Aaron Craig

    Aaron Craig Member

    Joined:
    Jun 20, 2016
    Posts:
    31
    You're absolutely right. I hadn't considered that, but it's important to do even the little things right. I looked at your example of recursion as well, which makes total sense. Although I don't see much recursion inside of GMS, it's still important to always be coding properly. I'll address that in my future videos, and start changing that myself.
     
  5. Kombowz

    Kombowz Guest

    Nice, thank you.
     

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