Jump to content


Photo

A GML tutorial


  • Please log in to reply
32 replies to this topic

#1 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 08 June 2010 - 09:58 PM


A GML tutorial
Hi there. I have been in this community for quite a while, and most of you have been quite helpful for the few problems I've had. This is my contribution to the community, my thanks, and I hope you find it as useful as I may have found it when I first started learning GML.

Note: I have abandoned this tutorial as I no longer use GameMaker. If someone would like to take charge, please PM me. I could even turn it into a wiki for you, if you like.

I hope you enjoy it and find it useful.

Take good care in this walk of life.
Stewart.

Search Tags
  • GMCTUTORIAL
  • GMCGML

Edited by icuurd12b42, 13 December 2011 - 11:58 PM.

  • 2

#2 Canite

Canite

    Canigget

  • GMC Member
  • 1358 posts
  • Version:GM8

Posted 20 June 2010 - 02:48 AM

Hey, this tutorial is great! You did a very nice job of explaining all the parts of using arrays and in a nice simple way. Arrays always confuse me when I try to understand other people using them, so I needed a nice simple example to help me understand it and this did the job :) I needed this because I'm planning on using a 2d array for a metroidesque map I'm making, so if you want to help with that, I wouldn't mind and maybe you can add it to the tutorial example.

p.s. I read the whole pdf and.. I love tennis too! haha

edit: By the way I figured out the map thing and its very cool. That double for loop method is awesome! :D

Edited by Canite, 20 June 2010 - 06:45 PM.

  • 0

#3 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 20 June 2010 - 09:37 PM

I'm glad you liked it! I was starting to get worried it was buried under mountains of other tutorials! Lol.
Lol, tennis is awesome :) By the way, you joined the GMC on my birthday :)
Thanks for your nice comments :)
  • 0

#4 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 29 July 2010 - 10:59 PM

I've just added an online version of this tutorial, for the people who don't like downloading stuff ;)

It can be found here. Again, any comments, bugs or anything, just say so! Thanks! Have a nice day and keep on whistlin'!!!
Posted Image

Edited by Stew :), 01 August 2010 - 08:20 PM.

  • 0

#5 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5417 posts
  • Version:GM:Studio

Posted 30 July 2010 - 09:49 AM

Preferably not the step event, because that uses lots of memory

What you are doing is writing over the same variable, that will take a bit prossesing power but not any more memory since you are re-writing over the old memory.

Here is another way of looping thru arrays with just 1 variable:
var i;
for(i=0;i<array_size;i+=1)// 
  array[i mod ww, i div ww]=0;
And one question many ask is how to get the size of the array.. which is something the user need to keep track of himself or use a data structure instead.

Your example download comes with the gmk backupfile and the pdf original. which are both unessesary..

And your example says, press start when you need to press enter, and the text in the last one is outside the view..

Other then that, good work ^^
  • 0

#6 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 30 July 2010 - 10:41 AM

Thanks very much for your constructive criticism!!!! I'll edit those tomorrow, thanks!

Here is another way of looping thru arrays with just 1 variable:

var i;
for(i=0;i<array_size;i+=1)// 
  array[i mod ww, i div ww]=0;

Erm, you haven't told us the value of "ww" ;). And wouldn't this only allow both "indexes" of the array to have the same value? Forgive me if I'm wrong ;). But nice job, I never would have thought of that ;). I'll add it in :)

- Stewart
  • 0

#7 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5417 posts
  • Version:GM:Studio

Posted 30 July 2010 - 05:49 PM

Oh .. Well, I was gonna put it into the comment in the above line, I use ww and hh for width and height, in this case it is how many slots you want in width.

and yeah, that loop is just to set all slots to the value 0, just like the one you used 2 for loops, speedvise you should choose 2 for loops.. did a test:
for(a=0;a<hh;a+=1)
  for(b=0;b<ww;b+=1)
    var1[a,b]=0;
38 VS 46 seconds (with 1000000 repeats)
for(a=0;a<ss;a+=1)
  var1[a mod ww,a div ww]=0;

And a explaination about div and mod .. pretty mutch as it was explained to me:

if a players want to make teams with b players on each team, then these will return:
a div b - how many teams there will be
a mod b - how many that will be without a team

7 div 2 = 3 // examples
9 mod 4 = 1

