GML A GML Tutorial Series Focused on Coding Basics (not game dev)

Discussion in 'Game Design, Development And Publishing' started by samspade, Nov 26, 2019.

  1. samspade

    samspade Member

    Feb 26, 2017
    The idea of a GML tutorial series focused on the basics of coding, instead of a how to make 'x' game, has been brought up a couple times recently, and if no one else wants to do it, I think I might try. I've only got three years (slightly less) of hobbiest coding experience but I've taken the basics many times and in several languages (processing, javascript, c, python) and have some presenting/teaching experience in real life.

    My goal would be to make short (<10 min) YouTube videos that cover a single topic or portion of a topic. The hope would be that these videos could be used from start to finish as a basics of programming in GML or could be referenced individually for personal use or on the forums.

    I'm not promising to do this, and I won't if someone else has already started, but I've got some time in late December, so I thought that I would start compiling a list of topics that should be covered. If nothing else the list can serve as a guide for others.

    Tutorial List (ideas)

    • Using the Manual
    • Code formatting and style
    • Variables and Data Type
    • Variable Scope
    • Enums
    • Macros
    • Basic Operators
    • Operator Precedence
    • Boolean Logic
    • If/Else Statements
    • Switch Statements
    • Loops and Iteration
      • repeat
      • while /do until
      • for
      • breaking out
    • Functions
    • Scripts
    • Objects
      • Events
      • Inheritance
      • with
    • Event Order
    • arrays
    • data structures
      • ds_list
      • ds_map
      • ds_stack
      • ds_queue
      • ds_priority
      • ds_grid
    • Recursion
    • Custom Data Structures
      • Trees
      • Graphs
    • Asynchronous Calls
    • Buffers
    • Debugging
      • how to read error messages
      • how to use show_debug_message
      • how to use the debugger
    • Dealing with GML's blackbox nature

    The above aren't in any particular order. And many would need to be a series (e.g. loops and iteration). Let me know what topics you think should be covered.
    Last edited: Dec 6, 2019
  2. Cpaz

    Cpaz Member

    Jun 20, 2016
    That's actually a really cool idea!
    When I started, everything I learned was based off of example, nothing was explicitly "here's how this specific thing works in detail" so I think even veterans could make good use of a tutorial series like this!
    Points like data structures and enums are things I've literally only started using this year, so I think I personally could learn a lot from this, if it were to become a thing.
  3. FrostyCat

    FrostyCat Member

    Jun 26, 2016
    Having a tutorial series on the true basics of GML has since become one of my top wishlist items, given my recent burnout from Q&A. It's incredibly frustrating talking to rookies who lay claim to platformer code but have no idea how basic control structures or variables work. My late December is now tied up in my attempt to organize a tutorial porting jam, but I would love to support your initiative by reviewing your content once you get it started.

    I would recommend adding the following topics:
    • Asynchronous calls (Topics like this and this just drive me nuts personally, especially given how the Manual tells them to use the asynchronous events)
    • Tree structures and traversal (This is the one thing that made recursion click for me in university, 6 years after I learned to code)
    • GM-geared OOP (After GML 2020 comes out with GMS 2.3)
    • Finer points of with blocks and its scoping behaviour (Could be part of loops and iteration, but likely better in its own article)
    I also recommend delaying coverage of items that may be turned upside down by the GML 2020 update, in particular scripts, arrays and data structures. I have 2 libraries almost ready for release now, but held off because of how much better but drastically different GML 2020 will make them.
    Rob, IndianaBones and Cpaz like this.
  4. Toque

    Toque Member

    May 25, 2017
    These would be great.
  5. Calvert

    Calvert Member

    Dec 24, 2017
    I often enjoy the thought of programming as a hobby, but I am one who never spent enough time to properly appreciate the basics of the language, so my knowledge regarding programming with code is pathetic and my works are often unorthodox. I still use Studio 1.4 but I would consider allocating time and upgrading to Studio 2 just to have the ability to follow a solid tutorial series like this.
  6. samspade

    samspade Member

    Feb 26, 2017
    That might be a little ambitious of a hope.

    All those sound good and fit although GM-geared OOP I'd probably have to use for a bit.

    My guess is that unless this is very easy to do, which I doubt, as long as I don't start with those areas that will significantly changed with 2.3 those changes will happen before I get there. That said, part of the idea for this series would be that the chunks are small and contained meaning that if 2.3 is delayed or something I'd probably just go ahead and do what is true now and then redo those specific sections when 2.3 arrives.

    In general, I think I'll start working on some of these and see how it goes. But it'll probably be several weeks - my goal would be to have a couple ready to go towards the end of December. Since I'd like these to be correct, I'll post some form of them somewhere for review prior to making a video.
  7. Homunculus

    Homunculus Member

    Jun 20, 2016
    I’d love to see this happen. As you said, this would be a great help for the Q&A topics as a reference to direct people to when it’s clear that some basic skills are missing.

    I’d consider adding a section on Buffers and the File System (sandbox and file functions) though.

    I’m also available for code reviewing or anything you might need help with.
    samspade likes this.
  8. HeWhoShallNotBeNamed

    HeWhoShallNotBeNamed Member

    Nov 9, 2018
    This is a ridiculously good idea. I didn't use a lot of tutorials when I was first starting out, and only really started to learn about things like pathfinding and enumerators when I was looking up how to tackle specific sections of my current project. And even though I've gotten to the point where I mostly know what I'm doing, there are plenty of things that are probably pretty easy to understand that I have no clue about, simply because I haven't used them. A series like this would be good for intermediate-level users who would rather see a video that goes, "Here's what this function does, and here's what it could be used for" than one that goes "Here's how to add this feature to your game, here are functions that might help." While the manual gives example code, sometimes it isn't the best at describing when you would use that code.

    I would like to second the idea of covering Buffers, and also think sections on surfaces, JSON encoding, and accessors could be of help to a lot of people.
    samspade likes this.
  9. samspade

    samspade Member

    Feb 26, 2017
    Buffers are good, I've added it temporarily. Maybe json encoding. Accessors would probably be covered in their respective sections, but it might make sense to have them separate as well.

    I think for the first pass, I would probably not cover surfaces and file systems. In general I want to focus on things that are more universal between all languages. There are a few exceptions (e.g. GM objects and events) that are so core to how GMS works you can't avoid them, but for the most part I want to draw a distinction between the more fundamental elements of programming and the more difficult topics in GML specifically. I also want to keep what I attempt to start with doable, which means at least in part, that I already know the subject well enough to teach it. However, if it goes well, I might be interested in expanding to other topics.

    Rather than join the jam this weekend I decided to start working on this. At the moment my process is to create a Slide show and a GMS 2 project for a topic along with a shortened text version of the presentation. Once I get far enough along I'll make them available on a git repository for review.
  10. r_Svan

    r_Svan Member

    Nov 30, 2019
    I've probably gotten the bulk of my learning content (beyond the built-in help feature) from either Shaun Spalding or The Friendly Cosmonaut on youtube. I feel both of them have offered up some pretty good tutorials that explain some of the basics. Albeit, some of those good lessons are within a video about how to make a certain type of game...

    This sounds really good though, sounds like something I'd appreciate!
  11. samspade

    samspade Member

    Feb 26, 2017
    In working on the project, I found that a similar and pretty good version already exists (I learned a couple new things watching them). It is different enough in design and scope, that I'm still going to attempt my version, but I thought I would leave this here.

    Fundamentals Playlist

    If anyone watched/watches these, let me know what you did or did not like about them and I'll try to incorporate the feedback.
    jpcr and Cpaz like this.
  12. samspade

    samspade Member

    Feb 26, 2017
    IndianaBones likes this.
  13. samspade

    samspade Member

    Feb 26, 2017
    First video is up. I intended to have more done, but I've been having some issues getting my recording setup setup. I'm still having some issues, but I'm just going to start posting them as I make them and I'll probably go back and rerecord them as I get better at this (I can only record the same one so many times in a row before going crazy). I think going forward it makes the most sense to have comments in the tutorial forum post rather than here if they relate to the content. If you want to offer feedback on things like mic settings, editing, etc. that might make more sense here, but I'm fine either way (I just don't want the tutorial to get to bogged down in none content related messages).

    Tutorial Link

    All comments are fair game.
  14. Yal

    Yal GMC Memer GMC Elder

    Jun 20, 2016
    Relying on operator precedence just makes code harder to read and less portable (and it's not even consistent between every port of GML - I think HTML5 and Android has slightly different operator precendence). I'd recommend just telling people to use parantheses to make sure operators are done in the correct order, every time they mix operators.

    You forgot bitwise operators... lots of fun stuff there (binary flags, using ^= 1 to toggle between 0 and 1, etc)

    Also considering having a chapter on comments, that's the part most people seem to be really bad at in between the biggest tutorial names and code I've seen produced by professional people at work
    • Explain what the goal of a chunk of code implements on a higher level, not what every line does (i.e. "find all targets within range" is a good comment, "check if r < 350" is a bad comment, especially if it's right next to the line if(r < 350){)
    • Document ranges and other important properties for function arguments (e.g. will the function crash if you pass in an instance ID instead of an object ID?)
    • When you do some really weird hack, DOCUMENT IT so you won't accidentally fix it and cause bugs
    • Write comments first to structure up your code, THEN write the code
    • Using // to document things, /* */ to temporarily make code not do anything (since you can't nest /* */ comments)
    • When to use comments, when to use show_debug_message, when to use #region
    • Using JavaDoc tags and other tagging styles to make your comments carry metadata for documentation

    Also, for macros, it could be worth pointing out that you can have them ANYWHERE - in some cases your code becomes easier to read if you set macros in a random script instead of all in the same place (like the manual suggests), like if you use a switch-statement-based state machine and want to refer to states you want to jump to a lot (e.g. states that can be set in collision events with other objects, or by control objects) by a name tag instead of an integer number.
    samspade and Homunculus like this.
  15. samspade

    samspade Member

    Feb 26, 2017
    Thanks for the comments.

    Regarding operator precedence that is probably what will happen. I'm going to explain it in general, as it is important, but the GMS 2 manual says that nothing is sure but parenthesis. So I'll probably stick to that. And point out the reason for it - which as you stated is because it might be different between ports and updates.

    I'm probably not going to cover bitwise. At least not to start with.

    In the code style slides I have a few slides on comments where I should talk about all of those things. I added your points to the speaker notes so I'll remember to cover them. Although a few I think might make sense in other tutorials.

    The macros and enums tutorials will explain that they can be put anywhere, including in code that is never called.

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