- 浏览: 3801 次
- 性别:
- 来自: 广州
文章分类
最新评论
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package MainUI;
import Handler.Components;
import Handler.GameRecord;
import Handler.Handler;
import Handler.Info;
import Level.*;
import java.io.IOException;
import java.util.Vector;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.game.GameCanvas;
/**
*
* @author Administrator
*/
public class MainUI extends GameCanvas implements Runnable,CommandListener{
//程序控制器
public static MainUI instance; //主界面句柄
private Graphics g; //画布
private Level1 level1=null; //相关关卡
private Level2 level2=null;
private Level3 level3=null;
private Level4 level4=null;
private Level5 level5=null;
//主界面程序状态控制参数设置
public static boolean pause=false; //主界面是否转到其他关卡界面
public int delay=300; //显示延时
private int line=0; //游戏显示
private int menuSelect=0; //菜单选项
private int setSelect=0; //设置选项
public int state=-1; //程序状态记录
public final static int SPLASH=-1;
public final static int PLOT=0;
public final static int SELECT=1;
public final static int PROCESS=2;
public final static int HELP=3;
public final static int ABOUT=4;
public final static int SET=5;
public final static int EXIT=6;
public final static int PASS=7;
public final static int FAIL=8;
public final static int AGAIN=9;
public final static int ENTER=10;
//设备参数
public static int height;
public static int width;
private GameRecord game=new GameRecord();
private Vector v;
private Info in=new Info();
private TextBox f=new TextBox("请输入玩家姓名:",null,256,TextField.ANY);
private Command c=new Command("确认",Command.OK,1);
private int ind=0;
//图片资源
private Image bg=null;
private Image logo=null;
private Image menu=null;
private Image mainMenu=null;
private int frameGif=0;
private boolean next=false;
//文字说明
private String[]Menu={"继续旅程", "设置","帮助","关于","退出"};
private String help=" 游戏帮助\n " +
" 1、按键操作\n"+
"2键或向上键表示向上\n"+
"8键或向下键表示向下\n"+
"4键或向左键表示向左\n"+
"6键或向右键表示向右\n"+
"5键或OK键表示确认\n"+
"返回键或右软件键表示返回到主界面\n"+
" 2、游戏关卡\n"+
"一共有五个关卡,需要在规定时间内闯关\n"+
" 祝你有一个愉快的旅程!";
private String about=" 游戏声明\n"+
"程序编写: David Tseng\n"+
"美工: DouDou&&David Tseng\n"+
"游戏名称:浪漫鼠之旅\n"+
"游戏音乐:DouDou\n"+
"游戏剧情:DouDou\n"+
"联系电话:你是我的XX\n"+
"服务商:DouDou&&David\n"+
"创作时间:2008年4月\n";
private String[]plot={"很多年以前。。。。。。多年以前。。。。。。年以前。。。。。。以前。。。。。。前。。。。。。",
"为了争夺河蟹大陆的统治权,猫小咪和浪漫鼠两个种群进行着旷日持久的战斗。",
"经过几场异常惨烈的战役,猫咪国和可爱鼠国双方元气大伤,在德高望重的DeiDei狗和DouDou马的调停下,两国化干戈于鱼片和奶酪,共同和平的生活着。",
"浪漫鼠霄霄和筱筱,自由自在地生活在无忧草原上,朝九晚五采集食物,睡睡吃吃,吃吃睡睡。。。。。。过着神仙鼠般的生活。。。。。。",
"可是。。。。。\n种子早已深埋,阴霾的天空再次笼盖。。。。。。",
"邪恶的猫小咪豆豆一心想要挑起战争,取得河蟹大陆统治权,它趁着霄霄睡懒觉绑架了筱筱,并留下字条:!@#¥%…&*()。。。。。",
"故事就这样开始了。。。。。。"};
public MainUI()
{
super(false);
setFullScreenMode(true);
g=getGraphics();
initial();
(new Thread(this)).start();
}
private void initial(){
Handler.instance=new Handler();
Components.instance=new Components();
height=getHeight();
width=getWidth();
f.addCommand(c);
f.setCommandListener(MainUI.instance);
try{
bg=Image.createImage("/Resource/Picture/Main/bg.png");
logo=Image.createImage("/Resource/Picture/Main/logo.png");
menu=Image.createImage("/Resource/Picture/Main/menu.png");
mainMenu=Image.createImage("/Resource/Picture/Main/mainMenu.png");
}catch(IOException e){}
v=game.readRecord();
state=SPLASH;
}
private void drawPlot(){
next=false;
while(line<plot.length){
Components.instance.drawText(plot[line],Font.getDefaultFont(),Handler.board,(MainUI.width-Handler.board.getWidth())/2,(MainUI.height-Handler.board.getHeight())/2, g,null);
for(int i=0;i<20&&!next;i++){
try{
Thread.sleep(100);
}catch(InterruptedException e){}
flushGraphics();
}
line++;
next=false;
}
state=SELECT;
}
private void drawSplash(){
g.setColor(0xffff);
g.fillRect(0,0,width,height);
g.drawImage(logo,width/2,Handler.move,g.HCENTER|g.TOP);
Handler.move+=5;
try{
Thread.sleep(100);
}catch(InterruptedException e){}
if(Handler.move>(height-bg.getHeight())/2){
state=1;Handler.move=0;
try{
Thread.sleep(500);
}catch(InterruptedException e){}
state=SELECT;
}
}
private void drawMenu(){
g.setClip(0,0,width,height);
g.setColor(0xffff);
g.fillRect(0,0,width,height);
g.drawImage(bg,width/2,height/2,g.HCENTER|g.VCENTER);
g.setColor(0xffff);
g.drawString(Menu[menuSelect],width/2,height/2+20,g.HCENTER|g.TOP);
}
private void drawHelp(){
Components.instance.drawText(help,Font.getDefaultFont(),Handler.board,(width-Handler.board.getWidth())/2,(height-Handler.board.getHeight())/2, g,null);
}
private void drawAbout(){
Components.instance.drawText(about,Font.getDefaultFont(),Handler.board,(width-Handler.board.getWidth())/2,(height-Handler.board.getHeight())/2, g,null);
}
private void drawEnter(){
g.setColor(0xffff);
g.fillRect(0,0,getWidth(),getHeight());
g.drawImage(bg,getWidth()/2,getHeight()/2,g.HCENTER|g.VCENTER);
if(v==null){
g.setColor(0xffff);
g.drawString("请输入玩家名字:",getWidth()/2,getHeight()/3,g.HCENTER|g.TOP);
g.setColor(0xffff);
g.drawRect(getWidth()/2-40,getHeight()/3+20,80,20);
}
else {
for(int i=0;i<v.size();i++){
Info in=(Info)v.elementAt(i);
g.setColor(0xffff);
g.drawString(in.Player,0,i*20,g.TOP|g.LEFT);
}
g.setColor(0xffff);
g.drawString("设置新玩家: ",getWidth()/2,v.size()*20,g.HCENTER|g.TOP);
g.setColor(0xffff);
g.drawRect(getWidth()/2-40,(v.size()+1)*20,80,20);
}
}
private void drawSet(){
g.setColor(0xffff);
g.fillRect(0,0,width,height);
g.setColor(0xff00ff);
g.fillRect(0,setSelect*30,width,30);
g.setColor(0xff0000);
g.drawString("声音",0,0,g.TOP|g.LEFT);
g.setColor(0xff0000);
if(Handler.SoundEnable)
g.drawString("开",width,0,g.TOP|g.RIGHT);
else g.drawString("关",width,0,g.TOP|g.RIGHT);
g.drawString("音量",0,30,g.TOP|g.LEFT);
g.drawString(""+Handler.sound,width,30,g.TOP|g.RIGHT);
g.setColor(0xff0000);
}
private void Level(){
System.out.println("进入关卡!");
switch(Handler.Level){
case 1:
if(level1==null)level1=new Level1();
else{level1.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level1);new Thread(level1).start();}
break;
case 2:
if(level2==null)level2=new Level2();
else{level2.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level2);new Thread(level2).start();}
break;
case 3:
if(level3==null)level3=new Level3();
else{level3.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level3);new Thread(level3).start();}
break;
case 4:
if(level4==null)level4=new Level4();
else{level4.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level4);new Thread(level4).start();}
break;
case 5:
if(level5==null)level5=new Level5();
else{level5.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level5);new Thread(level5).start();}
break;
}
}
private void Pass(){
Clear();
Handler.Level++;
if(Handler.Level>5)Handler.Level=1;
if(Handler.Level==4)Handler.Level=5;
state=PROCESS;
}
private void Exit(){
Clear();
Midlet.instance.notifyDestroyed();
Midlet.instance.destroyApp(true);
}
public void Clear(){
switch(Handler.Level){
case 1:
if(level1!=null){level1.end=true;level1=null;System.gc();}
break;
case 2:
if(level2!=null){level2.end=true;level2=null;System.gc();}
break;
case 3:
if(level3!=null){level3.end=true;level3=null;System.gc();}
break;
case 4:
if(level4!=null){level4.end=true;level4=null;System.gc();}
break;
case 5:
if(level5!=null){level5.end=true;level5=null;System.gc();}
break;
}
}
public void keyRepeated(int keyCode){
keyPressed(keyCode);
}
public void keyPressed(int keyCode){
switch(state){
case ENTER:
if(v==null&&(keyCode==KEY_NUM5||keyCode==-5)){
pause=true;
Display.getDisplay(Midlet.instance).setCurrent(f);
return ;
}
else{}
break;
case PLOT:
next=true;
break;
case SELECT:
switch(keyCode){
case KEY_NUM5:
case -5:
if(Handler.NewGame){
state=ENTER;
Handler.NewGame=false;
return;
}
switch(menuSelect){
case 0:
state=PROCESS;
break;
case 1:
state=SET;
break;
case 2:
state=HELP;
break;
case 3:
state=ABOUT;
break;
case 4:
state=EXIT;
break;
}
break;
case KEY_NUM2:
case -1:
menuSelect--;
if(menuSelect<0)menuSelect=4;
break;
case KEY_NUM8:
case -2:
menuSelect++;
if(menuSelect>4)menuSelect=0;
break;
case KEY_NUM4:
case -3:
break;
case KEY_NUM6:
case -4:
break;
}
break;
case HELP:
if(keyCode==-11||keyCode==-10){state=SELECT;Handler.move=0;}
else if(keyCode==-1||keyCode==KEY_NUM2){Handler.move--;}
else if(keyCode==-2||keyCode==KEY_NUM8){Handler.move++;}
break;
case ABOUT:
if(keyCode==-11||keyCode==-10){state=SELECT;Handler.move=0;}
else if(keyCode==-1||keyCode==KEY_NUM2){Handler.move--;}
else if(keyCode==-2||keyCode==KEY_NUM8){Handler.move++;}
break;
case SET:
switch(keyCode){
case -10:
case -11:
state=SELECT;
break;
case -5:
case KEY_NUM5:
if(setSelect==0){
Handler.SoundEnable=!Handler.SoundEnable;
if(Handler.SoundEnable)Handler.instance.playSound();
else Handler.instance.pauseSound();
}
break;
case -1:
case KEY_NUM2:
setSelect--;
if(setSelect<0)setSelect=1;
break;
case -2:
case KEY_NUM8:
setSelect++;
if(setSelect>1)setSelect=0;
break;
case -3:
case KEY_NUM4:
if(setSelect==1){
Handler.sound-=5;
if(Handler.sound<0)Handler.sound=0;
Handler.instance.setVolume();
}
break;
case -4:
case KEY_NUM6:
if(setSelect==1){
Handler.sound+=5;
if(Handler.sound>100)Handler.sound=100;
Handler.instance.setVolume();
}
}
break;
case FAIL:
Clear();
state=SELECT;
break;
case PASS:
Pass();
break;
}
}
public void run() {
Handler.instance.playAudio("/Resource/Music/Main/bg.mid");
while(!pause){
switch(state){
case SPLASH:
drawSplash();
break;
case PLOT:
drawPlot();
break;
case SELECT:
drawMenu();
break;
case PROCESS:
Level();
break;
case HELP:
drawHelp();
break;
case ABOUT:
drawAbout();
break;
case SET:
drawSet();
break;
case EXIT:
Exit();
break;
case PASS:
Pass();
break;
case FAIL:
Clear();
state=SELECT;
break;
case AGAIN:
Clear();
state=PROCESS;
break;
case ENTER:
drawEnter();
break;
}
if(state!=PLOT){
try{
Thread.sleep(150);
}catch(InterruptedException e){}
flushGraphics();
}
}
}
public void commandAction(Command c, Displayable s) {
if(c==instance.c){
in.Player=f.getString();
}
f=null;
state=SELECT;
pause=false;
new Thread(MainUI.instance).start();
Display.getDisplay(Midlet.instance).setCurrent(MainUI.instance);
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package MainUI;
import Handler.Components;
import Handler.GameRecord;
import Handler.Handler;
import Handler.Info;
import Level.*;
import java.io.IOException;
import java.util.Vector;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.game.GameCanvas;
/**
*
* @author Administrator
*/
public class MainUI extends GameCanvas implements Runnable,CommandListener{
//程序控制器
public static MainUI instance; //主界面句柄
private Graphics g; //画布
private Level1 level1=null; //相关关卡
private Level2 level2=null;
private Level3 level3=null;
private Level4 level4=null;
private Level5 level5=null;
//主界面程序状态控制参数设置
public static boolean pause=false; //主界面是否转到其他关卡界面
public int delay=300; //显示延时
private int line=0; //游戏显示
private int menuSelect=0; //菜单选项
private int setSelect=0; //设置选项
public int state=-1; //程序状态记录
public final static int SPLASH=-1;
public final static int PLOT=0;
public final static int SELECT=1;
public final static int PROCESS=2;
public final static int HELP=3;
public final static int ABOUT=4;
public final static int SET=5;
public final static int EXIT=6;
public final static int PASS=7;
public final static int FAIL=8;
public final static int AGAIN=9;
public final static int ENTER=10;
//设备参数
public static int height;
public static int width;
private GameRecord game=new GameRecord();
private Vector v;
private Info in=new Info();
private TextBox f=new TextBox("请输入玩家姓名:",null,256,TextField.ANY);
private Command c=new Command("确认",Command.OK,1);
private int ind=0;
//图片资源
private Image bg=null;
private Image logo=null;
private Image menu=null;
private Image mainMenu=null;
private int frameGif=0;
private boolean next=false;
//文字说明
private String[]Menu={"继续旅程", "设置","帮助","关于","退出"};
private String help=" 游戏帮助\n " +
" 1、按键操作\n"+
"2键或向上键表示向上\n"+
"8键或向下键表示向下\n"+
"4键或向左键表示向左\n"+
"6键或向右键表示向右\n"+
"5键或OK键表示确认\n"+
"返回键或右软件键表示返回到主界面\n"+
" 2、游戏关卡\n"+
"一共有五个关卡,需要在规定时间内闯关\n"+
" 祝你有一个愉快的旅程!";
private String about=" 游戏声明\n"+
"程序编写: David Tseng\n"+
"美工: DouDou&&David Tseng\n"+
"游戏名称:浪漫鼠之旅\n"+
"游戏音乐:DouDou\n"+
"游戏剧情:DouDou\n"+
"联系电话:你是我的XX\n"+
"服务商:DouDou&&David\n"+
"创作时间:2008年4月\n";
private String[]plot={"很多年以前。。。。。。多年以前。。。。。。年以前。。。。。。以前。。。。。。前。。。。。。",
"为了争夺河蟹大陆的统治权,猫小咪和浪漫鼠两个种群进行着旷日持久的战斗。",
"经过几场异常惨烈的战役,猫咪国和可爱鼠国双方元气大伤,在德高望重的DeiDei狗和DouDou马的调停下,两国化干戈于鱼片和奶酪,共同和平的生活着。",
"浪漫鼠霄霄和筱筱,自由自在地生活在无忧草原上,朝九晚五采集食物,睡睡吃吃,吃吃睡睡。。。。。。过着神仙鼠般的生活。。。。。。",
"可是。。。。。\n种子早已深埋,阴霾的天空再次笼盖。。。。。。",
"邪恶的猫小咪豆豆一心想要挑起战争,取得河蟹大陆统治权,它趁着霄霄睡懒觉绑架了筱筱,并留下字条:!@#¥%…&*()。。。。。",
"故事就这样开始了。。。。。。"};
public MainUI()
{
super(false);
setFullScreenMode(true);
g=getGraphics();
initial();
(new Thread(this)).start();
}
private void initial(){
Handler.instance=new Handler();
Components.instance=new Components();
height=getHeight();
width=getWidth();
f.addCommand(c);
f.setCommandListener(MainUI.instance);
try{
bg=Image.createImage("/Resource/Picture/Main/bg.png");
logo=Image.createImage("/Resource/Picture/Main/logo.png");
menu=Image.createImage("/Resource/Picture/Main/menu.png");
mainMenu=Image.createImage("/Resource/Picture/Main/mainMenu.png");
}catch(IOException e){}
v=game.readRecord();
state=SPLASH;
}
private void drawPlot(){
next=false;
while(line<plot.length){
Components.instance.drawText(plot[line],Font.getDefaultFont(),Handler.board,(MainUI.width-Handler.board.getWidth())/2,(MainUI.height-Handler.board.getHeight())/2, g,null);
for(int i=0;i<20&&!next;i++){
try{
Thread.sleep(100);
}catch(InterruptedException e){}
flushGraphics();
}
line++;
next=false;
}
state=SELECT;
}
private void drawSplash(){
g.setColor(0xffff);
g.fillRect(0,0,width,height);
g.drawImage(logo,width/2,Handler.move,g.HCENTER|g.TOP);
Handler.move+=5;
try{
Thread.sleep(100);
}catch(InterruptedException e){}
if(Handler.move>(height-bg.getHeight())/2){
state=1;Handler.move=0;
try{
Thread.sleep(500);
}catch(InterruptedException e){}
state=SELECT;
}
}
private void drawMenu(){
g.setClip(0,0,width,height);
g.setColor(0xffff);
g.fillRect(0,0,width,height);
g.drawImage(bg,width/2,height/2,g.HCENTER|g.VCENTER);
g.setColor(0xffff);
g.drawString(Menu[menuSelect],width/2,height/2+20,g.HCENTER|g.TOP);
}
private void drawHelp(){
Components.instance.drawText(help,Font.getDefaultFont(),Handler.board,(width-Handler.board.getWidth())/2,(height-Handler.board.getHeight())/2, g,null);
}
private void drawAbout(){
Components.instance.drawText(about,Font.getDefaultFont(),Handler.board,(width-Handler.board.getWidth())/2,(height-Handler.board.getHeight())/2, g,null);
}
private void drawEnter(){
g.setColor(0xffff);
g.fillRect(0,0,getWidth(),getHeight());
g.drawImage(bg,getWidth()/2,getHeight()/2,g.HCENTER|g.VCENTER);
if(v==null){
g.setColor(0xffff);
g.drawString("请输入玩家名字:",getWidth()/2,getHeight()/3,g.HCENTER|g.TOP);
g.setColor(0xffff);
g.drawRect(getWidth()/2-40,getHeight()/3+20,80,20);
}
else {
for(int i=0;i<v.size();i++){
Info in=(Info)v.elementAt(i);
g.setColor(0xffff);
g.drawString(in.Player,0,i*20,g.TOP|g.LEFT);
}
g.setColor(0xffff);
g.drawString("设置新玩家: ",getWidth()/2,v.size()*20,g.HCENTER|g.TOP);
g.setColor(0xffff);
g.drawRect(getWidth()/2-40,(v.size()+1)*20,80,20);
}
}
private void drawSet(){
g.setColor(0xffff);
g.fillRect(0,0,width,height);
g.setColor(0xff00ff);
g.fillRect(0,setSelect*30,width,30);
g.setColor(0xff0000);
g.drawString("声音",0,0,g.TOP|g.LEFT);
g.setColor(0xff0000);
if(Handler.SoundEnable)
g.drawString("开",width,0,g.TOP|g.RIGHT);
else g.drawString("关",width,0,g.TOP|g.RIGHT);
g.drawString("音量",0,30,g.TOP|g.LEFT);
g.drawString(""+Handler.sound,width,30,g.TOP|g.RIGHT);
g.setColor(0xff0000);
}
private void Level(){
System.out.println("进入关卡!");
switch(Handler.Level){
case 1:
if(level1==null)level1=new Level1();
else{level1.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level1);new Thread(level1).start();}
break;
case 2:
if(level2==null)level2=new Level2();
else{level2.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level2);new Thread(level2).start();}
break;
case 3:
if(level3==null)level3=new Level3();
else{level3.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level3);new Thread(level3).start();}
break;
case 4:
if(level4==null)level4=new Level4();
else{level4.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level4);new Thread(level4).start();}
break;
case 5:
if(level5==null)level5=new Level5();
else{level5.end=false;pause=true;Display.getDisplay(Midlet.instance).setCurrent(level5);new Thread(level5).start();}
break;
}
}
private void Pass(){
Clear();
Handler.Level++;
if(Handler.Level>5)Handler.Level=1;
if(Handler.Level==4)Handler.Level=5;
state=PROCESS;
}
private void Exit(){
Clear();
Midlet.instance.notifyDestroyed();
Midlet.instance.destroyApp(true);
}
public void Clear(){
switch(Handler.Level){
case 1:
if(level1!=null){level1.end=true;level1=null;System.gc();}
break;
case 2:
if(level2!=null){level2.end=true;level2=null;System.gc();}
break;
case 3:
if(level3!=null){level3.end=true;level3=null;System.gc();}
break;
case 4:
if(level4!=null){level4.end=true;level4=null;System.gc();}
break;
case 5:
if(level5!=null){level5.end=true;level5=null;System.gc();}
break;
}
}
public void keyRepeated(int keyCode){
keyPressed(keyCode);
}
public void keyPressed(int keyCode){
switch(state){
case ENTER:
if(v==null&&(keyCode==KEY_NUM5||keyCode==-5)){
pause=true;
Display.getDisplay(Midlet.instance).setCurrent(f);
return ;
}
else{}
break;
case PLOT:
next=true;
break;
case SELECT:
switch(keyCode){
case KEY_NUM5:
case -5:
if(Handler.NewGame){
state=ENTER;
Handler.NewGame=false;
return;
}
switch(menuSelect){
case 0:
state=PROCESS;
break;
case 1:
state=SET;
break;
case 2:
state=HELP;
break;
case 3:
state=ABOUT;
break;
case 4:
state=EXIT;
break;
}
break;
case KEY_NUM2:
case -1:
menuSelect--;
if(menuSelect<0)menuSelect=4;
break;
case KEY_NUM8:
case -2:
menuSelect++;
if(menuSelect>4)menuSelect=0;
break;
case KEY_NUM4:
case -3:
break;
case KEY_NUM6:
case -4:
break;
}
break;
case HELP:
if(keyCode==-11||keyCode==-10){state=SELECT;Handler.move=0;}
else if(keyCode==-1||keyCode==KEY_NUM2){Handler.move--;}
else if(keyCode==-2||keyCode==KEY_NUM8){Handler.move++;}
break;
case ABOUT:
if(keyCode==-11||keyCode==-10){state=SELECT;Handler.move=0;}
else if(keyCode==-1||keyCode==KEY_NUM2){Handler.move--;}
else if(keyCode==-2||keyCode==KEY_NUM8){Handler.move++;}
break;
case SET:
switch(keyCode){
case -10:
case -11:
state=SELECT;
break;
case -5:
case KEY_NUM5:
if(setSelect==0){
Handler.SoundEnable=!Handler.SoundEnable;
if(Handler.SoundEnable)Handler.instance.playSound();
else Handler.instance.pauseSound();
}
break;
case -1:
case KEY_NUM2:
setSelect--;
if(setSelect<0)setSelect=1;
break;
case -2:
case KEY_NUM8:
setSelect++;
if(setSelect>1)setSelect=0;
break;
case -3:
case KEY_NUM4:
if(setSelect==1){
Handler.sound-=5;
if(Handler.sound<0)Handler.sound=0;
Handler.instance.setVolume();
}
break;
case -4:
case KEY_NUM6:
if(setSelect==1){
Handler.sound+=5;
if(Handler.sound>100)Handler.sound=100;
Handler.instance.setVolume();
}
}
break;
case FAIL:
Clear();
state=SELECT;
break;
case PASS:
Pass();
break;
}
}
public void run() {
Handler.instance.playAudio("/Resource/Music/Main/bg.mid");
while(!pause){
switch(state){
case SPLASH:
drawSplash();
break;
case PLOT:
drawPlot();
break;
case SELECT:
drawMenu();
break;
case PROCESS:
Level();
break;
case HELP:
drawHelp();
break;
case ABOUT:
drawAbout();
break;
case SET:
drawSet();
break;
case EXIT:
Exit();
break;
case PASS:
Pass();
break;
case FAIL:
Clear();
state=SELECT;
break;
case AGAIN:
Clear();
state=PROCESS;
break;
case ENTER:
drawEnter();
break;
}
if(state!=PLOT){
try{
Thread.sleep(150);
}catch(InterruptedException e){}
flushGraphics();
}
}
}
public void commandAction(Command c, Displayable s) {
if(c==instance.c){
in.Player=f.getString();
}
f=null;
state=SELECT;
pause=false;
new Thread(MainUI.instance).start();
Display.getDisplay(Midlet.instance).setCurrent(MainUI.instance);
}
}
相关推荐
我自己做的毕业论文答辩,包括论文,ppt,游戏的运行,给大家做参考用。 摘 要 网络的服务质量,Java已经从一种平台无关的编程语言演变成一种与厂商及平台无关的健壮的服务器端技术,促使IT业界深入发掘以Web为...
J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏
总的来说,"j2me手机游戏源码"为我们提供了一个宝贵的实战平台,通过学习和分析这些源码,不仅可以掌握J2ME编程技术,还能了解到游戏开发的基本流程和技巧。无论你是初学者还是经验丰富的开发者,都能从中受益匪浅,...
在J2ME中,由于内存和性能限制,通常会使用多个屏幕(Screen)来管理不同的游戏状态,比如主菜单、游戏界面、得分屏幕等。此类可能包含了这些屏幕之间的跳转逻辑。 3. **GameManager.java** `GameManager` 很可能...
J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏J2ME小游戏
在这个特定的上下文中,我们讨论的是基于J2ME开发的手机游戏,这些游戏在功能手机时代非常流行,提供了各种各样的娱乐选择。 J2ME由两部分组成:K Virtual Machine (KVM) 和 Connected Limited Device ...
我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我的第一个j2me游戏代码我...
**J2ME手机游戏开发毕业论文** Java 2 Micro Edition(J2ME)是Java平台的一个子集,专为资源有限的嵌入式设备,如早期的移动电话和掌上设备设计。它提供了开发和部署应用程序的框架,包括手机游戏。这篇毕业论文...
总之,J2ME游戏引擎是构建移动平台上游戏的关键工具,它们通过提供一系列预封装的功能和优化,帮助开发者克服硬件限制,创造出引人入胜的游戏体验。随着技术的发展,虽然现在更多高级平台如Unity和Unreal Engine占据...
J2ME是Java平台的一个子集,主要用于嵌入式设备和移动设备,如早期的智能手机和平板电脑。这本书的焦点在于教导开发者如何利用J2ME的技术特性来创建引人入胜的游戏体验。 J2ME游戏开发的核心知识点包括: 1. **...
《J2ME手机游戏案例精编电子教程》是一份深入探讨Java 2 Micro Edition (J2ME)在手机游戏开发中的应用的宝贵资源。J2ME是Java平台的一个子集,专为嵌入式设备,如早期的智能手机和平板电脑设计,它提供了开发移动...
Java 2 Micro Edition (J2ME) 是一种用于开发小型设备和嵌入式系统的 Java 平台,尤其在早期智能手机和功能手机上广泛应用于游戏开发。"J2ME 游戏原代码" 提供的资源可能是一个包含 J2ME 游戏完整源代码的压缩包,名...
它以其轻量级、跨平台的特性,成为了早期手机游戏开发的重要工具。本教程将深入探讨j2ME游戏开发的核心概念和技术。 一、j2ME架构与基础 j2ME由配置(Configurations)、配置文件(Profiles)和功能包(MIDP)组成...
通过本文的分析,我们可以看到J2ME手机游戏引擎开发是一个既有挑战又有机遇的项目,它能为开发者提供一个便捷的开发平台,同时满足特定市场的需求。通过合理的设计和实施,有望推动J2ME游戏领域的发展。
Java 2 Micro Edition (J2ME) 是一种用于开发小型设备和嵌入式系统的 Java 平台,尤其在早期的移动设备和智能手机上广泛应用。在 J2ME 中开发游戏,理解其基本结构至关重要,因为这将直接影响到游戏的性能、可移植性...
综上所述,基于J2ME的手机游戏开发涉及到多个技术层面,包括环境配置、用户界面、游戏逻辑、资源管理以及测试和分发。尽管现在有更多先进的平台可以选择,但J2ME的历史地位和其背后的编程思想仍然值得学习和借鉴。
**J2ME手机游戏开发详解** Java 2 Micro Edition(J2ME)是Java平台的一个子集,专门设计用于资源有限的设备,如移动电话、PDA和其他嵌入式系统。J2ME在手机游戏开发领域曾占据重要地位,尤其在功能手机时代,许多...
J2ME,全称Java 2 Micro Edition,是Java平台的一个子集,主要用于移动设备、嵌入式设备上的应用程序开发,尤其是手机游戏。这个压缩包包含的“J2ME游戏开发资源”是一份宝贵的资料库,对于想要学习或从事J2ME游戏...