⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamehigh.java

📁 j2me
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package mole.Rusfk;

//import java.util.Enumeration;
import java.util.Random;

//import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import mole.gmapi.BooCanvas;
import mole.gmapi.GameListener;
import mole.gmapi.GameManager;
import mole.gmapi.Message;
import mole.gmapi.MoleActor;

public class GameHigh extends BooCanvas implements GameListener,CFINALS,els176js_def
{
	public static final int COUNT_GAME_KEY = 14;
	private int[] m_pDefaultGameKey = new int[COUNT_GAME_KEY];
	private int[] m_pPlayGameKey = new int[COUNT_GAME_KEY];

	public	static final String[]	GAME_KEY_INTRO = 
	{
		"旋转方块",
		"快速下落",
		"向左移动",
		"向右移动",
		"立即到底",
		"对自己使用道具",
		"对二号使用道具",
		"对三号使用道具",
		"对四号使用道具",
		"切换道具",
		"玩家列表",
   		"预设语句",
		"聊天室",
       	"状态栏",
	};

	public	static final int[]	GAME_KEY_VALUE = 
	{
		KEY_UP,
		KEY_DOWN,
		KEY_LEFT,
		KEY_RIGHT,
		KEY_FIRE,
		KEY_1,
		KEY_2,
		KEY_3,
		KEY_4,
		KEY_5,
		KEY_7,
   		KEY_8,
		KEY_9,
       	KEY_0,
	};
	
	boolean m_bStatus=false;
	private int RP=0;
	int[] skin=new int[22];
	private boolean duiwu_judge=false;
	private byte 	TeamSelMenuIndex=1;		//组队菜单选择
	private int lt_tx=0;
	private int kuang_tx=20;
	private boolean can_push=true;
	boolean DJC=false;
	private byte DaoJuToIndex=0;			//道具受用方索引
	private byte MyDJAddSpeed=0;			//加速道具作用秒数
	private byte MyDJDecSpeed=0;			//减速道具作用秒数
	private int timeadd;
	
	private int player_num = 4;
	//private int player_MAX;
	private boolean chose_judge = true;
	private boolean chatMode=false;
	
