"Dear friends! If you enjoyed the video, please give it a like and subscribe to the channel. We strive to share with you the lost knowledge of the great prophet and teacher of GameDev, Sempiternal Rain. With these lessons, you'll learn the GameMaker Studio game engine. Learn programming in Game Maker Language (GML). And in the future, you'll be able to easily create virtually any 2D game for video consoles, computers, and phones."
Description and tips below. Enjoy!
VK Community:
sempiternalrainnotes - Sempiternal Rain: Notes
(Chat, news, and community available - Subscribe!)
Games created by the great prophet of the gaming industry, Sempiternal Rain. You can purchase them on Steam:
1. "Socialism Simulator"
2. "ReLinked"
-------------------------------------------------------------------
Lesson Title:
GameMaker Studio - Lesson #9: Arrays and the For Loop
Lesson Description:
In this video, you'll learn about one-dimensional and two-dimensional arrays, as well as the For loop.
Timecodes:
00:00 - Introduction
00:15 - Example: Simple Inventory
00:33 - How to Write an Array
00:52 - What is an Array
02:27 - How to Write an Array Using a Loop
06:40 - Printing an Array
10:00 - Checking if a Cell is Empty
10:44 - Two-Dimensional Array
14:50 - Explanation of How a Loop Works
-------------------------------------------------------------------
*****
name_mass[0]="any_name"; //array entry
*****
One-dimensional array
Ob_array
*Create //when creating an object
for(i = 0; i<4; i++) //loop, from cell 0 to cell 3
{
global.inventory[i]="none"; //inventory, array (visible everywhere)
}
*Draw //draw on screen
for(i = 0; i<4; i++) //loop, from 0 to 3
{
draw_text(30+60*i,30,global.inventory[i]); //display on screen
}
Object2
*Left Pressed //if the left mouse button is pressed
for(i = 0; i<4; i++) //loop from cell 0 to cell 3
{
if(global.inventory[i]="none") //check if the cell is empty
{
global.inventory[i]="sword"; //write to the "sword" array cell
instance_destroy(); //delete the Object2 object
exit; //exit the loop
}
}
*****
Two-dimensional array
Ob_array
*Create //when creating an object
for(i = 0; i<4; i++) //loop through the i-th row, from cell 0 to cell 3
{
for(j = 0; j<4; j++) //loop through the j-th column, from cell 0 to cell 3
{
global.inventory[i][j]=k; //two-dimensional inventory array (visible everywhere)
}
}
*Draw //draw on screen
for(i = 0; i<4; i++) //loop through row i, from cell 0 to cell 3
{
for(j = 0; j<4; j++) //loop through column j, from cell 0 to cell 3
{
draw_text(30+60*i,30+60*j,global.inventory[j][i]); //display on screen
}
}
Object2
*Left Pressed //if the left mouse button is pressed
for(i = 0; i<4; i++) //loop through row i, from cell 0 to cell 3
{
for(j = 0; j<4; j++) //loop through column j, from cell 0 to cell 3
{
if(global.inventory[i][j]="none") // cell is empty in a two-dimensional array
{
global.inventory[i]="sword"; //write to array cell "sword"
instance_destroy(); //delete Object2
exit; //Exit the loop
}
}
}
*****
Notes:
1. Array numbering starts at 0
/ ...