📄 play.java
字号:
package Kidfishing;
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import tool.Tools;
public class Play {
Image image[][];
String name;
private int x, y;// 玩家坐标
private int direct;// 玩家方向
static final int _LEFT = 173;
static final int _RIGHT = 174;
boolean isdown, isfish;// 是否放线,是否有鱼
boolean isShark;
boolean isback;// 收线
private int v = 3;// 玩家速度
private int frame, goals;// 桢,玩家得分
private int bx, by, barbx, barby;// 鱼钩坐标;
private int prop[] = new int[3];// 道具
int count;
public Play() {
try {
image = new Image[2][];
Image res = Image.createImage("/player.png");
for (int i = 0; i < image.length; i++) {
image[i] = Tools.getAnmi(res, 0, i * 40, 1, 2, 70, 40);
}
x = 0;
y = 20;
} catch (IOException e) {
e.printStackTrace();
}
}
void move() {
switch (direct) {
case _LEFT:
direct = _LEFT;
nextFrame();
break;
case _RIGHT:
direct = _RIGHT;
nextFrame();
break;
}
}
void stillMove() {
if (isMove()) {
switch (direct) {
case _LEFT:
x -= v;
if (x <= -25) {
x = -25;
}
if (x >= 106) {
x = 106;
}
break;
case _RIGHT:
x += v;
if (x <= -25) {
x = -25;
}
if (x >= 106) {
x = 106;
}
break;
}
}
}
public void drawPlayer(Graphics g) {
if (!isdown) {
g.drawImage(image[0][frame], x, y, Graphics.TOP | Graphics.LEFT);
} else {
g.drawImage(image[1][frame], x, y, Graphics.TOP | Graphics.LEFT);
}
}
// 画鱼线
public void drawFishline(Graphics g) {
if (!isdown && !isfish) {
bx = x + 66;
by = y + 4;
barbx = bx;
barby = by + 20;
} else if (isfish) {
int a = getY();
barby = a;
} else {
bx = x + 67;
by = y + 27;
barbx = bx;
}
g.setColor(0xffffff);
g.drawLine(bx, by, barbx, barby);
}
// 下线
void stillDown() {
barby += 5;
if (barby >= 208) {
isdown = false;
direct = 174;
}
}
// 上线
void stillUp(int a) {
barby -= 2;
if (barby <= 30) {
goals += a;
isdown = false;
isfish = false;
isback = false;
direct = 174;
}
}
// 控制线
void contorlLine() {
isdown = true;
direct = 0;
}
public void nextFrame() {
if (frame++ >= 1) {
frame = 0;
}
}
boolean isMove() {
if (direct != 0) {
return true;
}
return false;
}
void setdirect(int a) {
direct = a;
}
int getGoal() {
return goals;
}
void setGoal(int a) {
goals += a;
}
int getX() {
return barbx;
}
int getY() {
return barby;
}
// 道具
int[] isProp() {
return prop;
}
// 判断道具
int alive(int a) {
return prop[a];
}
// 买道具
void buyone(int a) {
prop[a] = 777;
goals -= (a + 1) * 100;
}
// 用道具
void delone(int a) {
prop[a] = 0;
}
// 控制计数器
int countUp(boolean a) {
if (a == true) {
count++;
if (count == 10000) {
count = 0;
}
} else {
count = 0;
}
return count;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -