ME FIRST GAMES
Menu
games for me and you
![]() A loop statement allows YOU to execute a group of statements multiple times. 💪They are very powerful, especially if you need to execute a task N times or iterate over many objects. ⭐️ foreach loop 📌 Executes a block of statements for each instance in an array, list, or any IEnumerable. 👍 You'll see this loop often, using it to perform the same task for multiple objects. ⭐️ for loop 📌 This loop allows you to initialize variables and change them after each iteration until a condition is false. 👍 Use this if you need to keep track of the current index in an array. 👍 Good if you just need to iterate over any numbers. ⭐️ while loop 📌 Simply executes a block of statements until a condition is false. The condition is checked before the first iteration. 👍 Good for running tasks until some state has changed. 👍 e.g. Move player until they are dead. Eat food until full. ⭐️ do while 📌 Similar to the while loop, however, the condition is checked after the first iteration. 👍 Use this when you have a task you always want to run before the loop condition. 👍 e.g. Player enters input, if the input is not valid then try again, else exit the loop. ⭐️ Loops are both fun and powerful tools at your disposal. ⭐️ You may struggle with learning loops, that's ok. Things will click after hours of practice. ⭐️ If you find yourself repeating the writing them the same code over and over, consider a loop. ➡️ Follow @mefirstgames for more game dev tips.⠀ ➡️ Free Unity Tools: https://www.mefirstgames.com/hierarchy-comments.html⠀
1 Comment
|
Me First Games is an independent game studio dedicated to creating unique and bizarre video games.
Red MatterStar Impact is an upcoming adventure platformer coming to PC, Mac, and Linux.
Archives
April 2021
Categories |
Copyright (c) 2020 Me First LLC
|