⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 battle_on_the_river_kwai_n60.java

📁 J2ME War game Thank you very much.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import java.util.*;
import java.lang.*;
import java.io.*;

import javax.microedition.rms.*;

import com.nokia.mid.sound.*;
import com.nokia.mid.ui.*;

import javax.microedition.io.*;
import javax.microedition.media.control.*;
import javax.microedition.media.*;

public class BATTLE_ON_THE_RIVER_KWAI_N60 extends MIDlet {
    Display display;
    Intro intro;
    GameCanvas obj;
    SubmitPoints subPts;
    ShowScore shwScr;

    FieldMover mover;
    Timer timer;

    //vars for game
    public int gamePaint, arrowNum;
    public boolean checkPause, yes, islv, prevl; //islv: mark if pass level; prevl:mark prevel
    public Random gran, ran;
    int rtmp, r, time, stime, hour, min, sec, life, g_time, enemy, lv, page, cl; //ti time;

    String store, temp1, name1, timestr, locstr, infostr, emailstr, contrystr;
    String str[] = {"Allen", "Weaver", "Sachs", "Rickman ", "Enrico", "Fern"};
    int[] scr = {0, 0, 0, 0, 0, 0};
    public int temp, xch;

    public Entername n1 = new Entername();
    public TextField name, email, country, birth;


//-----------------------------------------------------------------
    /*
      byte abyte0[] = new byte[200];
      Sound snd[]=new Sound[4];
      String sndnm[]={"/intro.ott","/fall.ott","/hit.ott","/over.ott"};
     */

    //vars for menu
    public Image hash, loading, tri, ii, in, itr, sta_bar, arrowr, joystick,
    arrowg;
    private Image bbg4, blood;


    int selectx, selecty, selectno, up, down, right, left, fire, w, h, introcnt,
    x, y, start, endp, x1, y1, k, chr, lpp, inc, init, cntri, cntrj, im,
    tdif, gc, menuSelectIndex;
    byte sound = 0, a, count, j, game, no, xy, gameend, fs, gmov, prc, nkpr;
    boolean kpr, dpt;
    int len[] = {1, 1, 1, 1, 1, 1};
    int pg[] = {1, 1, 1, 1};
    String menu[] = {"Start Game", "Instructions", "Sound (On)", "Top Score",
                    "Global Scorecard", "About Fugumobile", "Exit"};
    String showlevel[] = {"Night", "Daybreak ", "Midday"};

    public String tmp[] = {"You’ve been posted to keep watch over a new bridge that’s being constructed over the river. Your men have toiled day in and day out working on this bridge and now have recaptured it from the enemy. Many lives have already been lost. The bridge is under constant threat and its all happening tonight! Will this be the last sunrise your men will ever live to see? ",
                          "Press 4 or LEFT to move the cross hair left.# Press 6 or RIGHT to move the cross hair right.# Press 2 or UP to move the cross hair up.# Press 8 or DOWN to move the cross hair down.# Press 5 or FIRE to fire.# The flashing soldiers have spotted you and are shooting at you. Kill them first to survive the battle. In the third level, shoot down all enemy soldiers before they shoot down your soldiers.",
                          "Check out www.fugumobile.com for new releases", //"Download more games at# # or go to  www.fugumobile.com# on your phone browser to download games immidiately.",
                          "",
                          "Retrieval of Global Scorecard will depend on carrier networks and handset compatibility", //"List of top 10 players and their score. Downloading data may take some time.# This functionality is available only with compatible handsets & operator networks.",
                          "Copyright \u00A9 Fugu Mobile.# For more games, visit www.fugumobile.com "
    };
    //public String menu[] = {"Start","Game Objective","Instructions","Sound (on)","Top Score","Global Scorecard","More games","About Fugumobile","Exit"};
    public String submenu[] = {"Practice Mode", "Play Mode", "Load Game",
                              "Main Menu"};
    public String Exmenu[] = {"Continue", "New Game", "Main Menu"};
    public String Lvmenu[] = {"Level1", "Level2", "Level3"};

    public Vector Game2play = new Vector();
    public Vector How2play = new Vector();
    public Vector about = new Vector();
    public Vector HallOfFame = new Vector();
    public Vector MoreGames = new Vector();
    public Vector Prelv;

