
in the develop of bass learn game , i have discovered "mod", anyway i rewrite the snap snake movement...
first of my examples is :" snake head , snap movement in base of key press"
CREATE
tempo_max=6 //time limit
tempo=0 //time variable
step_tempo=1 //step of increase time variable
direzione=0 //direction move
lh_sprite=32 //sprite leight-height 32 the sprite is 32x32 remember of center sprite origin
STEP
//SET DIRECTION IN BASE KEYBOARD
if (keyboard_check_pressed(vk_right)) {direzione=0}
if (keyboard_check_pressed(vk_left)) {direzione=1}
if (keyboard_check_pressed(vk_down)) {direzione=2}
if (keyboard_check_pressed(vk_up)) {direzione=3}
//INCREMENT TIME IN BASE TO STEP_TEMPO (SPEED STEP)
tempo+=step_tempo
//SETTING MOVEMENT IN BASE TO INPUT GIVE= KEYBOARD + TIME
if (x mod lh_sprite ==0 and tempo>=tempo_max and direzione=0)
{
x+=lh_sprite ;
tempo=0
}
if(x mod lh_sprite ==0 and tempo>=tempo_max and direzione=1)
{
x-=lh_sprite ;
tempo=0
}
if(y mod lh_sprite ==0 and tempo>=tempo_max and direzione=2)
{
y+=lh_sprite ;
tempo=0
}
if(y mod lh_sprite ==0 and tempo>=tempo_max and direzione=3)
{
y-=lh_sprite ;
tempo=0
}