问题描述
在Netbeans里面能运行的,最好有时间、模式(简单困难)和排行
解决方案
解决方案二:
原来是要游戏源码滴路过,帮顶下
解决方案三:
如果有给发个谢谢
解决方案四:
http://download.csdn.net/source/134525不知道这是不是你要的,直接在netbeans底下新建项目,把src拷进去,把res文件夹添加到项目中就行了
解决方案五:
我的blog里有一篇关于J2ME拼图游戏的文章,有源码。
解决方案六:
偶也想要,mark一下,UP
解决方案七:
我想要J2ME的
解决方案八:
packagecom.pictureGame;importjavax.microedition.lcdui.Display;importjavax.microedition.midlet.MIDlet;importjavax.microedition.midlet.MIDletStateChangeException;publicclassMainGameextendsMIDlet{publicstaticMainGamemain=null;PictureCanvaspictureCanvas=null;Displaydisplay=null;publicMainGame(){main=this;}protectedvoiddestroyApp(booleanarg0)throwsMIDletStateChangeException{}protectedvoidpauseApp(){}protectedvoidstartApp()throwsMIDletStateChangeException{pictureCanvas=newPictureCanvas();//pictureCanvas.setFullScreenMode(true);//设置全屏显示Stringp=System.getProperty("video.encodings");if(p!=null){System.out.println("视频格式:"+p);}display=Display.getDisplay(this);display.setCurrent(pictureCanvas);}}packagecom.pictureGame;importjava.io.IOException;importjava.io.InputStream;importjava.util.Random;importjavax.microedition.lcdui.Font;importjavax.microedition.lcdui.Graphics;importjavax.microedition.lcdui.Image;importjavax.microedition.lcdui.game.GameCanvas;importjavax.microedition.lcdui.game.TiledLayer;importjavax.microedition.media.Manager;importjavax.microedition.media.MediaException;importjavax.microedition.media.Player;publicclassPictureCanvasextendsGameCanvasimplementsRunnable{Imageimg=null;//定义图片Graphicsg=null;//定义画笔TiledLayerpicLyer=null;//intpicture[][]={{1,2,3},{4,5,6},{7,8,9}};//定义数组,存放方框内的信息intindexPicture;//记录方框内最初的一个信息intpx=50;//选择框的x坐标intpy=100;//选择框的y坐标intr;//方框内的信息为0的方框的x坐标intc;//方框内的信息为0的方框的y坐标Threadth=null;//定义线程Randomrand=null;//定义随机数Playerplayer=null;//定义播放器booleanloop=true;//用来实现播放器的循环longtime=0;//定义一个系统时间intwidth=this.getWidth();//得到屏幕的宽intheight=this.getHeight();//得到屏幕的高booleangameWin=false;//用来判断游戏是否结束publicPictureCanvas(){super(false);try{img=Image.createImage("/3.png");picLyer=newTiledLayer(3,3,img,50,50);}catch(IOExceptione){e.printStackTrace();}rand=newRandom();g=this.getGraphics();paintPicture();initPicture();th=newThread(this);th.start();}publicvoidinitPicture(){//方框内的信息for(inti=0;i<picture.length;i++){for(intj=0;j<picture[i].length;j++){picLyer.setCell(j,i,picture[i][j]);}}}publicvoidpaintPicture(){//初始化picture的信息inttemp;for(inti=0;i<picture.length;i++){for(intj=0;j<picture[i].length;j++){intr=Math.abs(rand.nextInt())%3;intc=Math.abs(rand.nextInt())%3;temp=picture[i][j];picture[i][j]=picture[r][c];picture[r][c]=temp;}}indexPicture=picture[2][1];picture[2][1]=0;}publicvoidgameWin(){//判断游戏是否结束intindex=1,count=1;for(inti=0;i<picture.length;i++){for(intj=0;j<picture[i].length;j++){if(picture[i][j]==index){count++;}}}if(count==9){gameWin=true;}}privatevoidclearScreen(){//清屏的方法g.setColor(0xffffff);g.fillRect(0,0,width,height);g.setColor(0);}publicvoidcirle(){//绘制选择框g.setColor(0xff00);g.drawRect(px,py,47,47);g.fillRect(px+20,py+20,5,5);}publicvoidrender(){//渲染if((System.currentTimeMillis()-time)/1000==31){//音乐的播放时间大约为33秒loop=true;}if(loop){playMp3();//播放音乐loop=false;time=System.currentTimeMillis();//获得当前系统时间}clearScreen();//清屏initPicture();//方框内的信息picLyer.paint(g);//绘制画笔cirle();//绘制选择框g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));//设置字体g.drawString("华宇手机游戏开发工作室",0,165,0);//绘制字体gameWin();if(gameWin){//游戏结束时绘制的界面g.setColor(0,255,255);g.drawString("你神啊!厉害!牛啊!",0,180,0);}this.flushGraphics();//刷新g}publicvoidselectd(){//按下确认键FIRE_PRESSED时判断该选择框的宽和高for(inti=0;i<picture.length;i++){for(intj=0;j<picture[i].length;j++){if(picture[i][j]==0){r=i;c=j;}}}}publicvoidlogic(){//实现逻辑的方法intr2=0,c2=0,temp;selectd();if(px>0){c2=px/50;}if(py>0){r2=py/50;}if((r-r2)==1||(c-c2)==1&&(!((r-r2)==2||(c-c2)==2))&&(!((r2-r)==2||(c2-c)==2))){if(!((r-r2)==1&&(c-c2)==1)){temp=picture[r][c];picture[r][c]=picture[r2][c2];picture[r2][c2]=temp;}}if(((r2-r)==1||(c2-c)==1)&&(!((r2-r)==2||(c2-c)==2))&&(!((r-r2)==2||(c-c2)==2))){if(!((r2-r)==1&&(c2-c)==1)){temp=picture[r][c];picture[r][c]=picture[r2][c2];picture[r2][c2]=temp;}}}publicvoidrun(){//run方法try{while(true){render();//渲染Thread.sleep(300);//让线程睡眠300ms}}catch(Exceptione){e.printStackTrace();}}publicvoidplayMp3(){//播放音乐的方法try{InputStreamis=getClass().getResourceAsStream("/1.mid");//获取文件流player=Manager.createPlayer(is,"audio/midi");//创建播放器player.realize();player.prefetch();player.start();}catch(IOExceptione){e.printStackTrace();}catch(MediaExceptione){e.printStackTrace();}}publicvoidkeyPressed(intkeyCode){//按键事件intcode=getKeyStates();switch(code){caseUP_PRESSED://向上if(py>=50){py-=50;}break;caseDOWN_PRESSED://向下if(py<=50){py+=50;}break;caseLEFT_PRESSED://向左if(px>=50){px-=50;}break;caseRIGHT_PRESSED://向右if(px<=50){px+=50;}break;caseFIRE_PRESSED://按下确认键logic();break;}}}
解决方案九:
这是小弟玩玩的。。。不是很规范的游戏源码。。。你自己研究研究吧!
解决方案十:
http://www.verycd.com/topics/2741518/视频+教程Netbeans的自己看