WEB开发网
开发学院网页设计JavaScript javascript Game 阅读

javascript Game

 2007-11-27 17:59:02 来源:WEB开发网   
核心提示:<HTML><HEAD><TITLE>JS FALCON</TITLE><SCRIPT LANGUAGE=JavaScript><!--var Flimit=9 //for TEST PLAY (Fire Limit 0 to 9)var BossTM

<HTML>

<HEAD>
<TITLE>JS FALCON</TITLE>

<SCRIPT LANGUAGE=JavaScript>
<!--
var Flimit=9               //for TEST PLAY (Fire Limit 0 to 9)
var BossTM=0               //        (Boss test mode = 1)
var BossLM=700              //        (Boss appearance)
var Easy=0

var timerID = null
var TimeCounter = 0
var INT = 25               //interval
var k=0                 //key buffer
var X=100                //my chr XY
var Y=100
var DX=0                 //my chr move
var DY=0
var IX=0
var IY=0
var SDX=0
var SDY=0
var SIX=0
var SIY=0
var Endflg=0               //Game End Flag
var ff=0                 //fire flag
var fc=0                 //fire counter
var FX = new Array(12)          //fire XY
var FY = new Array(12)
var bf=0                 //bomb flag
var bc=0                 //bomb counter
var BX=0                 //bomb XY
var BY=-100
var BDX=0                //bomb fall speed
var BDY=0
var Cname = new Array(2)         //clash image No
var Bflag=0               //bomb FLAG
var GND=0                //scroll flag
var EFX = new Array(8)          //enemy fire XY
var EFY = new Array(8)
var EVX = new Array(8)          //enemy fire speed
var EVY = new Array(8)
var Fmax = 3               //enemy fire max
var EMX = 200              //enemy missile XY
var EMY = 284
var PTN = 0               //enemy missile paturn
var Mvx = 0               //enemy missile speed
var Mvy = 0
var mCount = 100             //missile timer
var EX = new Array(20)          //enemy XY
var EY = new Array(20)
var CH = new Array(2)          //cobra Yspeed
var CW = new Array(2)          //cobra Xspeed
var tmp1 = 0
var tmp2 = 0
var Endflg = 1
var Bossflg = 0
var BossX = 0              //Boss X
var BossH = 0              //Boss Canon H (170 to 220)
var CanonX=-200             //Canon X,Y,counter
var CanonY=-200
var CanonC=0
var Bossflg=0
var tmpBF=0
var sf=0                 //Start flag
var spCOUNT=0