    static final String DBNAME = "OOO";
    public boolean highscorecheck = true;
    public boolean highscoretext = false;
    public int score, health, scorel;
    // public String store;
    int diff, imno, rantem, cloind, iran;
    int post[] = new int[4];
    int cntr[] = new int[5];

    //GAME VARIABLES
    public boolean IN_Game = false, i_am_dead = false, allian_dead = true;
    //============================Images==========================
    //Background IMages
    public Image bgtr1, bgtr2, bbg1, bbg2, fg, bg1, bg2, bush, bgw, st1, st2,
    gbreak, allian1, allian2, fire1, fire2, lv1, lv2, lv3, scoreimg,
    blackTransparence, killsimg;
    //Troops ka images for walking
    public Image Trp[] = new Image[28];
    public Image shot[] = new Image[4];
    public Image shotanim[] = new Image[9];
    public String Tinm[] = {"/ef1.gif", "/ef2.gif", "/es1.gif", "/es2.gif",
                           "/ep1.gif", "/ep2.gif", "/er1.gif", "/er2.gif",
                           "/ep1r.gif", "/ep2r.gif", "/wef1.gif", "/wef2.gif",
                           "/wes1.gif", "/wes2.gif", "/wesr1.gif", "/wesr2.gif",
                           "/wep1.gif", "/wep2.gif", "/wp1.gif", "/wp2.gif",
                           "/wer1.gif", "/wer2.gif", "/wep1r.gif", "/wep2r.gif",
                           "/ef3.gif", "/ef3s.gif", "/wef3a.gif", "/wef3b.gif"};
    public String shotname[] = {"/shot1.gif", "/shot2.gif", "/shot3.gif",
                               "/shot4.gif"};
    public String sty[] = {"/buletg1.gif", "/buletg2.gif", "/buletg3.gif",
                          "/buletw1.gif", "/buletw2.gif", "/buletw3.gif",
                          "/w1.gif", "/w2.gif", "/w3.gif", };
    public String temstr;
    //bush placement
    int bx[] = {40, 60, 120};
    int by[] = {40, 160, 20};
    //Variables for Target
    byte uup, dn, lf, rt, anim;
    public Image target, gen, btns2, btns3; //gen general img for pre level
    public int cx, cy, chx, chy;
    public int tindex = 0;
    //Return Direction if coollide with the screen
    public byte bu[] = {1, 2, 6, 7}, bd[] = {0, 4, 3};
    public byte ru[] = {1, 2, 6, 7}, rd[] = {0, 4, 3};
    public byte conlu[] = {0, 2, 3}, conld[] = {2, 5, 7}, conru[] = {1, 4, 0},
    conrd[] = {1, 6, 5};
    public byte s1[] = {2, 7, 3}, s2[] = {1, 4, 6}, s3[] = {5, 6, 7}, s4[] = {0,
            4, 3};
    public byte proareal[] = {2, 5, 7}, proarear[] = {1, 4, 6};
    public byte ret[] = {1, 2, 5, 6, 7};
    //game play Array
    int grid[][]
            = {
              //level 1
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {2, 2, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 2, 2, 2, 0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 2, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
              0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 4},
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 2,
              2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 2, 2,
              0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0,
              0, 0, 0, 0, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4},
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4}, {0, 0, 0,
              2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4}, {2, 2, 0, 2, 0, 0,
              0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 4, 4,
              4, 4, 4, 4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4,
              4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
              4, 4, 4}, {0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},

    }; //19,22

    int grid1[][]
            = {
              //level 1
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {2, 2, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 2, 2, 2, 0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 2, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
              0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 4},
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 2,
              2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 2, 2,
              0, 0, 0, 0, 0, 0, 0, 0, 4}, {0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0,
              0, 0, 0, 0, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4},
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4}, {0, 0, 0,
              2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4}, {2, 2, 0, 2, 0, 0,
              0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 4, 4,
              4, 4, 4, 4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4,
              4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
              4, 4, 4}, {0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
    };

    int grid2[][] = { {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
                    {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5, 5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5, 5, 5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5, 5, 5, 5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {4, 4, 4, 4, 4, 4, 4, 4, 4,
                    0, 0, 0, 0, 0, 0, 0, 0, 0}, {4, 4, 4, 4, 4, 4, 4, 4, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0}, {4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1,
                    1, 1, 1, 1, 1, 1, 1}, {4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1, 1}, {4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1}, {4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1}, {4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1}, {4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1}, {4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
                    {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},

    };
    //level 3
    int grid3[][] = { {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
                    {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {5, 5, 5, 5,
                    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {0, 0, 0, 0, 0,
                    0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, {0, 0, 0, 0, 0, 0,
                    0, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 0, 1,
                    1, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4}, {1, 1, 1, 1, 1, 1, 1, 1,
                    5, 5, 5, 5, 4, 4, 4, 4, 4, 4}, {1, 1, 1, 1, 1, 1, 1, 1, 1,
                    5, 5, 5, 5, 4, 4, 4, 4, 4}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 5,
                    5, 5, 5, 5, 5, 5, 5, 5}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    5, 5, 5, 5, 5, 5, 5}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    5, 5, 5, 5, 5, 5}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1}, {4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4,
                    4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0,
                    0, 0}, {4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0}, {4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                    {4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

    };


    //Trops elements
    Troops[] t = new Troops[7];
    Troops ti = null;
    int tt = 0;

    Troops[] al = new Troops[3];
    //Troops t1=null,t2=null,t3=null,t4=null,t5=null,t6=null,ti=null;
    //Variables for moving water
    public int wx, wy;
    //Variables For level
    public byte level = 0, gun = 0, kill;
    public byte[] react_tim = {16, 14, 14, 13, 12, 11, 9, 6, 5, 4, 3, 2, 1, 2,
                              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                              1, 1, 1, 1, 1, 1, 1, };

    //Sounds-----
    private static Player snd[] = new Player[4];
    public InputStream istream[] = new InputStream[4];
    String sndnm[] = {"/intro.mid", "/gunshot.wav", "/explode.wav",
                     "/scream.wav"};
    String sndty[] = {"audio/midi", "audio/x-wav", "audio/x-wav", "audio/x-wav"};
    /*
      //sounds
      byte abyte0[] = new byte[200];
      Sound snd[]=new Sound[2];
      String sndnm[]={"/intro.ott","/gunshot.ott"};

     */
    //sound counter
    int expcnt, crcnt;
    private int i_bloodNum;

    public BATTLE_ON_THE_RIVER_KWAI_N60() {
        lv = 0;
        cl = 0;
        intro = new Intro();
        obj = new GameCanvas();
        display = Display.getDisplay(this);

    }

    public class Intro extends FullCanvas {
        public Intro() {

        }

        public void paint(Graphics g) {
            DirectGraphics dg = DirectUtils.getDirectGraphics(g);

            switch (a) {
            case 88:
                g.drawImage(gbreak, w / 2, 0,
                            Graphics.TOP | Graphics.HCENTER);
                g.setColor(0x000000);
                g.fillRect(1, h - 15, w - 1, 12);
                g.drawImage(joystick, w / 2, h - 5,
                            Graphics.BOTTOM | Graphics.HCENTER);
                break;
            case 111: //level complete

//				  g.setColor(0xff0000);
//				  g.fillRect(0,0,w,h);

                g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
                                       Font.SIZE_MEDIUM));
                g.setColor(255, 255, 0);

//				  g.drawString("Score: "+score,w/2,h/2,Graphics.TOP|Graphics.HCENTER);
                g.drawString("Level Completed", w / 2, h / 2,
                             Graphics.HCENTER | Graphics.VCENTER);
                break;

            case 11: //Game Over

                if (highscorecheck == true) {
                    //	playsnd(3,100);
                    highscorecheck = false;
                }

                if (enemy == 0) {
                    drawbg(g, true);
                    postLevel(g, lv, enemy);
                } else {
                    drawbg(g, true);
                    postLevel(g, lv, enemy);
//                    g.setColor(0, 0, 0);
//                    g.fillRect(0, 0, w, h);
//                    drawbg(g, true);
//                    if (lv < 2) {
//                        g.drawImage(fg, 0, 93, Graphics.TOP | Graphics.LEFT);
//                    }
//                    g.drawImage(gbreak, w / 2, 0,
//                                Graphics.TOP | Graphics.HCENTER);
//                    g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
//                                           Font.SIZE_MEDIUM));
//                    g.drawImage(blackTransparence,w/2,h/2,Graphics.HCENTER|Graphics.VCENTER);
//                    g.setColor(0xaa0000);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -