import java.io.InputStream;
import java.util.Random;
import java.util.Vector;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class TankCanvas extends Canvas implements Runnable
{
private final TankMIDlet midlet;
public static Graphics g = null;
private int gameStatus = 1;
private int gameSubStatus = 1;
private int gameSelect = 1;
private int CanvasWidth, CanvasHeight;
private int fontHeight, fontWidth;
private int level = 1;
private static int MAX_LEVEL = 20;
private int passPos = 1;
private int title_x, title_y;
private int title_w, title_h;
private int SplashCnt;
private int ResultCnt;
private int fadeColor;
private int frameWidth, frameHeight;
private int i, j;
private boolean isPaused = false;
private boolean isFirstTime = true;
private boolean isShowLevel = true;
private boolean isFadeIn = true;
private boolean isNotationDown = false;
private boolean isVictorShowed = false;
private boolean isCapped = false;
private Image imgSplash;
private Image imgTankEnemy;
private Image imgTankPlayer;
private Image imgTitle;
private Image imgTemp;
private Image imgMap;//加载地图
public int tileWidth, tileHeight;//地图单元的宽高
private Image imgTile1;
private Image imgTile2;
private Image imgTile3;
private Image imgTile4;
private Image imgVictor;//飞鹰标志
private Image imgLogoPlayer;//玩家坦克标志
private Image imgLogoEnemy;//敌方坦克标志
public int mapWidth, mapHeight;//地图宽高
public int mapOffsetX, mapOffsetY;//地图,屏幕的尺寸偏移量
public int dataOffsetX, dataOffsetY;//地图数组偏移量
public int tileW;//地图单元宽度的一半
private Image imgMedal;
private Image again1;
private Image again2;
private Image next1;
private Image next2;
private Image back1;
private Image back2;
private Image exit1;
private Image exit2;
private Font font;
private volatile Thread gameThread = null;
public int mapInfo[] = new int[(52 * 52)];
public int mapInfoFormer[] = new int[(52 * 52)];
private int liveCount = 0;
boolean pauseStart = false;
boolean canMove = true;
boolean ifTimer = false;
boolean homeWall = false;
private Bullet[] bullet = new Bullet[3];
public boolean bulletAlive[] = new boolean[3];
public int maxBullet = 3;
private EnemyPool pool;
private Vector tempPos = new Vector();
private Enemy[] enemy;//敌方坦克
private Enemy[] backenemy;//备份敌方坦克
private Enemy[] enemyNormal;//普通坦克
private Enemy[] enemyGreen;//绿色坦克
private int timeCount = 0;
private int maxShowEnemy = 7;
private int leftEnemy;
boolean enemyAlive[] = new boolean[maxShowEnemy]; //modified by johnson
private int currentEnemy = 3;
private final int MAX_NUM = 15;
private int numPos = 0;
private int[] enemyGroup =
{
0, 0, 0, 2, 1, 3, 2, 0, 2, 1, 0, 3, 3, 2, 1, 0, 0, 0, 0, 0
};//坦克类型 0是普通 1是红色 2绿色 3是普通
private Image bombImage;
boolean shootFlag = false;
boolean grassPaint = false;
public Hero hero;
public int life = 3;
Bonus bonus = new Bonus();
private int totalMark;
private int bonusMark;
private int normalNum;
private int redNum;
private int greenNum;
private int superNum;
public boolean isWin, isLose;
boolean reDraw = false;
public TankCanvas(TankMIDlet midlet)
{
this.midlet = midlet;
CanvasWidth = getWidth(); //240
CanvasHeight = getHeight(); //289
System.out.println("宽: " + CanvasWidth);
System.out.println("搞: " + CanvasHeight);
pool = new EnemyPool();
isPaused = false;
font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE);
fontHeight = font.getHeight();
fontWidth = font.charWidth('坦');
isNotationDown = (CanvasWidth > CanvasHeight)?true:false;//提示的标志位置
hero = new Hero(this);
initLevel();//初始化关卡
enemy = new Enemy[MAX_NUM];
backenemy = new Enemy[MAX_NUM];
enemyNormal = new Enemy[4];//4个普通坦克
enemyGreen = new Enemy[4];//4 个绿色坦克
for (int i = 0; i < MAX_NUM; i++)
{
enemy[i] = new Enemy(this, enemyGroup[i]);//生成敌方坦克
}
for (int i = 0; i < MAX_NUM; i++)
{
backenemy[i] = enemy[i];//备份敌方坦克
}
for (int i = 0; i < 4; i++)
{
enemyNormal[i] = new Enemy(this, 0);
}
for (int i = 0; i < 4; i++)
{
enemyGreen[i] = new Enemy(this, 2);
}
bombImage = createImage("/explode.png");//爆炸图片
for (int i = 0; i < maxBullet; i++)
{
bulletAlive[i] = false;//子弹存活标志
bullet[i] = new Bullet(this);
}
again1 = createImage("/again1.png");
again2 = createImage("/again2.png");
next1 = createImage("/next1.png");
next2 = createImage("/next2.png");
back1 = createImage("/back1.png");
back2 = createImage("/back2.png");
exit1 = createImage("/exit1.png");
exit2 = createImage("/exit2.png");
}
public void run()
{
Thread currentThread = Thread.currentThread();
int gameSpeed = 100;
try
{
while (currentThread == gameThread)
{
if (gameStatus == 4)
{
gameSpeed = 35;
}
没有合适的资源?快使用搜索试试~ 我知道了~
J2ME坦克游戏源码
共197个文件
png:75个
map:60个
class:27个
4星 · 超过85%的资源 需积分: 5 25 下载量 14 浏览量
2011-02-26
11:23:36
上传
评论
收藏 1.02MB RAR 举报
温馨提示
J2ME坦克游戏源码 J2ME源码 坦克游戏源码 手机源码 手机游戏源码
资源推荐
资源详情
资源评论
收起资源包目录
J2ME坦克游戏源码 (197个子文件)
TankCanvas.class 34KB
TankCanvas.class 30KB
TankCanvas.class 30KB
Bullet.class 10KB
Hero.class 9KB
Bullet.class 9KB
Bullet.class 9KB
Hero.class 7KB
Hero.class 7KB
Enemy.class 6KB
Enemy.class 5KB
Enemy.class 5KB
Bonus.class 3KB
EnemyPool.class 3KB
Bonus.class 2KB
EnemyPool.class 2KB
Bonus.class 2KB
EnemyPool.class 2KB
SoundPlayer.class 2KB
SoundPlayer.class 2KB
SoundPlayer.class 2KB
TankMIDlet.class 1KB
TankMIDlet.class 1KB
TankMIDlet.class 1KB
Point.class 338B
Point.class 338B
Point.class 338B
SuperTank--3.jad 240B
SuperTank--3.jar 255KB
TankCanvas.java 150KB
TankCanvas.java 150KB
Bullet.java 53KB
Bullet.java 53KB
Hero.java 37KB
Hero.java 37KB
Enemy.java 21KB
Enemy.java 21KB
EnemyPool.java 5KB
EnemyPool.java 5KB
Bonus.java 4KB
Bonus.java 4KB
SoundPlayer.java 2KB
SoundPlayer.java 2KB
TankMIDlet.java 1KB
TankMIDlet.java 1KB
Point.java 215B
Point.java 215B
17.map 458B
17.map 458B
17.map 458B
1.map 422B
1.map 422B
1.map 422B
13.map 420B
13.map 420B
13.map 420B
14.map 418B
2.map 418B
14.map 418B
2.map 418B
14.map 418B
2.map 418B
6.map 410B
6.map 410B
6.map 410B
8.map 384B
8.map 384B
8.map 384B
18.map 370B
18.map 370B
18.map 370B
12.map 368B
12.map 368B
12.map 368B
20.map 362B
20.map 362B
20.map 362B
11.map 340B
11.map 340B
11.map 340B
10.map 336B
10.map 336B
10.map 336B
3.map 334B
3.map 334B
3.map 334B
16.map 328B
16.map 328B
16.map 328B
7.map 318B
7.map 318B
7.map 318B
9.map 308B
9.map 308B
9.map 308B
19.map 286B
19.map 286B
19.map 286B
5.map 280B
5.map 280B
共 197 条
- 1
- 2
资源评论
- weileiok0012012-06-23游戏写的很认真。但是在相对低端的手机上跑。还是略有困难
- 秦晋随风2012-09-03还行 起码能跑起来
- holyguang2016-08-05还可以,有待改进
Hermit_2009
- 粉丝: 9
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功