Advertisement
Guest User

Untitled

a guest
May 5th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /// onCreate
  2.    
  3.     // this script will have all the variables needed for moving and colliding with tiles
  4.     platformInit()
  5.  
  6.     // This is where we are creating the variables for the specific type of enemy, IE. shooting, jumping etc.
  7.     enmTypeInit()
  8.  
  9.     // walking, idling
  10.     spriteReg = sprTyupeReg
  11.     // blinking
  12.     spritehurt = sprTyupeHurt
  13.     // blinking
  14.     spriteDead = sprTyupeDead
  15.     // add more sprites for jumping and falling and charging if that is nessecary, and reflect that in the switchCase onStep.
  16.     // extra sprite states could always be present, just not triggered by the specific type of enemy.
  17.     // last note, i will add this.
  18.  
  19.     // the variables needed for the enemy state, could be included in platformInit(), if so, renamed to enmInit()
  20.     state = reg
  21.     stateTimer = 0
  22.     hp = 10
  23.     deadTimer = 30
  24.  
  25.  
  26.  
  27.  
  28.  
  29.     /// onStep
  30.  
  31.  
  32.  
  33.     // the collision and movement code here, will stop if oPaus exists or if state is not regular state
  34.     // this is so we can paus the movement incase the enemy is hurt, dying or charging before an attack or attacking or game is paused
  35.         if !instance_exists(oPaus) and state = reg {
  36.             sPlatform()
  37.         }
  38.  
  39.  
  40.     //  
  41.  
  42.  
  43.     // the following code could be put into an enmScript()
  44.     switch(state){
  45.         // case regular state, if in regular state the enemy AI is applied
  46.         case reg: sprite_index = spriteReg
  47.         break;
  48.  
  49.         // case hurt state, this is triggered by oWeapon col with parEnm
  50.         case hurt: sprite_index = spriteHurt
  51.                    stateTimer--
  52.                    if stateTimer <= 0 {
  53.                         state = reg
  54.                     }
  55.    
  56.         break;
  57.         // play this code when the state is daed lol
  58.         case dead: sprite_index = spriteDead
  59.                     deadTimer--
  60.                     if deadTimer <= 0 {
  61.                         instance_create(x,y,oExplosion1)
  62.                         dieSound = audio_play_sound(sndDead,1,0)
  63.                         audio_sound_pitch(dieSound,random_range(-.2,.2))
  64.                         instance_destroy()
  65.                     }
  66.         break;
  67.     }
  68.  
  69.    
  70.     if hp <= 0 state = dead
  71.  
  72.    
  73.  
  74.  
  75.     onCol > oWeapon //actually is on oWeapon onCol > enmParent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement