Log in
Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest None
Most users ever online was 105 on Sat Apr 10, 2021 4:09 pm
Statistics
We have 23 registered usersThe newest registered user is mariwaigjka
Our users have posted a total of 303 messages in 86 subjects
The Basic GML Code
3 posters
Page 1 of 1
The Basic GML Code
Lesson 1 CH 1
the basic code is saying a message, lets begin
{
show_message('Hello World")
}
that creates a dialog message for GM to read, simple.
TIP: always put brackets above and below on some code.
Now lets try something a bit harder.
if keyboard_check(vk_right)
{
x+=3
}
Now you see that I didn't put brackets above "If" in GM if is asking a question to GM and only following what goes when the parameters are qualified, so if is asking GM if the the right arrow key is being pushed, then when the key is pressed X meaning the horizontal postion, move the player right, + means relative, and if you want to move the player left use the same code but change it a little.
if keyboard_check(vk_left)
{
x+=-3
}
You put a negative before any X type of situation, meaning to go the opposite direction of X.
That is the first chapter in the GML basic code tutorial.
the basic code is saying a message, lets begin
{
show_message('Hello World")
}
that creates a dialog message for GM to read, simple.
TIP: always put brackets above and below on some code.
Now lets try something a bit harder.
if keyboard_check(vk_right)
{
x+=3
}
Now you see that I didn't put brackets above "If" in GM if is asking a question to GM and only following what goes when the parameters are qualified, so if is asking GM if the the right arrow key is being pushed, then when the key is pressed X meaning the horizontal postion, move the player right, + means relative, and if you want to move the player left use the same code but change it a little.
if keyboard_check(vk_left)
{
x+=-3
}
You put a negative before any X type of situation, meaning to go the opposite direction of X.
That is the first chapter in the GML basic code tutorial.
OmegraKai- Founder
- Number of posts : 141
Age : 39
Mem. Points :
Mod. Points :
Warning Bar :
Talk About your Self! : I am A Gamer!!
Registration date : 2008-04-06
Character sheet
Rate your Gaming ability's!:
(74/100)
Re: The Basic GML Code
CH: 2
creating objects in GML is very easy just type this.
{
instance_create(x,y,object)
}
thats the simplest of all code actually.
Now lets make a harder one, lets say we wanted to create a object every 20 seconds. follow these steps
CREATE
alarm[0] = 20
ALARM 0
{
instance_create(x,y,object)
}
now every 20 seconds a instance is created. Now lets try repeating instances
repeat(10)
{
instance_create(x,y,object)
}
this way you have more control of how many you want.
that concludes our Chapter for today.
creating objects in GML is very easy just type this.
{
instance_create(x,y,object)
}
thats the simplest of all code actually.
Now lets make a harder one, lets say we wanted to create a object every 20 seconds. follow these steps
CREATE
alarm[0] = 20
ALARM 0
{
instance_create(x,y,object)
}
now every 20 seconds a instance is created. Now lets try repeating instances
repeat(10)
{
instance_create(x,y,object)
}
this way you have more control of how many you want.
that concludes our Chapter for today.
OmegraKai- Founder
- Number of posts : 141
Age : 39
Mem. Points :
Mod. Points :
Warning Bar :
Talk About your Self! : I am A Gamer!!
Registration date : 2008-04-06
Character sheet
Rate your Gaming ability's!:
(74/100)
Re: The Basic GML Code
Thank you for that, I didn't know any code until this...
AracnoX- Moderator
- Number of posts : 46
Age : 28
Location : Wherever I feel like being.
Mem. Points :
Mod. Points :
Warning Bar :
Talk About your Self! : Why do you want to hear this go away!
Registration date : 2008-07-15
Character sheet
Rate your Gaming ability's!:
(0/0)
Re: The Basic GML Code
I'm glad I helped once I fully know code I make a whole thing about it.
OmegraKai- Founder
- Number of posts : 141
Age : 39
Mem. Points :
Mod. Points :
Warning Bar :
Talk About your Self! : I am A Gamer!!
Registration date : 2008-04-06
Character sheet
Rate your Gaming ability's!:
(74/100)
Re: The Basic GML Code
yeah this is going to help me make my new upcoming game
sebalex11- Newbie
- Number of posts : 34
Age : 29
Location : someweverywherehere
Mem. Points :
Mod. Points :
Warning Bar :
Talk About your Self! : i like to make games and play them
Registration date : 2008-07-17
Character sheet
Rate your Gaming ability's!:
(10/100)
Re: The Basic GML Code
CH 3
okay now were going to move to copying functions of off of D&D system. lets start with the TAB "Move"
D&D tab lesson 1
Move
The first thing you see is a red arrow direction cube, this is for moving directions, we have actually already covered this but here is a refreshment.
{
x+=3
speed = 3
}
x+= moving right, change it to x+= -3 and that we'll become moving left. change X to Y to make it up and down.
speed just means what type of speed you want to have, you don't have to do this but it controls it more.
second is a blue direction cube, this may be a little harder but here. ( I don't know if its harder, because I don't know how to do it... )
next is a move towards type of function which in code is this.
{
move_towards_point(x,y,3)
}
3 means the speed that you want the object to move to the point x,y. if you want it to move to a object,
use this
{
move_towards_point(obj_player.x,obj_player.y,3)
}
Now the other two, with the red arrow pointing down and sideways, is simple.
{
hspeed
}
is horizontal speed
{
vspeed
}
is vertical speed.
as a example vspeed can be used for jumping to stop.
here.
if vspeed > 0 && !place_free(x,y+vspeed)
{
move_contact(270)
}
vspeed = 0
this means if vspeed is less than 0 and there is a SOLID at position of vertical vspeed, move towards the object at direction 270 (down) then when it touches it vspeed = 0.
that's a pretty hard code. but an example none the less.
now onto gravity. this one is simple, in step events you to have gravity,
{
gravity = 0.5
gravity_direction = 270
}
meaning the gravity = 0.5 and the direction is down.
that concludes our lesson for now.
okay now were going to move to copying functions of off of D&D system. lets start with the TAB "Move"
D&D tab lesson 1
Move
The first thing you see is a red arrow direction cube, this is for moving directions, we have actually already covered this but here is a refreshment.
{
x+=3
speed = 3
}
x+= moving right, change it to x+= -3 and that we'll become moving left. change X to Y to make it up and down.
speed just means what type of speed you want to have, you don't have to do this but it controls it more.
second is a blue direction cube, this may be a little harder but here. ( I don't know if its harder, because I don't know how to do it... )
next is a move towards type of function which in code is this.
{
move_towards_point(x,y,3)
}
3 means the speed that you want the object to move to the point x,y. if you want it to move to a object,
use this
{
move_towards_point(obj_player.x,obj_player.y,3)
}
Now the other two, with the red arrow pointing down and sideways, is simple.
{
hspeed
}
is horizontal speed
{
vspeed
}
is vertical speed.
as a example vspeed can be used for jumping to stop.
here.
if vspeed > 0 && !place_free(x,y+vspeed)
{
move_contact(270)
}
vspeed = 0
this means if vspeed is less than 0 and there is a SOLID at position of vertical vspeed, move towards the object at direction 270 (down) then when it touches it vspeed = 0.
that's a pretty hard code. but an example none the less.
now onto gravity. this one is simple, in step events you to have gravity,
{
gravity = 0.5
gravity_direction = 270
}
meaning the gravity = 0.5 and the direction is down.
that concludes our lesson for now.
OmegraKai- Founder
- Number of posts : 141
Age : 39
Mem. Points :
Mod. Points :
Warning Bar :
Talk About your Self! : I am A Gamer!!
Registration date : 2008-04-06
Character sheet
Rate your Gaming ability's!:
(74/100)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|