?? main.java
字號:
import javax.microedition.io.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.rms.*;import java.io.*;import java.util.*;//#if Nokiaimport com.nokia.mid.ui.*;public class Main extends com.nokia.mid.ui.FullCanvas implements Runnable, RecordFilter, RecordComparator//#elif Siemens && (!SX1)import com.siemens.mp.color_game.*;import com.siemens.mp.game.*;public class Main extends com.siemens.mp.color_game.GameCanvas implements Runnable, RecordFilter, RecordComparator//#elsepublic class Main extends Canvas implements Runnable, RecordFilter, RecordComparator//#endif{ static boolean isBannerLoaded; static String banner; static int bannerImageIndex = 32; static int snow[] = null; static int sin[] = null; static int cos[] = null; static int anims[][] = null; static String text[] = null; static final int GHOST_DATA_SIZE = 2000; // bytes static final int NO_ACTION = -15; static final int STATE_BIATHLON_RUN = 0; static final int STATE_BIATHLON_RUN_FINISH = 1; static final int STATE_BIATHLON_RUN_SCORES = 2; static final int STATE_BIATHLON_SHOOT = 3; static final int STATE_BIATHLON_SHOOT_FINISH = 4; static final int STATE_SKATER_RUN = 10; static final int STATE_SKATER_RUN_FINISH = 11; static final int STATE_SKATER_RUN_SCORES = 12; static final int STATE_SKIJUMP_RUN = 20; static final int STATE_SKIJUMP_RUN_FINISH = 21; static final int STATE_SKIJUMP_RUN_SCORES = 22; static final int STATE_PLACE = 50; static final int STATE_MENU = 70; static final int STATE_EDITOR = 80; static final int STATE_EDITOR_FINISH = 81; static final int STATE_INTRO = 90; static final int STATE_LOGO = 91; static int[][] abcw = {//#if Size_0 // 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z # . : _ , * @ ( ) {6,4,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,3,6,6,6,7,6,6,6,6,6,6,7,6,6,7,7,7,5, 5,2,2,6,2,9,9,4,4, 4, 6,6,6,6,6, 8, 6, 6,6,6,6, 3,3,3,3, 6, 6,6,6,6, 6,6,6,6, 5,5, 6,7},//#else {8,5,8,8,7,8,8,7,8,8, 8,7,8,8,7,7,8,8,4,8,8,7,10,8,8,7,8,8,7,8,8,8,10,8,8,7, 7,4,4,6,4,9,9,4,4, 4, 8,8,8,8,8, 9, 8, 7,7,7,7, 4,4,4,4, 8, 8,8,8,8, 8,8,8,8, 7,7, 6,7},//#endif {6,6,6,6,6,6,6,6,6,6,3}, {6,4,5,5,5,5,5,5,5,5,5,5,4,5,5,5}}; static int[][] abcx = null; static int[][] abcy = null; static int[] abch = {9,11,8}; static int abci = 0; static byte ghost_data[] = null; static int ghost_data_ptr = 0; static int ghost_data_count = 0; static byte ghost_data_w[] = null; static int ghost_data_ptr_w = 0; static int ghost_data_count_w = 0; static int rounds_count = 3; static int rounds_passed = 0; static WinterSports midlet; Thread mainThread; static Image img[] = null; static String img_names[] = null;//#if GX10 static Image img_cache[] = null;//#endif static int logo0_index = -1; static int logo1_index = -1; static int abc_index[] = {-1,-1,-1}; static int rast_index = -1; static int snowflake_index = -1; static Frame fT[] = null; static Frame fSn[] = null; static Frame fTree[] = null; static Frame fFlag[] = null; static Frame fBg = null; static Frame fChess = null; static Frame fTarget = null; static Frame fMeter = null; static Frame fMeterred = null; static Frame fHeart = null; static Frame fAmmo = null; static Frame fSnow = null; static Frame fSign = null; static Frame fBoard = null; static Frame fGo[] = null; static Dynamic man = null; static Dynamic ghost = null; static Hashtable hp = null; static Vector v = null,v1 = null,v2 = null; static int s_w; // physical screen size static int s_h; static Random rand; static int state; static boolean initOK = false; static int action = NO_ACTION, key_action = NO_ACTION, g_action, game_action; static boolean running = false; // static int[] track_x = null; // array or track points static int[] track_y = null; static int track_width = 0; static int track_width_one = 0; static int a_x_d = 0; // displacement static int a_y_d = 0; static int a_x_range = 0; // displacement range static int i,i2,j,k,x,y,x1,y1,x2,y2,w,h,w1,h1,w2,h2,n,dx,dy,idx,itotal,tracks_total; static int rel_dx,rel_dy; static int x_bound, y_bound_top, y_bound_bottom, y_bg_top; static int start_x, start_y; static int track_x_sum, shoot_bound, points, total_points; static int distance = 0; static String str, str2, str3, message = null; static char buf[] = null; static int bgTop = 0; static Vector vMenu; static Vector vMenuId; static Vector vState; static int menuIndex = 0; static String menuName; static int menuDisp,menuRange,menuHeight,menuTop,logoTop; static boolean isPointer = true; static boolean isState = true; static int menuLast = -1; static boolean showLogo = false; static Vector vMenuName; static int menuWidth; static int menuItemWidth; static int menuSize; static char editText[] = null; static String letters = " 0123456789abcdefghijklmnopqrstuvwxyz.,:*@_#"; static String numbers = " +0123456789_#"; static int editX, editY, ew; static char ch; // tasks static int taskTimes[] = null; static int tasks[] = null; static int task_i = 0; static boolean needRepaint = false; static InputStream in = null; Font font = null; static int si,sl,sx,sn; static char sc; static int tabx[] = new int[2]; static int tabi = 0; static int tabw = 0; Thread t = null; static long tstart = 0, tcur = 0; static boolean runFlag = true;// static int model = 4; static boolean resourcesLoaded = false; static String str_yes, str_no; static Dynamic dyn = new Dynamic();//#if MIDP2 protected void sizeChanged(int w,int h) { s_w = w; s_h = h; }//#endif public Main(WinterSports midlet) {//#if Siemens && (!SX1) super(false); // for game canvas//#endif try { this.midlet = midlet;//#if MIDP2 setFullScreenMode(true);//#endif s_w = getWidth(); s_h = getHeight(); ew = 10; w = 104;//#if Size_0 ew = 8; w = 81;//#endif abcx = new int[abcw.length][]; abcy = new int[abcw.length][]; for (j = 0; j < abcw.length; j++) { x = 0; y = 0; abcx[j] = new int[abcw[j].length]; abcy[j] = new int[abcw[j].length]; for (int i = 0; i < abcw[j].length; i++) { abcx[j][i] = x; abcy[j][i] = y; x += abcw[j][i]; if (x > w) { x = 0; y += 9; } } } buf = new char[30]; // char buffer isNameSaved = false; try { rs = RecordStore.openRecordStore("wsports",false); if (getVar(C_UNAME) > 0) { uname = r_player; isNameSaved = true; } } catch(Exception ex) { try { rs = RecordStore.openRecordStore("wsports",true); for (i = 0; i < 9; i++) { player = gp("n" + i); putRecord(C_ADD_RECORD,G_BIATHLON,Integer.parseInt(gp("s0_" + i))); putRecord(C_ADD_RECORD,G_SKATER, Integer.parseInt(gp("s1_" + i))); putRecord(C_ADD_RECORD,G_SKIJUMP, Integer.parseInt(gp("s2_" + i))); } } catch(Exception ex2){} } version = midlet.getAppProperty("MIDlet-Version"); rand = new Random(System.currentTimeMillis()); img = new Image[71]; img_names = new String[img.length]; for (i = 0; i < img.length; i++) { img[i] = null; img_names[i] = null; } abc_index[0] = img.length - 1; abc_index[1] = abc_index[0] - 1; abc_index[2] = abc_index[1] - 1; logo0_index = abc_index[2] - 1; logo1_index = logo0_index - 1; rast_index = logo1_index - 1; snowflake_index = rast_index - 1; editText = new char[5]; state = STATE_INTRO; logoTop = -1; state_delay = 40; isKeyPressed = false; action = NO_ACTION; createImage(snowflake_index, "/Res/sf.png"); createImage(logo0_index, "/Res/xi.png"); if (img[logo0_index] != null) { w1 = getImageWidth(logo0_index); h1 = getImageHeight(logo0_index); fBg = new Frame(logo0_index,0,0,w1,h1,w1,h1); }//#if GX10 img_cache = new Image[3]; img_cache[0] = Image.createImage("/Res/xl.png"); img_cache[1] = Image.createImage("/Res/xt.png"); img_cache[2] = Image.createImage("/Res/rast.png");//#endif text = new String[70]; loadText(); str_yes = text[13]; str_no = text[14]; while (str_yes.length() > str_no.length()) str_no = " " + str_no; while (str_yes.length() < str_no.length()) str_yes = " " + str_yes; snow = new int[8]; for (i = 0; i < snow.length; i++) { x = rnd(s_w); y = rnd(s_h); k = rnd(1); h = rnd(10) * 2 + 10; snow[i] = (x << 24) & 0xFF000000; snow[i] |= (y << 16) & 0x00FF0000; snow[i] |= (k << 8) & 0x0000FF00; snow[i] |= h & 0x000000FF; } isBannerLoaded = true; banner = midlet.getAppProperty("banner"); if (banner != null) isBannerLoaded = false; else bannerImageIndex = -1; Display.getDisplay(midlet).setCurrent(this); initTasks(); start(); } catch(Exception ex) {// ex.printStackTrace(); } } static void loadText() { DataInputStream din = null; try { din = new DataInputStream(midlet.getClass().getResourceAsStream("/Res/en")); for(j = 0; j < text.length; j++) text[j] = din.readUTF(); } catch(Exception e){} try { din.close(); } catch(Exception ex){} din = null; } static int initTasks() { taskTimes = new int[1]; taskTimes[0] = 75; tasks = new int[taskTimes.length]; tasks[0] = 0; tstart = tcur = System.currentTimeMillis(); runFlag = false; running = true; return 0; } static int rnd(int interval) { return (rand.nextInt() & 0x07FFFFFFF) % interval; } int isScreen = 0; void setScreen(String msg) { message = msg; isScreen = 1; doRepaint(); } static Frame gf(String name,int i1, int i2, int i3) { StringBuffer sb = new StringBuffer(); sb.append(name); sb.append(Integer.toString(i1)); sb.append('_'); sb.append(Integer.toString(i2)); sb.append('_'); sb.append(Integer.toString(i3)); return gf(sb.toString()); } static int gf_count = 0; static Frame gf(String name) { try { String str = gp(name); if (str != null) { Vector v = parse(str); int h = ((Integer)v.elementAt(0)).intValue(); str = gp("i" + h); int w1,w2,h1,h2; if (str != null) { if (img_names[h] == null) { img_names[h] = str; } w1 = w2 = ((Integer)v.elementAt(3)).intValue(); h1 = h2 = ((Integer)v.elementAt(4)).intValue(); if (v.size() > 5) w2 = ((Integer)v.elementAt(5)).intValue(); if (v.size() > 6) h2 = ((Integer)v.elementAt(6)).intValue(); return new Frame(h,((Integer)v.elementAt(1)).intValue(),((Integer)v.elementAt(2)).intValue(),w1,h1,w2,h2); } if (++gf_count == 8) { gf_count = 0; midlet.main.doRepaint(); } } } catch(Exception ex){} return null; } boolean enqueue_abc(int index) { if (img[abc_index[index]] == null) { img_names[abc_index[index]] = "abc" + index; return true; } return false; } boolean loadLogo() { boolean res = false; if (img[rast_index] == null) { img_names[rast_index] = "rast"; res = true; } if (img[logo0_index] == null) { img_names[logo0_index] = "xl"; res = true; } if (img[logo1_index] == null) { img_names[logo1_index] = "xt"; res = true; } return res; } void release() { initOK = paused = false; fT = null; fSn = null; fTree = null; fFlag = null; fT = null; fSnow = null; fBg = null; fChess = null; fTarget = null; fMeter = null; fMeterred= null; fHeart = null; fAmmo = null; fBoard = null; fSign = null; fSnow = null; fGo = null; track_x = null; for (i = 0; i < img.length; i++) if ((i != abc_index[0]) && (i != rast_index) && (i != snowflake_index)) { img[i] = null; img_names[i] = null; } anims = null; sin = null; cos = null; vMenu = null; vMenuId = null; vState = null; vMenuName = null; man = null; ghost = null;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -