📄 def.java
字号:
/**
* <p>Title: Bowling3D Mockup</p>
* <p>Description: For Sony Ericsson K700</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: Gameloft Shanghai</p>
* @author Xia Wei
* @version 1.0
*/
/**
* cDef is a class that defines vars
*/
public class def {
/**
* Keys
*/
public static final int KEY_EMPTY = 0;
public static final int KEYNOTPRESSED = 0;
public static final int KEY_MENU = -5; //softkey "recall"
public static final int KEY_LEFT_MENU = -6; //softkey "recall"
public static final int KEY_RIGHT_MENU = -7; //softkey "continue"
//the width & height of screen,according to Sony Ericsson K700 White Page
public static final int DISPLAY_WIDTH = 176;
public static final int DISPLAY_HEIGHT = 220;
/** lane width */
// default size extended
public static final int DEFAULT_EXTEND = 100;
public static final int LANE_WIDTH = 117 * DEFAULT_EXTEND;
/** lane length */
public static final int LANE_LENGTH = 2000 * DEFAULT_EXTEND; //changed to public by Milo
//for display soft button
public static final int iCharWidth = 3;
public static final int iCharHeight = 5;
public static final String s1WidthChars = "I";
public static final String s2WidthChars = "J1 -";
public static final String s4WidthChars = "KNQ";
public static final String s5WidthChars = "MW%";
//default positions that player stands
public static final int PLAYER_POSITION_X = 0; //LANE_WIDTH =117
public static final int PLAYER_POSITION_Y = -250;
public static final int PLAYER_ROTATION_X = 0;
public static final int PLAYER_ROTATION_Y = 0;
public static final int PLAYER_ROTATION_Z = 2048;
//0 for without collision
public static final int TENPIN_WITHOUT_COLLISION = 0;
//1 for NORMAL collision
public static final int TENPIN_NORMAL_COLLISION = 1;
//2 for head collision
public static final int TENPIN_HEAD_COLLISION = 2;
//3 for ROTATED collision
public static final int TENPIN_LOW_ROTATED_COLLISION = 3;
//4 for HEAVY ROTATED collision
public static final int TENPIN_HEAVY_ROTATED_COLLISION = 4;
public static final int TENPIN_SMALLEST_PART = 0;
public static final int TENPIN_BIGGEST_PART = 2;
public static final int TENPIN_MIDDLE_PART = 1;
//FALLING VALUE
public static final int FALLING_VALUE = 2;
// const variable in CBall
public static final int DEFAULT_BALL_RADIUS = 12 * DEFAULT_EXTEND;
public static final int DEFAULT_BALL_WEIGHT = 14;
public static final int DEFAULT_DIFFICULT_VELOCITY = 1500;
public static final int DEFAULT_DIFFICULT_ROLLING = 1000;
// Fastest ball moving time
public static final int BALL_MOVMENT_FASTEST_TIME = 62;
// Mapping from strength to time.
public static final int BALL_MOVMENT_TIME_MODIFICATION = 5;
///** the extended multiple of trigonometric function value */
public static final int VALUE_MULTIPLE_TEN = 10000;
/** the extended multiple of angle */
public static final int ANGLE_MULTIPLE_TEN = 10;
/** pin height */
public static final int TENPIN_GRAVITY_CENTER = 5 * DEFAULT_EXTEND; //CTenpin.HEIGHT /6
/**
* Calculate square root of param value
*
* @param value
* @return square root
*/
public static int sqrt(int value) {
int a, b;
if (value == 0)
return 0;
a = value / 2;
do {
if (a == 0)
return 1;
b = (value / a - a) / 2;
a = a + b;
} while ((b > 1) || (b < -1));
return a;
}
/**
* Calculate the distance from one point to the other point
* @param x1 x coordinate of one point on the line
* @param y1 y coordinate of one point on the line
* @param x2 x coordinate of the other point on the line
* @param y2 y coordinate of the other point on the line
* @return the distance
*/
public static int distanceP2P(int x1, int y1, int x2, int y2) {
int dx = x2 - x1;
int dy = y2 - y1;
int dis = sqrt(abs(dx * dx + dy * dy));
return dis;
}
/**
* Calculate the distance from one point to one straight line
*
* @param x1 x coordinate of one point on the line
* @param y1 y coordinate of one point on the line
* @param x2 x coordinate of another point on the line
* @param y2 y coordinate of another point on the line
* @param xp x coordinate of the point out of the line
* @param yp y coordinate of the point out of the line
* @return the distance
*/
public static int distanceP2L(int x1, int y1, int x2, int y2, int xp, int yp) {
int dx = x2 - x1;
int dy = y2 - y1;
int dis;
if (dx == 0 && dy == 0)
dis = sqrt((xp - x1) * (xp - x1) + (yp - y1) * (yp - y1));
else
dis = abs(dx * (yp - y1) - dy * (xp - x1))
/ sqrt(dx * dx + dy * dy);
return dis;
}
public static int distanceP2L(int x1, int y1, int z1, int x2, int y2, int z2, int xp, int yp, int zp)
{
int l = x2-x1;
int m = y2-y1;
int n = z2-z1;
int dis;
if(l==0&&m==0&&n==0)
dis = distanceP2P(x1,y1,z1,xp,yp,zp);
else
{
int dx = xp-x1;
int dy = yp-y1;
int dz = zp-z1;
int t1 = dy*n-dz*m;
int t2 = dz*l-dx*n;
int t3 = dx * m - dy * l;
dis = sqrt( ( (long) t1 * t1 + t2 * t2 + t3 * t3) /
(l * l + m * m + n * n));
}
return dis;
}
/**
* Calculate absolute value of param value
*
* @param value
* @return the absolute value
*/
public static int abs(int value) {
if (value < 0)
return (-value);
else
return value;
}
/** the value of trigonometric function sin, array SIN means the value of sin every 5 degrees starting from 0 to 90 degrees, and is multipled by 10000 */
private static int SIN[] = { 0, 87, 174, 261, 348, 436, 523, 610, 697, 784,
871, 958, 1045, 1132, 1218, 1305, 1391, 1478, 1564, 1650, 1736,
1822, 1908, 1993, 2079, 2164, 2249, 2334, 2419, 2503, 2588, 2672,
2756, 2840, 2923, 3007, 3090, 3173, 3255, 3338, 3420, 3502, 3583,
3665, 3746, 3826, 3907, 3987, 4067, 4146, 4226, 4305, 4383, 4461,
4539, 4617, 4694, 4771, 4848, 4924, 5000, 5075, 5150, 5224, 5299,
5372, 5446, 5519, 5591, 5664, 5735, 5807, 5877, 5948, 6018, 6087,
6156, 6225, 6293, 6360, 6427, 6494, 6560, 6626, 6691, 6755, 6819,
6883, 6946, 7009, 7071, 7132, 7193, 7253, 7313, 7372, 7431, 7489,
7547, 7604, 7660, 7716, 7771, 7826, 7880, 7933, 7986, 8038, 8090,
8141, 8191, 8241, 8290, 8338, 8386, 8433, 8480, 8526, 8571, 8616,
8660, 8703, 8746, 8788, 8829, 8870, 8910, 8949, 8987, 9025, 9063,
9099, 9135, 9170, 9205, 9238, 9271, 9304, 9335, 9366, 9396, 9426,
9455, 9483, 9510, 9537, 9563, 9588, 9612, 9636, 9659, 9681, 9702,
9723, 9743, 9762, 9781, 9799, 9816, 9832, 9848, 9862, 9876, 9890,
9902, 9914, 9925, 9935, 9945, 9953, 9961, 9969, 9975, 9981, 9986,
9990, 9993, 9996, 9998, 9999, 10000 };
/** the value of trigonometric function tan, array TAN means the value of tan every 5 degrees starting from 0 to 90 degrees, and is multipled by 10000 */
private static int TAN[] = { 0, 87, 174, 261, 349, 436, 524, 611, 699, 787,
874, 962, 1051, 1139, 1227, 1316, 1405, 1494, 1583, 1673, 1763,
1853, 1943, 2034, 2125, 2216, 2308, 2400, 2493, 2586, 2679, 2773,
2867, 2962, 3057, 3152, 3249, 3345, 3443, 3541, 3639, 3738, 3838,
3939, 4040, 4142, 4244, 4348, 4452, 4557, 4663, 4769, 4877, 4985,
5095, 5205, 5317, 5429, 5543, 5657, 5773, 5890, 6008, 6128, 6248,
6370, 6494, 6618, 6745, 6872, 7002, 7132, 7265, 7399, 7535, 7673,
7812, 7954, 8097, 8243, 8390, 8540, 8692, 8847, 9004, 9163, 9325,
9489, 9656, 9826, 10000, 10176, 10355, 10537, 10723, 10913, 11106,
11302, 11503, 11708, 11917, 12130, 12348, 12571, 12799, 13032,
13270, 13514, 13763, 14019, 14281, 14550, 14825, 15108, 15398,
15696, 16003, 16318, 16642, 16976, 17320, 17674, 18040, 18417,
18807, 19209, 19626, 20056, 20503, 20965, 21445, 21942, 22460,
22998, 23558, 24142, 24750, 25386, 26050, 26746, 27474, 28239,
29042, 29886, 30776, 31715, 32708, 33759, 34874, 36058, 37320,
38667, 40107, 41652, 43314, 45107, 47046, 49151, 51445, 53955,
56712, 59757, 63137, 66911, 71153, 75957, 81443, 87768, 95143,
103853, 114300, 127062, 143006, 163498, 190811, 229037, 286362,
381884, 572899, 1145886, java.lang.Integer.MAX_VALUE };
/**
* Get the index in SIN or TAN
*
* @param degree the angle degree for being searched
* @param d the degree gap standed for between two adjoining value in array SIN or TAN
* @return the index that param degree corresponds in array SIN or TAN
*/
private static int searchIndex(int degree, int d) {
int p;
if (degree >= 0 && degree <= 90 * ANGLE_MULTIPLE_TEN) {
p = degree / d + ((degree % d) > d / 2 ? 1 : 0);
} else
p = -1;
return p;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -