Jump to content


Photo

The For Loop


  • Please log in to reply
4 replies to this topic

#1 thatshelby

thatshelby

    GMC Member

  • GMC Member
  • 3823 posts
  • Version:GM8

Posted 31 August 2010 - 01:27 AM

  • Title: The Almighty For Loop
  • Description: A simple tutorial regarding the sometimes confusing for-loop.
  • GM Version: 8
  • Registered: No
  • File Type: .GMK
  • File Size: 106.18KB
  • File Link: http://dl.dropbox.co...42053/loops.gmk

Additional Info

There are three examples in this .gmk: one that shows how to draw a sprite, tiled, across the entire room, one showing how to draw an array, and one showing how to create, then draw the created array.
Code is pretty well commented.


If you see any flaws, please point them out!
If you have any trouble, PM me and I'll try to get to you with that.
Suggestions for another example? Leave a post here.

Thanks!
  • 1

#2 MrJackSparrow2

MrJackSparrow2

    GMC Member

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

Posted 31 August 2010 - 02:12 AM

Very useful to a new GML programmer. I would just add some more practical uses to using a for loop. Such as looping through a data structure, or show how to do a 2d array with a nested for loop.

Edit: just noticed you DID do a nested for loop. Sorry.

Edited by MrJackSparrow2, 31 August 2010 - 02:17 AM.

  • 0

#3 thatshelby

thatshelby

    GMC Member

  • GMC Member
  • 3823 posts
  • Version:GM8

Posted 31 August 2010 - 02:28 AM

Yes, hehe. Thanks for the kind words.

The problem is, I don't want to create a data structure. XD


  • 0

#4 ubervendroid

ubervendroid

    GMC Member

  • New Member
  • 17 posts

Posted 22 July 2011 - 11:24 AM

if you can make a for-loop in gmk can you make a while-loop?
  • 0

#5 thatshelby

thatshelby

    GMC Member

  • GMC Member
  • 3823 posts
  • Version:GM8

Posted 23 July 2011 - 07:22 AM

if you can make a for-loop in gmk can you make a while-loop?


Yup. While-loops are very simple.

while (statement-is-true) {
  //run some code
}


Careful, they will freeze up your game if you don't use it very well.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users