	private int[] zd_x=new int[player_num*2];		//绘制炸弹xy
	private int[] zd_y=new int[player_num*2];
	private boolean[] zd_xy={false,false,false,false};
	private int[] bz_num={0,0,0,0};				        //炸弹动画的帧数
	private byte[] zd_judge={0,0,0,0};		//绘制炸弹  1:满级发送 2:连销发送 3:接到
	private boolean zd_judge_bool=false;
	private byte[] bz_x={5,4,0};				//炸弹动画的偏移
	private byte[] bz_y={5,0,3};				//炸弹动画的偏移
	private int del_move=0;						//消失抖动
	private byte[] del_move_num={2,1,2,1};		//消失帧数
	private byte llt=0;							//力量条
	
	
		//============SDK调用============//
		private int  	tmptime=0;
	    private int 	currentScenario=0;
	    private boolean busyRun=false;
	    private void gotoScenario(int nextScenario)
	    {
	        busyRun=true;
	        if(nextScenario!=currentScenario){
	            currentScenario=nextScenario;
	            if(currentScenario==SCENARIO_HANDUP||currentScenario==SCENARIO_SCORE||currentScenario==SCENARIO_PLAYMYSELF||currentScenario==SCENARIO_EXIT){
	            	init_kuang();
	            }
	            if(currentScenario>=SCENARIO_SHOWPLAYINFO){
	            	returnFromLobby(0);
	            }
//	        	if(currentScenario==SCENARIO_MAINMENU) 
//	        		NowMenuOpen=true;
//	        	else
//	        		NowMenuOpen=false;
	            repaint();
	        }
	        busyRun=false;
	    }	    
		public void onPhone() {}
		public void onPhoneOver() {}
		public String getGameVersion()
		{
			return "2.01";
		}
		public String getGameName()
		{
			return "摩乐俄罗斯";
		}		
		public void returnFromLobby(int type)
		{
			
//			System.err.println("返回游戏"+type);
//      		NowMenuOpen=false;
			GotoLastSCENLIST();
			InitDelay();
			ReflashFullArea();
			NowMenuOpen=true;
		}
		public short getChatMsgID()
		{
			return EM_CHAT;
		}
		public void OnChatMsg(int arg0,String info)
		{
			SysChatMode=true;
			ShowChatinfo(info,false);
		}
		public void onAffiche(String info)
		{
			AfficheMode=true;
			SysChatMode=false;
			ShowChatinfo(info,false);
		}
		public void onDisconnect() 
		{
			AutoExit=50;
			gotoScenario(SCENARIO_BREAKEXIT);
		}
		public void onExit() {
			this.ExitGame();
		}	
	    public void onTimer(int rate)
	    {
	    	if(rate==0 || currentScenario==0)
	    		return;
	    	tmptime+=rate;
	    	if(tmptime>=1000)
	    	{
	    		tmptime=0;
	    		DoOneSecond();		//每秒调用
	    	}
	        if(busyRun==true)
	            return;
	        busyRun=true;
			DoChatTextTimer();		//计算聊天区文字坐标
			switch(currentScenario){
	        case SCENARIO_PLAY:
	    	case SCENARIO_EXIT:
	        case SCENARIO_MAINMENU:
	    	case SCENARIO_HANDUP:
	    	case SCENARIO_SCORE:
	    	case SCENARIO_LOWCOINEXIT:
	    	case SCENARIO_PLAYMYSELF:
	        	onPlayTimer();     	//因为查看菜单时,游戏可能正在进行,所以要处理游戏逻辑,以下的查看预设和退出同理	
	            break;
//	        case SCENARIO_CHATINFO:
//	       		onPlayTimer();		
//	            onChatInfoTimer();
//	            break;
	    	case SCENARIO_INFOEXIT:
	    	case SCENARIO_BREAKEXIT:
	    		if(AutoExit>0)
	    			AutoExit--;
	    		else
	    			ExitGame();
	    		break;
	    	default:
	    		onPlayTimer(); 
	    		break;
	        }
	        busyRun=false;
	    }
	    public void paint(Graphics g)
	    {
	    	//System.err.println("当前="+currentScenario+"  前一个="+MyLastScen);
	      	 if(m_leftback==null || m_gameback==null  ||   m_bottomback==null)
	 	 		return;
	      	 if(m_gameother==null || m_gamearea==null ||  m_bottomarea==null)
	      		 return;
	     	if(NowMenuOpen){
	     		m_delayotherarea=0;
	     		m_delaygamearea=0;
	     		m_delayview=0;
	      		NowMenuOpen=false;
	      		return;
	      	}
	     	g.setFont(font);
	      	busyRun=true;
	      
	        switch(currentScenario){
	        case SCENARIO_MAINMENU:
	            switch(MyLastScen){
		            case SCENARIO_HANDUP:
		            	 onHandUpPaint(g);
		            	 break;
		            case SCENARIO_SCORE:
			            onScorePaint(g);
			            break;
		            case SCENARIO_PLAYMYSELF:
			    		onPlayMySelfPaint(g);
			    		break;
		            case SCENARIO_PLAY:
			            onPlayPaint(g);
			            break;
	            }
	            onMainMenuPaint(g);
	            break;
//	        case SCENARIO_CHATINFO:
//	        	onPlayPaint(g);
//	            onChatInfoPaint(g);
//	            break;
	        case SCENARIO_PLAY:
	            onPlayPaint(g);
	            break;
	        case 0:
	    	case SCENARIO_HANDUP:
	            onHandUpPaint(g);
	            break;
	    	case SCENARIO_SCORE:
	            onScorePaint(g);
	            break;
	    	case SCENARIO_EXIT:
	    		onPlayPaint(g);
	            onExitPaint(g);
	            break;
	    	case SCENARIO_INFOEXIT:
	    		break;
	    	case SCENARIO_BREAKEXIT:
	    		onBreakNetPaint(g);
	            break;           
	    	case SCENARIO_LOWCOINEXIT:
	    		onLowCoinExitPaint(g);
	    		break;	            
	    	case SCENARIO_PLAYMYSELF:
	    		onPlayMySelfPaint(g);
	    		break;
	        }
//	      刷新聊天区文字
	        DrawChatText(g);
	        busyRun=false;
	        
	    
	    }
	    
