home *** CD-ROM | disk | FTP | other *** search
- class Slange extends Figur
- {
- var mc;
- var dybde;
- var iLufta;
- var skjerm_y;
- var hogrevendt;
- var nesteFrame;
- var brett_x;
- var bredde;
- var brett_y;
- var hogde;
- var i;
- var underlag;
- var roligH = 1;
- var roligV = 10;
- var angripH = 20;
- var angripV = 30;
- var angriper = false;
- var forsteKnockoutH = 120;
- var sisteKnockoutH = 123;
- var forsteFlatH = 140;
- var sisteFlatH = 148;
- var forsteKnockoutV = 130;
- var sisteKnockoutV = 133;
- var forsteFlatV = 150;
- var sisteFlatV = 158;
- var knock = false;
- var flat = false;
- var forsteSlaaH = 40;
- var sisteSlaaH = 78;
- var forsteSlaaV = 80;
- var sisteSlaaV = 118;
- var slaar = false;
- function Slange(mc, brett_x, brett_y, bredde, hogde)
- {
- super(mc,brett_x,brett_y,bredde,hogde);
- Figur.figurliste.push(this);
- this.mc.swapDepths(4200 + Figur.figurliste.length);
- this.dybde = this.mc.getDepth();
- this.iLufta = true;
- this.aks_y = 0.7;
- }
- function knockout()
- {
- if(!this.knock)
- {
- this.knock = true;
- _root.hit.start();
- if(Figur.helt.stokkeslaar || Figur.helt.kraftspark)
- {
- this.skjerm_y -= 15;
- this.iLufta = true;
- }
- else
- {
- this.fart_y -= 10;
- }
- this.iLufta = true;
- if(this.hogrevendt)
- {
- this.nesteFrame = this.posisjon = this.forsteKnockoutH;
- }
- else
- {
- this.nesteFrame = this.posisjon = this.forsteKnockoutV;
- }
- }
- }
- function flatUt()
- {
- this.flat = true;
- _root.hit.start();
- if(this.hogrevendt)
- {
- this.nesteFrame = this.posisjon = this.forsteFlatH;
- }
- else
- {
- this.nesteFrame = this.posisjon = this.forsteFlatV;
- }
- }
- function vedTreff()
- {
- if(Figur.helt.sparkar || Figur.helt.slaar || Figur.helt.stokkeslaar || Figur.helt.feirer)
- {
- this.knockout();
- }
- else if(!Figur.helt.knock && !Figur.helt.flat)
- {
- Figur.helt.knockout();
- this.slag();
- }
- }
- function slag()
- {
- this.slaar = true;
- _root.slyngelyd.start();
- if(this.hogrevendt)
- {
- this.nesteFrame = this.posisjon = this.forsteSlaaH;
- }
- else
- {
- this.nesteFrame = this.posisjon = this.forsteSlaaV;
- }
- }
- function visRiktigFrame()
- {
- if(!this.aktiv)
- {
- this.bliUsynlig();
- }
- else
- {
- if(Math.abs(this.brett_x + this.bredde / 2 - (Figur.helt.brett_x + Figur.helt.bredde / 2)) < 200)
- {
- if(Math.abs(this.brett_y + this.hogde - (Figur.helt.brett_y + Figur.helt.hogde)) < 100 && !Figur.helt.flat && !Figur.helt.knock)
- {
- this.angriper = true;
- }
- else
- {
- this.angriper = false;
- }
- }
- else
- {
- this.angriper = false;
- }
- if(!this.knock)
- {
- if(!this.slaar)
- {
- if(!this.flat)
- {
- if(!this.angriper)
- {
- if(this.brett_x + this.bredde / 2 > Figur.helt.brett_x + Figur.helt.bredde / 2)
- {
- this.hogrevendt = true;
- this.nesteFrame = this.roligH;
- }
- else
- {
- this.hogrevendt = false;
- this.nesteFrame = this.roligV;
- }
- }
- else if(this.hogrevendt)
- {
- this.nesteFrame = this.angripH;
- this.brett_x -= 5;
- this.i = 0;
- while(this.i < Figur.platformliste.length)
- {
- if(Figur.platformliste[this.i].treffVegg(this))
- {
- if(Figur.platformliste[this.i] != this.underlag)
- {
- this.brett_x += 5;
- break;
- }
- }
- this.i = this.i + 1;
- }
- }
- else
- {
- this.nesteFrame = this.angripV;
- this.brett_x += 5;
- this.i = 0;
- while(this.i < Figur.platformliste.length)
- {
- if(Figur.platformliste[this.i].treffVegg(this))
- {
- if(Figur.platformliste[this.i] != this.underlag)
- {
- this.brett_x -= 5;
- break;
- }
- }
- this.i = this.i + 1;
- }
- }
- }
- }
- }
- }
- if(this.slaar)
- {
- if(this.hogrevendt)
- {
- if(this.mc._currentframe < this.sisteSlaaH)
- {
- this.posisjon += 1;
- this.nesteFrame = this.posisjon;
- }
- else
- {
- this.slaar = false;
- }
- }
- else if(this.mc._currentframe < this.sisteSlaaV)
- {
- this.posisjon += 1;
- this.nesteFrame = this.posisjon;
- }
- else
- {
- this.slaar = false;
- }
- }
- if(this.flat)
- {
- if(!this.hogrevendt)
- {
- if(this.mc._currentframe < this.sisteFlatV)
- {
- this.posisjon += 1;
- this.nesteFrame = this.posisjon;
- }
- else
- {
- this.flat = false;
- }
- }
- else if(this.mc._currentframe < this.sisteFlatH)
- {
- this.posisjon += 1;
- this.nesteFrame = this.posisjon;
- }
- else
- {
- this.flat = false;
- }
- }
- if(this.knock)
- {
- if(!this.hogrevendt)
- {
- if(this.mc._currentframe < this.sisteKnockoutV)
- {
- this.posisjon += 1;
- this.nesteFrame = this.posisjon;
- this.brett_x -= 8;
- }
- else if(!this.iLufta)
- {
- this.knock = false;
- this.flatUt();
- }
- else
- {
- this.nesteFrame = this.sisteKnockoutV;
- this.brett_x -= 8;
- }
- this.i = 0;
- while(this.i < Figur.platformliste.length)
- {
- if(Figur.platformliste[this.i].treffVegg(this))
- {
- if(Figur.platformliste[this.i] != this.underlag)
- {
- this.brett_x += 5;
- break;
- }
- }
- this.i = this.i + 1;
- }
- }
- else
- {
- if(this.mc._currentframe < this.sisteKnockoutH)
- {
- this.posisjon += 1;
- this.nesteFrame = this.posisjon;
- this.brett_x += 5;
- }
- else if(!this.iLufta)
- {
- this.knock = false;
- this.flatUt();
- }
- else
- {
- this.nesteFrame = this.sisteKnockoutH;
- this.brett_x += 5;
- }
- this.i = 0;
- while(this.i < Figur.platformliste.length)
- {
- if(Figur.platformliste[this.i].treffVegg(this))
- {
- if(Figur.platformliste[this.i] != this.underlag)
- {
- this.brett_x -= 5;
- break;
- }
- }
- this.i = this.i + 1;
- }
- }
- }
- }
- }
-