import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
import javax.microedition.lcdui.game.GameCanvas;
public class Man extends MIDlet
{
private Game game;
public Display display;
public Man()
{
game = new Game(this);
display = Display.getDisplay(this);
}
public void startApp()
{
game.startGame();
}
public void pauseApp()
{
//
}
public void destroyApp(boolean unconditional)
{
//
}
public void closeman()
{
destroyApp(false);
notifyDestroyed();
}
}
class Game
{
public MainMenu mainmenu;
public ManDown mandown;
private Man G_man;
private Image imgEmpty;
public int man_mov_x = 3;
public int man_mov_y = 3;
public int obj_mov = 4;
public Game(Man man)
{
this.G_man = man;
this.mainmenu = new MainMenu(this);
}
public void startGame()
{
G_man.display.setCurrent(this.mainmenu);
}
public void startmandown()
{
this.mandown = new ManDown(this,G_man);
setgame(man_mov_x,man_mov_y,obj_mov);
G_man.display.setCurrent(this.mandown);
}
public void exitGame()
{
G_man.destroyApp(false);
G_man.notifyDestroyed();
}
public void setgame(int manmovx, int manmovy, int objmov)
{
this.mandown.MAN_MOV_X = manmovx;
this.mandown.MAN_MOV_Y = manmovy;
this.mandown.OBJ_MOV = objmov;
}
public void MydrawRegion(Graphics graphics,Image imgSrc,
int SrcX,int SrcY,
int TargetX, int TargetY,
int TargetWidth,int TargetHeight)
{
graphics.setClip(TargetX, TargetY, TargetWidth, TargetHeight);
graphics.drawImage(imgSrc, TargetX-SrcX, TargetY-SrcY, Graphics.LEFT | Graphics.TOP);
}
}
class MainMenu extends Canvas
{
private int SCREEN_WIDTH = this.getWidth();
private int SCREEN_HEIGHT = this.getHeight();
public int menuindex = 0;
private int setindex= 0;
private Game game;
private String menustr[] = new String[4];
private String setstr[] = new String[4];
public MainMenu(Game game)
{
this.game = game;
try
{
setFullScreenMode(true);
menustr[0] = "开始";
menustr[1] = "设置";
menustr[2] = "退出";
menustr[3] = "关于";
setstr[0] = "简单";
setstr[1] = "普通";
setstr[2] = "困难";
setstr[3] = "返回";
}
catch(Exception ex)
{
//ex.printStackTrace();
}
}
protected void keyPressed(int key)
{
if(menuindex < 5)
{
switch (getGameAction(key))
{
case Canvas.UP:
menuindex --;
if(menuindex < 0) menuindex = 3;
break;
case Canvas.DOWN:
menuindex ++;
if(menuindex > 3) menuindex = 0;
break;
case Canvas.FIRE:
switch(menuindex)
{
case 0:
// 开始游戏
this.game.startmandown();
break;
case 1:
// 设置难度
menuindex = 5;
break;
case 2:
// 退出
this.game.exitGame();
break;
case 3:
// 关于
menuindex = 4;
break;
case 4:
//从关于中退出
menuindex = 3;
break;
}
break;
}
}
else
{
switch (getGameAction(key))
{
case Canvas.UP:
setindex --;
if(setindex < 0) setindex = 3;
break;
case Canvas.DOWN:
setindex ++;
if(setindex > 3) setindex = 0;
break;
case Canvas.FIRE:
switch(setindex)
{
case 0:
// 简单
this.game.man_mov_x = 3;
this.game.man_mov_y = 3;
this.game.obj_mov = 2;
this.game.startmandown();
break;
case 1:
// 一般
this.game.man_mov_x = 3;
this.game.man_mov_y = 3;
this.game.obj_mov = 4;
this.game.startmandown();
break;
case 2:
// 困难
this.game.man_mov_x = 4;
this.game.man_mov_y = 4;
this.game.obj_mov = 5;
this.game.startmandown();
break;
case 3:
// 返回
setindex = 0;
menuindex = 1;
break;
}
break;
}
}
this.repaint();
}
protected void sizeChanged(int w, int h)
{
SCREEN_WIDTH = w ;
SCREEN_HEIGHT = h ;
}
public void paint(Graphics graphics)
{
if(menuindex < 4)
{
graphics.setColor(96,57,19);
graphics.fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
graphics.clipRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
for(int i =0;i < 4;i++)
{
if(i == menuindex)
{
graphics.setColor(218,218,218);
graphics.drawString(menustr[i],this.getWidth()/2,this.getHeight()/6*(1+i),Graphics.HCENTER|Graphics.TOP);
}
else
{
graphics.setColor(198,156,109);
graphics.drawString(menustr[i],this.getWidth()/2,this.getHeight()/6*(1+i),Graphics.HCENTER|Graphics.TOP);
}
}
}
else if(menuindex == 4)
{
graphics.setColor(96,57,19);
graphics.fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
graphics.clipRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
graphics.setColor(198,156,109);
graphics.drawString("雨石工作室",this.getWidth()/2,this.getHeight()/5*1,Graphics.HCENTER|Graphics.TOP);
graphics.drawString("设计开发",this.getWidth()/2,this.getHeight()/5*2,Graphics.HCENTER|Graphics.TOP);
}
else if(menuindex == 5)
{
graphics.setColor(96,57,19);
//graphics.fillRect(0,0,this.getWidth(),this.getHeight());
//graphics.clipRect(0,0,this.getWidth(),this.getHeight());
graphics.fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
graphics.clipRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
for(int i =0;i < 4;i++)
{
if(i == setindex)
{
graphics.setColor(218,218,218);
graphics.drawString(setstr[i],this.getWidth()/2,this.getHeight()/6*(1+i),Graphics.HCENTER|Graphics.TOP);
}
else
{
graphics.setColor(198,156,109);
graphics.drawString(setstr[i],this.getWidth()/2,this.getHeight()/6*(1+i),Graphics.HCENTER|Graphics.TOP);
}
}
}
}
}
class ManDown extends GameCanvas implements Runnable
{
private static int MAN_WIDTH = 16;
private static int MAN_HEIGHT = 16;
private static int OBJ_WIDTH = 48;
private static int OBJ_HEIGHT = 8;
private static int SIDE_WIDTH = 8;
private static int SIDE_HEIGHT = 16;
private static int MAX_LIFE = 15;
//private int SCREEN_WIDTH = this.getWidth();
//private int SCREEN_HEIGHT = this.getHeight();
private int SCREEN_WIDTH;
private int SCREEN_HEIGHT;
public int MAN_MOV_X;
public int MAN_MOV_Y;
public int OBJ_MOV;
private Random rnd;
private Game game;
private Man man;
private Image I_man,I_obj1,I_obj2,I_side,I_top;
private Image image_temp;
private Thread thread;
private int man_picIndex = 0;
public int position_obj_x[] = new int[16];
public int position_obj_y[] = new int[16];
public int position_man_x;
public int position_man_y;
public int position_side_y = 0;
public int direction = 0;
public int directionup = 0;
public int directionhit = 0;
public int time_num = 0;
public int life;
public int level = 0;
public int life_change = 0;
public int level_change = 0;
private Image I_tmp[] = new Image[5];
private int Int_tmp[] = new int[16];
public boolean isgameover = false;
public boolean running = true;
public ManDown(Game game, Man man)
{
super(true);
thread = new Thread(this);
rnd = new Random();
this.game = game;
this.man = man;
setFullScreenMode(true);
SCREEN_WIDTH = this.getWidth();
SCREEN_HEIGHT = this.getHeight();
try
{
life = MAX_LIFE;
I_man = Image.createImage("/man.png");
I_obj1 = Image.createImage("/obj1.png");
I_side = Image.createImage("/side.png");
I_top = Image.createImage("/top.png");
initobj(16);
}
catch(Exception ex)
{
ex.printSt
没有合适的资源?快使用搜索试试~ 我知道了~
man.rar_The Just
共16个文件
png:4个
class:4个
db:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 66 浏览量
2022-09-22
18:12:25
上传
评论
收藏 135KB RAR 举报
温馨提示
just download the file...and learn about the game
资源推荐
资源详情
资源评论
收起资源包目录
man.rar (16个子文件)
www.pudn.com.txt 218B
Man
bin
Man.jad 221B
Man.jar 65KB
MANIFEST.MF 174B
res
side.png 1KB
obj1.png 21KB
man.png 30KB
Thumbs.db 12KB
top.png 421B
Man.pro 263B
tmplib
tmpclasses
src
Man.java 21KB
classes
a.class 2KB
b.class 8KB
c.class 1KB
Man.class 617B
lib
project.properties 119B
共 16 条
- 1
资源评论
weixin_42653672
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功