Hello with all, here a tuto to create a system of walk under Game Maker.
Sprites: Ridges two files in the part ???sprites???. (Right Click on ???sprites???: Add Group) One of both will be called ???Walk???, and the other ???Stop???. In the first file (Walk), create a sprite called ???spr_marche_haut???. There put the sprites of the hero going upwards. Of the same ridges for the downwards going hero. He will be called ???spr_marche_bas???. Idem for the sprites where the hero will walk towards the left and the right-hand side. Logically, they will be called ???spr_marche_gauche??? and ???spr_marche_droite???. In the second file (Stop), create a sprite called ???spr_arr??t_haut???. There put the sprites of the hero in pause upwards. Of the same ridges for the hero stopped downwards. He will be called ???spr_arr??t_bas???. Idem for the sprites where the hero will be stopped towards the left and the right-hand side. Logically, they will be called ???spr_arr??t_gauche??? and ???spr_arr??t_droite???. (You can obviously replace the word ???stop??? by the word ???stop??? for example.) The sprites from now on are included in the play.
Programming: (Note:: All that is after ???//??? in Game Maker Langage is not taken into account. It is thus a good means of putting a comment to be more explicit.)
In the object of the character, create a vent ???create??? containing a code: global.link_pause=0;
Un event ?? Alarm 0 ?? code :
if image_index<10 {x-=8;alarm[0]=1}
else {sprite_index=spr_arr??t_gauche}
Un event ?? Alarm 1 ?? code :
if image_index<10{y-=8;alarm[1]=1}
else{sprite_index=spr_arr??t_droite }
Un event ?? Alarm 2 ?? code :
if image_index<10{y-=8;alarm[1]=1}
else{sprite_index=spr_arr??t_haut}
Un event ?? Alarm 3 ?? code :
if image_index<10{y+=8;alarm[3]=1}
else{sprite_index=spr_arr??t_bas}
(10 = number of sprite???)
Character object : ?? Step ??.
?? Execute a piece of code ??
// Up
// Go up
if (keyboard_check_direct(vk_up))
{
sprite_index = spr_marche_haut;
y-=3; // Vitesse = 3
}
// stop up
if (keyboard_check_released(vk_up))
{
sprite_index = spr_arr??t_haut;
y-=0;
}
// Down
// Go down
if (keyboard_check_direct(vk_down))
{
sprite_index = spr_marche_bas;
y+=3;
}
// Stop down
if (keyboard_check_released(vk_down))
{
sprite_index = spr_arr??t_bas;
y+=0;
}
// Left
// Go left
if (keyboard_check_direct(vk_left))
{
sprite_index = spr_marche_gauche;
x-=3;
}
// Stop left
if (keyboard_check_released(vk_left))
{
sprite_index = spr_arr??t_gauche;
x-=0;
}
// Right
// Go right
if (keyboard_check_direct(vk_right))
{
sprite_index = spr_marche_droite;
x+=3;
}
// Stop right
if (keyboard_check_released(vk_right))
sprite_index = spr_arr??t_droite;
x+=0;
}
**End of the tuto**
Good use.