and if the b was 3 and you incrase a all the time, then you will get this array pattern:

0 div 3 = 0 // div
1 div 3 = 0
2 div 3 = 0

3 div 3 = 1
4 div 3 = 1
5 div 3 = 1

0 mod 3 = 0 // mod
1 mod 3 = 1
2 mod 3 = 2

3 mod 3 = 0
4 mod 3 = 1
5 mod 3 = 2
  • 0

#8 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 01 August 2010 - 08:23 PM

Wicked method, thanks :). I'll totally claim it as my own ;). (just kidding, would never do anything like that)...

Now I know what mod is. If you didn't notice, I was trying to conceal that fact :P

Thanks again for your advice!
  • 0

#9 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 15 November 2010 - 04:04 AM

Bump. I changed the topic to include the full scope of my gml tutorial, not only the array part.
  • 0

#10 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 02 December 2010 - 08:47 PM

another bump :)
  • 0

#11 AlexR2

AlexR2

    GMC Member

  • Banned Users
  • 197 posts
  • Version:Unknown

Posted 03 December 2010 - 01:04 AM

Ahh good tutorial, too bad it's useless for me now... Since i know ALL of that.
I learned arrays from a friend of mine who was teaching me how his code worked. iw as like "wtf is the array for then!" and he was like "oh yea so that gun group won't run out of ammo" and then it just hit me full force. tutorials never helped me for some reason, only from my own experience

#12 Zargy

Zargy

    GMC Member

  • GMC Member
  • 189 posts
  • Version:GM:Studio

Posted 03 December 2010 - 01:53 AM

Sir,
Posted Image

On a more serious note, this is a good tutorial.
  • 1

#13 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 03 December 2010 - 03:51 AM

Thanks guys :)
"This thread is now diamonds"
What on earth does that mean lol? :)
  • 0

#14 petermark1234

petermark1234

    GMC Member

  • New Member
  • 5 posts

Posted 04 December 2010 - 06:02 AM

There is a bit of one within Game Maker. Go to Help > Contents > The Game Maker Language (GML) and start reading. You can also visit at any time.Well, GML is kinda tricky if you're new to programming. I recommend doing all of the tutorials(except for the multiplayer one) on the official website. Article
Once you complete those you'll have an understanding of programming. They don't directly teach GML, but they give you the concepts of programming, so GML should be easier to understand.
What you basically need to know about GML is what each function does, how to use it, and how to combine them to make more efficient functions. What I did was just download a few examples and look at the GML. There's nothing wrong with that because they usually explain what each part of the GML does for the game.
  • 0

#15 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 04 December 2010 - 07:22 AM

Yeah, there isn't anything wrong with (almost) any methods. If you can learn that way, brilliant! As long as you learn :). I'm just trying to make it easier for those of us who don't learn that way :).
I found the manual doesn't explain it very well for my tastes. It used too much complex language and I found it difficult to know where to start (this is all from my experience from when I started learning it, which was ages ago).
Take care :)
  • 0

#16 Extra

Extra

    GMC Member

  • New Member
  • 1 posts

Posted 06 December 2010 - 11:35 AM

This is an amazing guide.. I've actually comprehended a few things that I couldn't understand before.
Really thanks for making this guide. It has helped out a lot for me and I'm sure it has for many people.
Keep up the great work!
  • 0

#17 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3230 posts
  • Version:Unknown

Posted 29 June 2011 - 02:27 PM

the site is now down
  • 0

#18 Stew :)

Stew :)

    GMC Member

  • GMC Member
  • 148 posts

Posted 30 June 2011 - 10:04 PM

Whoopsey daisy, my bad. I moved my site without even thinking of the sub domains. I think I fixed it now, although there's no styling on the site so it looks real bad. It'll probably fix itself within a day or two.

Thanks for notifying me ;)
  • 0

#19 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 17028 posts
  • Version:GM:Studio

Posted 01 July 2011 - 12:46 PM

I have closed this topic due to the fact that none of the links from the main page work... all give a 404 error. If you fix this then feel free to report the topic and ask for it to be re-opened.
  • 0

#20 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14446 posts
  • Version:GM:Studio

Posted 05 July 2011 - 12:44 AM

Unlocked and moved to rejected as per new approval process
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users