Basic Fundamentals of GML

B

Beef Erikson

Guest
GM Version: v1.4.1763
Target Platform: ALL
Download: Project Files
Links: N/A

Summary:
Greetings and I hope you find this informative! I created this for reference/learning for myself and figured it may be useful to others for reference/those who are just learning GML.

Tutorial:
Once you open the project up in gamemaker (download project above), browse the objects folder.
All basic programming functions/fundamentals will be listed there.

Simply open up 'room0' under the folder rooms, navigate to the objects tab,
select which object you'd like to see an example of and click on the map to place it. At that point, you can run to see the obj and/or scripts in action.

I highly recommend modifying and playing around with these objects so that you may have a better understanding of what they do.

I've tried to comment things as best as I can. However, if anyone runs into a question regarding this tutorial, please reply to thread and I'll be sure to help how I can.

Thanks and code on!
Beef Erikson

Edit 11-27-16: Updated files and clarified a few things. Huge thanks to FrostyCat for pointing out all my errors.
 
Last edited by a moderator:

chance

predictably random
Forum Staff
Moderator
I approved this... somewhat reluctantly. Because I'm not sure what you're trying to achieve. Or what audience this is aimed at.

It doesn't qualify as a tutorial, because many of the examples are provided without detailed explanation. And where explanation is provided, it seems to assume the reader already understands that particular programming structure, and just needs an example of how GM employs it.

That said, some of the examples extend what the manual provides. So they might be useful to intermediate programmers looking for more examples of usage, beyond the manual. So perhaps some users will find it useful.
 
Last edited:
B

Beef Erikson

Guest
yeah I wasn't entirely certain how useful this would be to anyone... I wrote that up myself for reference / while I was learning. Figured I'd spread it just in case someone want some clarification on how GM handles certain operations.

Debated on even posting it but hopefully someone finds it useful!
 

FrostyCat

Member
I'd wish that when people post guides teaching GML, they'd set better examples and be stricter about their style.
  • In scr_example, you have a script that is meant to take a fixed number of arguments but received them using the array form (argument[0] and argument[1]). This won't enforce the fixed number of arguments.
  • In obj_conditionals, you are teaching single = for comparisons, a clearly deprecated syntax.
    Code:
    varFour = varOne == varTwo || varThree = 8;
  • In obj_scope, you presented instance variables as "available object-wide". Not distinguishing instances from objects causes a large number of easily preventable headaches for novices.
  • In obj_scope2, you relied on instance order to make the reference to global.myVariable work. This is a brittle setup that also causes novices a lot of headaches.
  • In obj_functions, you said show_message() must take strings as arguments, which is no longer true in GMS 1.2+. You also repeatedly passed real arguments to show_message() throughout the project. Don't be a hypocrite.
  • In obj_while_dountil_loops, you compared Boolean values to true and false, a tell-tale sign of rookie work. This just shows how deficient you are about how expressions are evaluated.
  • In obj_2d_array, you left holes in your array declaration but tried accessing them anyways. This is poorly defined behaviour.
  • In obj_alarms, once again you used single = for comparisons, and you started the alarm cycle by hacking it into the Step event instead of just using the Create event.
  • In obj_keyboard_ord, more comparisons to true and false.
 
B

Beef Erikson

Guest
I appreciate the (very helpful) constructive criticism. I'm still rather new to this and am simply trying to share as I learn.
I'll be updating that file; while I don't necessarily appreciate the tone, I certainly appreciate the time spent correcting me.
 
B

Beef Erikson

Guest
I'd wish that when people post guides teaching GML, they'd set better examples and be stricter about their style.
  • In scr_example, you have a script that is meant to take a fixed number of arguments but received them using the array form (argument[0] and argument[1]). This won't enforce the fixed number of arguments.
  • In obj_conditionals, you are teaching single = for comparisons, a clearly deprecated syntax.
    Code:
    varFour = varOne == varTwo || varThree = 8;
  • In obj_scope, you presented instance variables as "available object-wide". Not distinguishing instances from objects causes a large number of easily preventable headaches for novices.
  • In obj_scope2, you relied on instance order to make the reference to global.myVariable work. This is a brittle setup that also causes novices a lot of headaches.
  • In obj_functions, you said show_message() must take strings as arguments, which is no longer true in GMS 1.2+. You also repeatedly passed real arguments to show_message() throughout the project. Don't be a hypocrite.
  • In obj_while_dountil_loops, you compared Boolean values to true and false, a tell-tale sign of rookie work. This just shows how deficient you are about how expressions are evaluated.
  • In obj_2d_array, you left holes in your array declaration but tried accessing them anyways. This is poorly defined behaviour.
  • In obj_alarms, once again you used single = for comparisons, and you started the alarm cycle by hacking it into the Step event instead of just using the Create event.
  • In obj_keyboard_ord, more comparisons to true and false.
Thanks again for all your help. Updated the file since the holiday is over; I believe I fixed everything you covered here. I learned a bit fixing these, so I really do appreciate you taking the time to point all this out to me.
 
Top