Javascript bee games

Source: Internet
Author: User

<Body>
<Script language = "JAVAScript">
Var timerID = null;
Var patno = 1;
Var cr = "\ r \ n ";
Var spcf1 = "";
Var spcf2 = "";
Var spcf3 = "";
Var hitflag = 0;
Var score = 0;
Var selec = 0;
Var rsmiss = "";
Function array1 (arn ){
This. length = arn;
For (var ar1 = 0; ar1 <= arn; ar1 ++ ){
This [ar1] = 1 ;}
Return this;
}
Function init (){
Blankx = new array1 (63 );
For (var makeblank = 0; makeblank <63; makeblank ++ ){
Blankx [makeblank] = "";
For (var addBlank = 0; addBlank <makeblank; addBlank ++ ){
Balancer [makeblank] = balancer [makeblank] + "";
}
}
Faker = new array1 (24 );
Face = new array1 (2 );
Face [1] = "(O_O )";
Face [2] = "(o_o )";
Mestotal = new array1 (4 );
Interval1 ();
}
Function restarter (){
Inplay = 0;
Blankno = 0;
Totalblank = "";
Lr = 1;
Lowerlf = "";
Downlf = "";
Downno = 0;
Missilex = 99;
Missiley = 99;
Mychrx = 1;
Myblank = "";
Mymove = 0;
Selec = 1;
Starter ();
}
Function starter (){
Document. fmark. win. value = cr + cr
+ "Bee games" + cr
+ "Click launch to start the game ";
Selec = 1;
}
Function goleft (){
Mymove = 0;
Mychrx = mychrx-1;
If (mychrx <= 0) {mychrx = 1 ;}
}
Function goright (){
Mymove = 0
Mychrx = mychrx + 1;
If (mychrx> = 56) {mychrx = 55 ;}
}
Function golmax (){
If (inplay = 1) {mymove =-1 ;}
}
Function gormax (){
If (inplay = 1) {mymove = 1 ;}
}
Function fire (){
If (inplay = 0) {if (selec = 1) {selec = 9; inplay = 1; init ();}
} Else {
If (missiley = 99) {missiley = 18; missilex = mychrx + 3 ;}
}
}
Function gameover (){
Score = 0;
For (var enerme = 1; enerme <25; enerme ++ ){
If (faker [enerme] = 1) {score = score + 1 ;}
}
If (score = 0 ){
Document. fmark. win. value = cr + cr
+ "Congratulations! "+ Cr
+ "You stopped the enemy squad !! ";
} Else {
Document. fmark. win. value = cr + cr
+ "Game over" + cr
+ "" + Score + "invaders got through ";
}
Inplay = 0;
}
Function interval1 (){
If (missiley! = 99) {missiley = missiley-1 ;}
If (missiley <0) {missiley = 99 ;}
Mychrx = mychrx + mymove;
If (mychrx <= 0) {mychrx = 1 ;}
If (mychrx> = 56) {mychrx = 55 ;}
Blankno = blankno + lr;
Totalblank = balancer [balancer no];
If (blankno> = 20) {lr =-1; downno = downno + 1; blankno = 20 ;}
If (blankno <= 0) {lr = 1; downno = downno + 1; blankno = 0 ;}
If (downno >=12) {gameover ();}
Downlf = "";
For (var upperspc = 0; upperspc <downno; upperspc ++ ){
If (missiley = upperspc ){
Downlf = downlf + blankx [missilex] + "|" + cr;
} Else {downlf = downlf + cr ;}
}
If (inplay = 1 ){
Patno = patno + 1;
If (patno> = 3) {patno = 1 ;}
For (var addline = 1; addline <5; addline ++ ){
Mestotal [addline] = totalblank;
Rsmiss = "";
If (missiley = (downno + addline * 2-2 )){
If (blankno <= missilex ){
Hitflag = parseInt (missilex-blankno)/7, 10 );
If (hitflag <6 ){
If (missilex-blankno-(hitflag * 7)> = 1 ){
If (missilex-blankno-(hitflag * 7) <= 5 ){
If (faker [(addline * 6) + hitflag-5] = 1 ){
Faker [(addline * 6) + hitflag-5] = 0;
Missiley = 99;
}
}
}
} Else {
If (missilex> (blankno + 42 )){
Rsmiss = blankx [missilex-blankno-42] + "| ";
}
}
} Else {
Mestotal [addline] = blankx [missilex] + "| ";
If (missilex <(blankno-1 )){
Mestotal [addline] = mestotal [addline] + blankx [blankno-1-missilex];
}
}
}
For (var addfaker = 1; addfaker <7; addfaker ++ ){
If (faker [(addline * 6) + addfaker-6] = 1 ){
Mestotal [addline] = mestotal [addline] + face [patno];
} Else {mestotal [addline] = mestotal [addline] + "";}
}
Mestotal [addline] = mestotal [addline] + rsmiss;
}
Spcf1 = cr;
Spcf2 = cr;
Spcf3 = cr;
If (missiley = (downno + 1) {spcf1 = blankx [missilex] + "|" + cr ;}
If (missiley = (downno + 3) {spcf2 = blankx [missilex] + "|" + cr ;}
If (missiley = (downno + 5) {spcf3 = blankx [missilex] + "|" + cr ;}
Lowerlf = "";
For (var lowerspc = 0; lowerspc <(11-downno); lowerspc ++ ){
If (missiley = (downno + 7 + lowerspc )){
Lowerlf = lowerlf + blankx [missilex] + "|" + cr;
} Else {lowerlf = lowerlf + cr ;}
}
Myblank = blankx [mychrx];
Document. fmark. win. value = downlf + mestotal [1] + cr + spcf1
+ Mestotal [2] + cr + spcf2 + mestotal [3] + cr + spcf3 + mestotal [4]
+ Cr + lowerlf + myblank + "" + cr + myblank + "(^_^ )";
TimerID = setTimeout ("interval1 ()", 250 );
}
}
</Script>
<Center>
<Form method = post name = fmark>
<Table border = 1 cellspacing = 0 cellpadding = 0>
<Tr> <td align = center>
<Textarea name = win rows = 20 cols = 63 wrap = virtual> </textarea>
<Pre> <input type = button name = button value = "<-" onClick = "golmax () "> <input type = button name = button value =" launch "onClick =" fire () "> <input type = button name = button value ="-> "onClick =" gormax () "> </pre>
<Input type = button name = button value = "New Game" onClick = "restarter ()">
</Td>
</Tr>
</Table>
</Form>
</Center>
</Body>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.