Pages: 1
  Print  
Author Topic: snake revenge code examples  (Read 1113 times)
Offline (Unknown gender) gra
Posted on: May 23, 2013, 02:55:28 AM

Member
Joined: Feb 2013
Posts: 147

View Profile
 ;D 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
Code: [Select]
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
Code: [Select]
//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
 }
« Last Edit: May 23, 2013, 03:36:11 AM by gra » Logged
Pages: 1
  Print