📄 jmps.java
字号:
// http://www2.r-force.co.jp/iapp/java/047/
// http://www2.r-force.co.jp/iapp/java/JMP/
//import com.nttdocomo.io.*;
//import com.nttdocomo.ui.*;
import com.lm.nttdocomo.ui.*;
import com.lm.nttdocomo.Util;
import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.rms.*;
import com.vodafone.v10.system.device.DeviceControl;
import com.vodafone.v10.system.media.*;
/**
* Contains the main game engine.
*
* @author <a href="mailto:xp@livingmobile.net">Xavier Palau</a>
* @version $Revision: 1.16.4.16 $
* @changed $Author: xavier $ $Date: 2003/03/31 11:05:15 $
*/
public class JMPS extends Canvas
{
private static JMP main;
private static final String STORE_NAME = "skijumping_high";
boolean isPaused = false;
boolean helpFirstScreen = true;
private MediaPlayer theme;
private MediaPlayer applause;
private MediaPlayer wincup;
private MediaPlayer wingame;
private MediaPlayer lost;
private static byte buf[];
private static DataOutputStream out;
private static DataInputStream in;
// private final static int KL = ( 1 << Display.KEY_1 | 1 << Display.KEY_4 | 1 << Display.KEY_7 | 1 << Display.KEY_LEFT );// KL 65682
// private final static int KR = ( 1 << Display.KEY_3 | 1 << Display.KEY_6 | 1 << Display.KEY_9 | 1 << Display.KEY_RIGHT );// KR 262728
// private final static int KU = ( 1 << Display.KEY_2 | 1 << Display.KEY_UP );// KU 131076
// private final static int KD = ( 1 << Display.KEY_8 | 1 << Display.KEY_DOWN );// KD 524544
// private final static int KC = ( 1 << Display.KEY_5 | 1 << Display.KEY_SELECT );// KC Com[4]
// private final static int SL = ( 1 << Display.KEY_SOFT1 );// SL:2097152
// private final static int SR = ( 1 << Display.KEY_SOFT2 );// SR:4194304
private static int BASELINE = Graphics.BASELINE;
private static int LEFT_TOP = Graphics.LEFT | Graphics.TOP;
private static int CENTER_TOP = Graphics.HCENTER | Graphics.TOP;
private static Font NF;
private static Random R;
private static String[] names = {"Ogawa","Steve","Ritva","Maria","Sven","Mika","Daniela","Max"};
private static String[] strCommon = null;
private static String[] strSpecific = null;
private String strTemp;
// -100 = menu ; -1 = loading ; 0 = title ;
// 100 = choose country ; 200 = cup, opponents
// 300 = game intro ; 350 = choose wind
// {400, 500, 600, 700} = descent, jump, balance, landing
// 800 = jump results ; 850 = ranking
// 888 = get supporters' applause ; 900 = win (cup)
// {350, 400, 500, 600, 650, 700} = Tutorial
// 950 = continue?
// 1000 = scores
// {998, 999, 1200} = game cleared
private static int GM;
private static int GM_old = -1000;
private int progmax;
private int progress;
private int counter = 0;
int[] colors = { 255,223,191,159,127,95,63,31,0,31,63,95,127,159,191,223 };
private static Image[] I;
private static Image startImage;
private static int nSel;
private static int ResCnt;
private static int nStage;
private static int Frame;
private static int LineX, LineY, LineOY;//, RedLine;
private static int nScroll;
private static int CVY;
private static int Pow;
private static int Wind, WindPow, WindTime, WindUD, WindLR, WindLRPow;
private static int[] nScore = {0,0,0,0,0,0,0,0,0,0,0,0,0}; //new int[4 + 8]; // +1:cumulate
private static int totalScore = 0;
private static int Kaisuu;
private static int Kyori, Hikyori, Hikei, RedPoint;
private static int FirstKyori, HowTo;
private static int PXY, JX, OffJP;
private static int fClear;
private static int[] Scr;
private static int[] C;
private static int[] Key;
private static int[] WCur;
private static int[] Head;
private static int[] VSList;
private static int[] icList;
private static int[] CupTime;
private static int[] CpuScore;
private static int[] Meter;
private static int[] Power; // MaxPower
private static int[] WindSpeed;
private static int[] Ending;
private static int[] Temp;
//private static byte Pallete[][];
//private static byte header[][];
//private static byte img[][];
private static boolean[] GF;
public JMPS()
{
// System.out.println("+JMPS");
//System.gc();
Scr = new int[3];
C = new int[6];
Key = new int[4];
WCur = new int[6];
Head = new int[16];
VSList = new int[8];
CupTime = new int[11];
CpuScore = new int[60];
Meter = new int[12];
Power = new int[8];
WindSpeed = new int[24];
Ending = new int[9];
Temp = new int[11];
GF = new boolean[19];
Scr[0] = ( Display.getWidth() - 120) / 2;
Scr[1] = ( Display.getHeight() - 120) / 2;
C[0] = 16777215; // Util.getColorOfRGB(255, 255, 255); // white
C[1] = 16754225; // Util.getColorOfRGB(255, 166, 49); // light orange
C[2] = 11913983; // Util.getColorOfRGB(181, 202, 255); // "ice" blue
C[3] = 16736063; // Util.getColorOfRGB(255, 95, 63); // red
C[4] = 16727903; // Util.getColorOfRGB(255, 63, 95); // red2
main = (JMP) IApplication.getCurrentApp();
strCommon = main.txt.getBundle("strCommon");
strSpecific = main.txt.getBundle("strSpecific");
NF = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL);
GM = -10;
R = new Random( new java.util.Date().getTime() );
}
//------------------------------------------------------------------------------
public void mediaStateChanged(int state) {
}
public void initAll()
{
int i;
GF[1] = true;
try
{
System.gc();
// init sound
theme = new MediaPlayer(readDataFromJar("/sounds/theme.mmf"));
applause = new MediaPlayer(readDataFromJar("/sounds/applause.mmf"));
wincup = new MediaPlayer(readDataFromJar("/sounds/wincup.mmf"));
wingame = new MediaPlayer(readDataFromJar("/sounds/wingame.mmf"));
lost = new MediaPlayer(readDataFromJar("/sounds/lost.mmf"));
in = new DataInputStream( getClass().getResourceAsStream("JMP.spf") );
// loading bar...
GM = -1;
progmax = 4 * (10 + 2 + 2); // flags + start image + misc
progress = 0;
// initialize image array
I = new Image[48];
for (i=0; i<48; i++) I[i] = null;
// load flags
for (i=0; i<10; i++) {
I[i] = Image.createImage("/images/img" + i + ".png");
//System.out.println("Loaded img[" + i + "] to I[" + i + "]");
loadProgress(4*1);
System.gc();
}
// load start image
startImage = Image.createImage("/images/start.png");
loadProgress(4*2);
// Load game variables initial values (146 bytes)
for (i = 0; i<6 ; i++) WCur[i] = in.readByte();
for (i = 0; i<11; i++) CupTime[i] = in.readByte();
for (i = 0; i<60; i++) CpuScore[i] = in.readByte();
for (i = 0; i<16; i++) Head[i] = in.readByte();
for (i = 0; i<12; i++) Meter[i] = in.readByte();
for (i = 0; i<8 ; i++) Power[i] = in.readByte();
for (i = 0; i<24; i++) WindSpeed[i] = in.readByte();
for (i = 0; i<9 ; i++) Ending[i] = in.readByte();
loadProgress(4*1);
in.close();
// Read scores
RecordStore highscore = null;
try {
highscore = RecordStore.openRecordStore(STORE_NAME, false);
for (i = 0; i < nScore.length; i++)
nScore[i] = Integer.parseInt(new String(highscore.getRecord(i+1)));
}
catch (Exception e) {}
finally {
if (highscore != null) {
try { highscore.closeRecordStore(); }
catch (Exception e) {}
}
}
loadProgress(4*1);
}
catch(Exception e) {}
playsound(theme);
notifyTitle();
}
//------------------------------------------------------------------------------
// loads imga.png to imgb.png(included) set of images (incr: loading bar)
public void LoadGraph(int a, int b, int incr)
{
try {
for (int i=a; i<=b; i++) {
System.gc();
if(I[i] == null) {
if (GM != -1 && GM != 1000) GM = -1; {
I[i] = Image.createImage("/images/img" + i + ".png");
//System.out.println("Loaded (Graph) img[" + i + "] to I[" + i + "]");
}
}
loadProgress(incr);
//System.out.println("Loaded img[" + i + "]);
}
} catch(Exception e) {}
}
/*
// UNloads imga.png to imgb.png(included) set of images
public void unLoadGraph(int a, int b)
{
try {
for (int i=a; i<=b; i++) {
I[i] = null;
//System.out.println("Unloaded img[" + i + "]);
}
} catch(Exception e) {}
System.gc();
}
*/
public void ChangeTeamGraph()
{
try {
I[45] = Image.createImage("/images/img" + (48+VSList[0]) + ".png");
I[46] = Image.createImage("/images/img" + (56+VSList[0]*2) + ".png");
I[47] = Image.createImage("/images/img" + (57+VSList[0]*2) + ".png");
}
catch (Exception e) {}
}
public void LoadTeamGraph()
{
int i, j;
try{
Temp[0] = 0;
for (i=0; i<11 && GF[17]; i++ ) I[37+i] = null;
for (i=0; i<4; i++) {
System.gc();
I[37+Temp[0]] = Image.createImage("/images/img" + (37+i) + ".png");
//System.out.println("1. Loaded img[" + (37+i) + "] to I[" + (37+Temp[0]) + "]");
loadProgress(1);
Temp[0]++;
}
j = 0;
if(VSList[0] == 1 || VSList[0] == 4 || VSList[0] == 5) j = 4;
for (i=0; i<5; i++) {
System.gc();
if (i < 4) {
if (j != 0 && i == 2) {
I[37+Temp[0]] = Image.createImage("/images/img" + (41+i) + ".png");
//System.out.println("2a. Loaded img[" + (41+i) + "] to I[" + (37+Temp[0]) + "]");
j--;
}
else {
I[37+Temp[0]] = Image.createImage("/images/img" + (41+i+j) + ".png");
//System.out.println("2b. Loaded img[" + (41+i+j) + "] to I[" + (37+Temp[0]) + "]");
}
}
else {
I[37+Temp[0]] = Image.createImage("/images/img" + (48+VSList[0]) + ".png");
//System.out.println("2c.Loaded img[" + (48+VSList[0]) + "] to I[" + (37+Temp[0]) + "]");
}
Temp[0]++;
loadProgress(1);
}
for (i=0; i<2; i++) {
System.gc();
I[37+Temp[0]] = Image.createImage("/images/img" + (56+i+VSList[0]*2) + ".png");
//System.out.println("3.Loaded img[" + (56+i+VSList[0]*2) + "] to I[" + (37+Temp[0]) + "]");
Temp[0]++;
loadProgress(1);
}
GF[17] = true;
System.gc();
} catch (Exception e) {}
}
public void loadProgress(int incr) {
progress += incr;
if (GM != -1) return;
Draw();
}
//------------------------------------------------------------------------------
public synchronized void ProEvent(int OnKey)
{
int i, j, x, y;
Key[0] = Key[3] | OnKey | getKeypadState();
Key[1] = Key[0] & ~Key[2];
Key[2] = Key[0];
Key[3] = 0;
if( GF[14] && GM > 200 ){ // How To (..)
Key[0] = 0;
Key[1] = 0;
}
//--------------------------------------------------------------------------
if( GM == 0 ){
if( ( Key[1] & 131076 ) != 0 ){
nSel--;
if( nSel < 0 ) nSel = 2;
}
if( ( Key[1] & 524544 ) != 0 ) nSel = ( nSel + 1 ) % 3;
// if( ( Key[1] & 1048608 ) != 0 ){
if (OnKey == -10) {
// HowTo...
GF[14] = false;
if( nSel == 2 ) GM = 1000;
else
{
if(I[10] == null && nSel == 0) { // load only Faces
GM = -1;
progmax = 8 * 5;
progress = 0;
LoadGraph(10, 17, 5);
try { Thread.sleep(500); } catch(Exception e) {}
}
GM = 100;
GF[13] = false;
// How To..
if( nSel == 1 ){
VSList[0] = 0;
LineY = 0;
nScroll = 0;
LineX = 0;
Frame = 0;
JX = 59;
PXY = 0;
GF[14] = true; // Tutorial ...
if (I[18] == null) {
progmax = 19*3 + 11;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -