these things are in every programming language and should help you understand how they work
the examples are in GML(Game Maker Language)
1. Variables
variables are used to store simple data like a number or a word
and can be user defined in some cases.
the stored data can be changed to
Example:
- Code:
-
var xyz = 123
var word = "string"
2. if statements
a. if then statements
basically if every thing is before the "then" is true then the code will execute after it
or in between {} for some languages (that was basically a if then statement)
Example:
- Code:
-
var Money = 100
if Money < 100 then {i am broke}
3. loops
there are 2 kinds of loops, for loops and do loops
for loops are good if you want something to repeat for a certain number of times every time you execute it
Example:
- Code:
-
for( i = 0; i < 5; i += 1 )
{
show_message( "Hello!" )
}
//this will show the message hello 5 times
do loops are good if you are uncertain of how many times you are going to loop through the code
example:
- Code:
-
var index = 0
do
{
index = index + 1 \\math in programming is pretty much self explanatory
}until (index = 5)
//this will loop 5 times until it will stop
more to come......
each programming language has many other things but i will not cover those cause they are language specific this is the basics that all languages
use.