//IE check
 systm=
 ver=navigator.appVersion
 len=ver.length
 for(iln=0;iln<len;iln++) if(ver.charAt(iln)==() break
 systm = ver.charAt(iln+1).toUpperCase()


// ---------------------------------
// ======== Main function ==========
// ---------------------------------

function interval1(){
 clearTimeout(timerID)

 // --------- Clash image clear -----------
  ccount0=ccount0+1
  if (ccount0 >= 2){cla0.left=-100}
  ccount1=ccount1+1
  if (ccount1 >= 2){cla1.left=-100}
  ccount2=ccount2+1
  if (ccount2 >= 2){cla2.left=-100}

 // --------- Enemy fire level up -----------
 TimeCounter=TimeCounter+1
 with (Math){Fmax=floor(TimeCounter/100)+3}
 if (Fmax >= Flimit){Fmax=Flimit}
 if (TimeCounter == Blimit){Bossflg=1;tmpbgc=100;tmpbgf=0}
 if (Bossflg >= 1){
  tmpbgc=tmpbgc-5
  if (tmpbgc >= 0){
  if (systm!=C){}
  }
  if (tmpbgf == 0){
  if (tmpbgc <= 0){
   if (systm!=C){
   tmpbgf=1
   }else{
   tmpbgf=1
   }
  }
  }
  tmpBF=0
  for (tmp1=0; tmp1<10; tmp1++){
  if (EX[tmp1] >= -50){tmpBF=1}
  }
  if (tmpBF == 0){BossMode()}
 }


 // --------- GND move ----------
 GND=GND-1;if (GND <= -16){GND=0}
 GNDs.left=GND


 // ---------- Mig23 move  enemy No =0,1,2  Layer No =27,28,29 ---------
 with (Math) {
  for (tmp1=0; tmp1<3; tmp1++){
  EX[tmp1]=EX[tmp1]-5
  if (EX[tmp1] <= -30){
   if (floor(random()*12) == 3 ){
   if (Bossflg == 0){EX[tmp1]=400;EY[tmp1]=floor(random()*12)*20+20}
   }
  }
  spMOV(27+tmp1,EX[tmp1],EY[tmp1])
  with (Math){if (floor(random()*5) == 3 ){Efire(EX[tmp1],EY[tmp1])}}
  }
 }

 // ---------- cobra move  enemy No =3,4,5  Layer No =30,31,32 ----------
 if (TimeCounter >= 300){
  with (Math) {
  for (tmp1=3; tmp1<6; tmp1++){
   EX[tmp1]=EX[tmp1]-CW[tmp1-3]
   if (EY[tmp1] <= 5){CH[tmp1-3]=2;CW[tmp1-3]=4}
   if (EY[tmp1] >= 240){CH[tmp1-3]=-2;CW[tmp1-3]=2}
   EY[tmp1]=EY[tmp1]+CH[tmp1-3]
   if (EX[tmp1] <= -30){
   if (floor(random()*12) == 3 ){
    if (Bossflg == 0){EX[tmp1]=400;EY[tmp1]=floor(random()*12)*20+20}
   }
   }
  spMOV(27+tmp1,EX[tmp1],EY[tmp1])
  with (Math){if (floor(random()*5) == 3 ){Efire(EX[tmp1],EY[tmp1])}}
  }
  }
 }

 // ---------- shilka move  enemy No =6,7,8  Layer No =33,34,35 ----------
 if (TimeCounter >= 200){
  with (Math){tmpTM=TimeCounter-floor(TimeCounter/100)*100}
  if (tmpTM <= 40){tmpTMX=3}else{if (tmpTM <= 70){tmpTMX=1}else{tmpTMX=-1}}
  for (tmp1=0; tmp1<3; tmp1++){
  EX[tmp1+6]=EX[tmp1+6]-tmpTMX
  if (EX[tmp1+6] <= -30){
   if (EX[6] <= 365){
   if (EX[7] <= 365){
    if (EX[8] <= 365){
    if (Bossflg == 0){
     with (Math){if (floor(random()*40) == 3 ){EX[tmp1+6]=400}}
    }
    }
   }
   }
  }
  spMOV(33+tmp1,EX[tmp1+6],EY[tmp1+6])
  with (Math){if (floor(random()*5) == 3 ){Efire(EX[tmp1+6],EY[tmp1+6])}}
  }
 }

 // ---------- gecko move  enemy No =9  Layer No =36 ------------
 if (EX[9] <= -600){if (Bossflg == 0){EX[9]=400}}
 EX[9]=EX[9]-1;if (EX[9] <= 250){EX[9]=EX[9]-4}
 if (EX[9] == 365){EMX=EX[9]+7;EMY=EY[9]-10;mCount=0}
 if (EX[9] == 310){EMX=EX[9]+7;EMY=EY[9]-10;mCount=0}
 if (EX[9] == 255){EMX=EX[9]+7;EMY=EY[9]-10;mCount=0}
 spMOV(36,EX[9],EY[9])

 // ---------- bomb move -------------
 if (bf == 1){BX=X;BY=Y+30;bc=1;bf=0;BDX=12}
 if (bc == 1){
  BDY=BDY+2
  if (BDY == 10){
  spMOV(45+Bflag,-100,-100)
  Bflag=1
  }
  if (BDY >= 10){BDX=BDX+3;BX=BX+BDX}
  BY=BY+BDY;tmpBMX=-100;tmpBMY=-100
  for (tmp2=0; tmp2<10; tmp2++){
   if (BX >= EX[tmp2]-30){
   if (BX <= EX[tmp2]+16){
    if (BY >= EY[tmp2]-3){
    if (BY <= EY[tmp2]+16){
     tmpBMX=BX-8;tmpBMY=BY-4
    }
    }
   }
   }
  }
  if (BY >= 284){tmpBMX=BX-8;tmpBMY=244}
  if (tmpBMX != -100){
  spMOV(45+Bflag,-100,-100)
  spMOV(50,tmpBMX,tmpBMY)
  Bflag=0;ccount2=0;bc=0;BY=-100;BDX=0;BDY=0
  for (tmp2=0; tmp2<10; tmp2++){
   if (BX >= EX[tmp2]-56){
   if (BX <= EX[tmp2]+40){
    if (EY[tmp2] >= tmpBMY-18){
    if (EY[tmp2] <= tmpBMY+63){
     spMOV(33+tmp2,-100,-100)
     spMOV(Cname[cflag],EX[tmp2],EY[tmp2]-6)
     if (cflag == 0){ccount0=0}else{ccount1=0}
     cflag=cflag+1;if (cflag >= 2){cflag=0}
     EX[tmp2]=-100;FX[tmp1]=500;score=score+50
    }
    }
   }
   }
  }
  }
  spMOV(45+Bflag,BX,BY)
 }

 // ---------- My fire move -------------
 if (ff == 1){
  FX[fc]=X;FY[fc]=Y+12
  fc=fc+1;if (fc >= 13){fc=0}
  ff=0
 }
 for (tmp1=0; tmp1<13; tmp1++){
  FX[tmp1]=FX[tmp1]+32
  for (tmp2=0; tmp2<10; tmp2++){
  if (FX[tmp1] >= EX[tmp2]-8){
   if (FX[tmp1] <= EX[tmp2]+32){
   if (FY[tmp1] >= EY[tmp2]-8){
    if (FY[tmp1] <= EY[tmp2]+19){
    spMOV(27+tmp2,-100,-100)
    spMOV(Cname[cflag],EX[tmp2],EY[tmp2]-6)
    if (cflag == 0){ccount0=0}else{ccount1=0}
    cflag=cflag+1;if (cflag >= 2){cflag=0}
    EX[tmp2]=-100;FX[tmp1]=500;score=score+10
    }
   }
   }
  }
  }
  spMOV(tmp1+1,FX[tmp1],FY[tmp1])
 }


 // ---------- Enemy Fire/Missile Move ---------
 Efmove()
 Emiss()

 // ---------- my chr move -----------
 tmpIX=IX+SIX;if (tmpIX >= 1){tmpIX=5+Easy}
 tmpIY=IY+SIY;if (tmpIY >= 1){tmpIY=5+Easy}
 tmpDX=DX+SDX;if (tmpDX >= 1){tmpDX=5+Easy}
 tmpDY=DY+SDY;if (tmpDY >= 1){tmpDY=5+Easy}
 X=X+tmpIX-tmpDX
 Y=Y+tmpIY-tmpDY
 if (X >= 368){X=368}
 if (X <=  0){X=  0}
 if (Y <=  0){Y=  0}
 if (Y >= 25

Tags:avascript Game

编辑录入:coldstar [复制链接] [打 印]
赞助商链接