	    public void keyPressed(int keyCode)
	    {
	    	keyCode=parseGameKey(keyCode);
	    	busyRun=true;
	    	switch(currentScenario){
	        case SCENARIO_MAINMENU:
	            onMainMenuKeyDown(keyCode);
	            break;
//	        case SCENARIO_CHATINFO:
//	            onChatInfoKeyDown(keyCode);
//	        	break;
	        case SCENARIO_PLAY:
	            onPlayKeyDown(keyCode);
	            break;
	    	case SCENARIO_HANDUP:
	    		onhandupKeyDown(keyCode);
	    		break;
	    	case SCENARIO_SCORE:
	    		onScoreKeyDown(keyCode);
				break;			
	    	case SCENARIO_EXIT:
	    		onExitKeyDown(keyCode);
				break;
	    	case SCENARIO_LOWCOINEXIT:
	    		onLowCoinKeyDown(keyCode);
	    		break;
	    	case SCENARIO_PLAYMYSELF:
	    		onPlayMySelfKeyDown(keyCode);
	    		break;
	        }
	        busyRun=false;
	    }
	    public void keyReleased(int keyCode)
	    {
	        busyRun=true;
	        if(currentScenario==SCENARIO_PLAY)
	        {
	        	if(NowKeyDOWN==1 || NowKeyDOWN==2)
	        		this.m_delay=m_tmpdelay;
	        	NowKeyDOWN=0;
	        }
	        busyRun=false;
	    }
		public void repaint()
		{
			gm.repaintArea(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);	
		}
		public void repaint(int x,int y,int w,int h )
		{
			gm.repaintArea(x,y,w,h);	
		}    
		public void onInitialize(GameManager arg0)
		{
			InitGame();
			gm=arg0;
			
			DJC=arg0.useTool();
			
		    m_play = new GameData[player_num];
			losebody=new boolean[player_num];
			havebody=new boolean[player_num]; 
			for(int i=0;i<player_num;i++)
			{
				m_play[i]= new GameData(this);
				m_play[i].InitRusHigh();
	    		havebody[i]=false;
	    		losebody[i]=false;
	    	}
	    	
//			粒子动画管理
		    bombindex=0;
		    bombpoint= new byte[256][2];
		   	m_fxpoint= new MyFxPointManage(this);
	
		   	//准备聊天信息
		    ChatShow = new StringBuffer();
		    
//		    //获取预设聊天信息
//		    SysChatText= new String[10];
//		    SysChatText= gm.getPresetDialogue();
		    
			//获得各绘制区的绘制偏移量
			CELL_SIZE=getFrameH(FRAME_FK1);
			
			
			GAMEAREA_LEFT=1;//3;//画游戏区域的左上角
			GAMEAREA_TOP=5;
			GAMEAREA_WIDTH=97+2*CELL_SIZE;//97;//画游戏区域大小	
			GAMEAREA_HEIGHT=189-8;
			
			draw_game_width=GAMEAREA_WIDTH+GAMEAREA_LEFT;
		    draw_game_height=GAMEAREA_TOP+GAMEAREA_HEIGHT;
			
			
		
			
					
			VIEWAREA_LEFT=draw_game_width-db_xy;//下一个方块的区域
			VIEWAREA_WIDTH=SCREEN_WIDTH-draw_game_width+db_xy;
			VIEWAREA_HEIGHT=36;
			draw_viewarea_width=SCREEN_WIDTH-draw_game_width+db_xy;
			draw_viewarea_height=VIEWAREA_HEIGHT+GAMEAREA_TOP;
			
			LEFTAREA_LEFT=103;
			LEFTAREA_TOP=36;
			LEFTAREA_HEIGHT=138;//画人物头像的区域大小
			LEFTAREA_WIDTH=60;
			
			draw_leftarea_left=draw_game_width;			
			draw_leftarea_top=draw_viewarea_height;
			draw_leftarea_height=draw_game_height-draw_viewarea_height;			
			draw_leftarea_width=SCREEN_WIDTH-draw_game_width;
			draw_leftarea_x=1;
			draw_leftarea_y=2;
		
			areawidth=(MAXROWS)*2+1;
			areaheight=(MAXCENG-2)*2;
			areax=2;//LEFTAREA_WIDTH-areawidth-10;
			areay=2;//LEFTAREA_HEIGHT/7-areaheight/2;
			aready=45;		
			
		    m_gameback=Image.createImage(draw_game_width,draw_game_height);
		    m_leftback=Image.createImage(draw_leftarea_width,draw_leftarea_height);
		    m_viewback=Image.createImage(draw_viewarea_width,draw_viewarea_height);
		    m_bottomback=Image.createImage(SCREEN_WIDTH,LEFTAREA_HEIGHT_NUM);
			
		   
		    m_gamearea=m_gameback.getGraphics();
		    m_gameother=m_leftback.getGraphics();
		    m_viewarea=m_viewback.getGraphics();	
		    m_bottomarea=m_bottomback.getGraphics();
		    m_gamearea.setFont(font);
		    m_gameother.setFont(font);
		    m_viewarea.setFont(font);
		    m_bottomarea.setFont(font);
   
		    textwidth=m_gamearea.getFont().stringWidth("我");
			textheight=m_gamearea.getFont().getHeight();


			//聊天信息显示框
//			CHATBUTT_SIZE=(byte)LEFTAREA_HEIGHT_NUM;
//			CHATBUTT_LEFT=SCREEN_WIDTH-CHATBUTT_SIZE;
			CHATSHOWAREA_TOP=2;
			CHATSHOWAREA_WIDTH=SCREEN_WIDTH-LEFTAREA_WIDTH_NUM*2;
			CHATSHOWAREA_HEIGHT=(byte)(LEFTAREA_HEIGHT_NUM-4);
			
			chose_judge = true;
		}
		public void onPlayerJoin(MoleActor arg0)
		{
			busyRun=true;
			Index10To0=0;
//			System.err.println("MyChair="+MyChair+"玩家加入");
			if(MyChair==-1)
			{
				MyChair=arg0.getLocation();
				AddPlay(arg0,MyChair);
				HasAskret=false;
				busyRun=false;
//				chatindex=0;
				InitDelay();
//				gotoScenario(SCENARIO_HANDUP);
			    SendAskhasPlay();
//				BakNowSCENLIST();
			}
			else
			{
				AddPlay(arg0,arg0.getLocation());
				SendAskhasTeam();
				busyRun=false;
				this.ReflashOtherArea(true);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -