Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// onCreate
- // this script will have all the variables needed for moving and colliding with tiles
- platformInit()
- // This is where we are creating the variables for the specific type of enemy, IE. shooting, jumping etc.
- enmTypeInit()
- // walking, idling
- spriteReg = sprTyupeReg
- // blinking
- spritehurt = sprTyupeHurt
- // blinking
- spriteDead = sprTyupeDead
- // add more sprites for jumping and falling and charging if that is nessecary, and reflect that in the switchCase onStep.
- // extra sprite states could always be present, just not triggered by the specific type of enemy.
- // last note, i will add this.
- // the variables needed for the enemy state, could be included in platformInit(), if so, renamed to enmInit()
- state = reg
- stateTimer = 0
- hp = 10
- deadTimer = 30
- /// onStep
- // the collision and movement code here, will stop if oPaus exists or if state is not regular state
- // 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
- if !instance_exists(oPaus) and state = reg {
- sPlatform()
- }
- //
- // the following code could be put into an enmScript()
- switch(state){
- // case regular state, if in regular state the enemy AI is applied
- case reg: sprite_index = spriteReg
- break;
- // case hurt state, this is triggered by oWeapon col with parEnm
- case hurt: sprite_index = spriteHurt
- stateTimer--
- if stateTimer <= 0 {
- state = reg
- }
- break;
- // play this code when the state is daed lol
- case dead: sprite_index = spriteDead
- deadTimer--
- if deadTimer <= 0 {
- instance_create(x,y,oExplosion1)
- dieSound = audio_play_sound(sndDead,1,0)
- audio_sound_pitch(dieSound,random_range(-.2,.2))
- instance_destroy()
- }
- break;
- }
- if hp <= 0 state = dead
- onCol > oWeapon //actually is on oWeapon onCol > enmParent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement