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

📄 mycanvas.java

📁 一个商业的赌博老虎机游戏
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
							//df[0]=df[1]=df[2]=true;
							
						}

						

					}
					if( (key == key_2)||(key == key_up))
					{
						mSelect1-=1;
						
						if( mSelect1 < 0 )
						{
							 mSelect1 = 2;
						}
						if(selectMenu > 0)
						selectMenu -=1;
						else
						selectMenu = 2;
						
						
						df[0]=true; 
					}
					if( (key == key_8)|| (key == key_down))
					{
						mSelect1 += 1;
						
						if( mSelect1 > 2 )
						{
							mSelect1 = 0;
						}
						
						if(selectMenu < 2)
						selectMenu +=1;
						else
						selectMenu = 0;
						
						
						df[0]=true;
					}
				
			}



		}else if(gameMode == 6)		//in game appear the next to screen
		{
			if((key == keySoft_select)||(key == key_5))
			{
				gameMode = 4; //retrun to gaming				
			}
			

		}

		repaint();
		serviceRepaints();


	}

	public void init()		//initialization some variable value
	{
		g = getGraphics();
		font = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM);
        g.setFont( font );
        scX = (screenW-160)/2;   
        scY = (screenH-180)/2-3;//zmm 2006-7-4			
		
		img		= new Image[ 36 ];
        df		= new boolean[4];
        reel	 = new byte[3][21];
        reelOffs = new byte[3];		
		reelStop = new boolean[3];
		moveY    = new byte[3];		
        charID   = new byte[3];		
        moveFlg  = new byte[3];                        
        money	= 0;
        smoney	= 0;
        svmoney	= -1;

		DrawFlg = true;
		df[0]=df[1]=df[2]=true;
	}
	public void loadResource()
	{
		int i;          
            try{
				  DataInputStream in = new DataInputStream(getClass().getResourceAsStream("/reel.dat"));
					for( i=0; i<21; i++ )
					{

                         reel[ 0 ][i] = in.readByte();
                         reel[ 1 ][i] = in.readByte();
                         reel[ 2 ][i] = in.readByte();
                    } 
					in.close();
					
					anjian = Image.createImage("/anjian.png");
					anjian1 = Image.createImage("/anjian1.png");
					exit = Image.createImage("/exit.png");
					back = Image.createImage("/back.png");

                    for( i=0; i<36; i++ )
					{
					 proInt = ((i+1)*100)/36;
                     repaint();
					 serviceRepaints();
					 img[i] = Image.createImage("/"+simg[i]+".png");
					                                    
                    }
					                              
              }catch( Exception x )
			  { 
				x.printStackTrace();
			  }   
	}
	public void RMSaccess(int type)				//Access the Record system
	{
		RecordStore rStore = null;
        byte[] data = null;
                try{
                        if( type == 99 )
						{
                                sf		= true;
                                money	= 300;
                                sumGame = 0;
                                sumBig  = 0;
                                sumReg  = 0;
                        }

                        else if( type == 0 ){
                          rStore = RecordStore.openRecordStore("pachislo" , true);
                          if( rStore.getNumRecords() == 0 )
                          {
                            sf		= true;
                            money	= 300;
                            sumGame = 0;
                            sumBig  = 0;
                            sumReg  = 0;

                           ByteArrayOutputStream baos = new ByteArrayOutputStream();
                           DataOutputStream out = new DataOutputStream( baos );
                           out.writeBoolean( sf );
                           out.writeInt( money );
                           out.writeInt( sumGame );
                           out.writeInt( sumBig );
                           out.writeInt( sumReg );
                           out.close();
                           data = baos.toByteArray();
                           rStore.addRecord( data, 0, data.length );
                          }else{
                            data = rStore.getRecord( 1 );
                            if( data != null )
                            {

                              ByteArrayInputStream bais = new ByteArrayInputStream( data );
                              DataInputStream in = new DataInputStream( bais );

                              sf = in.readBoolean();
                              money = in.readInt();
                              if (money <= 2)
                                money = 300;
                              sumGame = in.readInt();
                              sumBig = in.readInt();
                              sumReg = in.readInt();
                              in.close();
                              in = null;
                            }
                                
                        }
                        }
                        else if( type == 1 )
						{
                          rStore = RecordStore.openRecordStore("pachislo" , false);
                          ByteArrayOutputStream baos = new ByteArrayOutputStream();
                          DataOutputStream out = new DataOutputStream( baos );
                          out.writeBoolean( sf );
                          out.writeInt( money );
                          out.writeInt( sumGame );
                          out.writeInt( sumBig );
                          out.writeInt( sumReg );
                          out.close();
                          out = null;
                          data = baos.toByteArray();
                          rStore.setRecord( 1, data, 0, data.length );
                          rStore.closeRecordStore();                               
                        }
                }
                catch( Exception x )
				{
                  try
                  {
                         rStore.closeRecordStore();
                   }catch (Exception ex)
				   {}
				   x.printStackTrace();                       
                }
	}

	public void drawProcess(Graphics g_1)		//draw process indicate
	{
		g_1.setColor(getColorOfRGB(255,255,255) );
        g_1.drawRect( scX+28, scY+89, 101, 6 ); 
        g_1.setColor(getColorOfRGB(255,0,0) );
        g_1.fillRect( scX+29, scY+90, proInt, 5 );
		//DrawFlg = true;
        drawStr(g_1, "加载中... " + proInt + "%",	scX+45, scY+66, getColorOfRGB(255,255,255), getColorOfRGB(64,64,64) );

	}
	public Graphics getGraphics()
	{
		Graphics g_0;
		buffer = Image.createImage(screenW,screenH);
		g_0 = buffer.getGraphics();
		return g_0;		
	}
	public void setSoftLabel(int button,String str_1)		//draw text button
	{
		g.setColor(0xffffff);
		if(button != 0)
		{
			g.drawString(str_1, screenW-30, screenH-18,0);
		}else
		{
			g.drawString(str_1, 0, screenH-18,0);
		}
	}
	//----------------------------------------------
	//autoState method  add by k7sem
	//----------------------------------------------

		
	public void autoState()
	{
		
		
		try
		{
		switch( sstep )
		{
			
                case 5:	  
						
					if(  press ==  false) 
					{
						
                     DrawFlg = true;                                                
                     if( money < 3 )
					{
						 return;
					 
					}
                                                
                      if( sumGame < 9999999 )		sumGame++;
                      ngame++;
                      moveY[0]   = moveY[1]   = moveY[2]   = -20;
                      moveFlg[0] = moveFlg[1] = moveFlg[2] = 99;
                      money -= 3;
                      if( reachCnt > 0 )		reachCnt--;
                      lcBG  = getColorOfRGB(0,2,74);
                      ExInt = 0;
					  
                      AcPrize = lottery( 0 );
					 
                      switch( AcPrize )
					  {
                          case 0:
                          if( reach == 0 )		reachCnt = 7;
                          reach = 1;
                          break;

                          case 1:
                          if( reach == 0 )		reachCnt = 5;
                          reach = 2;
                          break;

                          case 2:
                          if( reach == 0 )		reachCnt = 3;
                          reach = 3;
                          break;
                      }                                                

                      LKeyTm	= System.currentTimeMillis()+700;
                      reelStop[ 0 ] = reelStop[ 1 ] = reelStop[ 2 ] = false;
                      sstep = 1;
                     
				
					}
              break;

            case 1:
				
            case 2:
				
            case 3:
				
				if(press == true)
			{
					
                  for(int i=0; i<3; i++ )
				 {
                      if( !reelStop[i] )
						{		
						  reelStop( i );	
						break; 
					  }
                 }

			}	
           
          break;
		}
         
		}catch(Exception ex){}
		
	}

	public  int lottery( int bonus )
	{
		//System.out.println("setup:::::"+setup);
		
          int	point;                
          AcNotice = 10;
          point = ((ran.nextInt()&0x7FFFFFFF)%1000) + 5 * setup;
		 
          if( point > 850 )
		  {
                  point = (ran.nextInt()&0x7FFFFFFF)%1000;
                  if( point > 997 )
			      {
                           moveFlg[0] = moveFlg[1] = moveFlg[2] = 1;
                           charID[0]  = charID[1]  = charID[2]  = 18;
                           //PlaySound( 8,	1 );
                           AcNotice = 0;
                          return 0;
                  }else if( point > 780 )
				  {		
                          moveFlg[0] = moveFlg[2] = 3;
                          moveFlg[1] = 2;
                          charID[0]  = charID[2]  = 19;
                          //PlaySound( 7,	1 );
                          AcNotice = 1;
                          point = ((ran.nextInt()&0x7FFFFFFF)%1000) - 10 * setup;
                          if(  point < 300 ){		charID[1]  = 35;	return 3;  }
                          else if( point < 794 ){		charID[1]  = 34;	return 6;  }
                          else if( point < 799 ){		charID[1]  = 35;	charID[0]  = charID[2]  = 18;		return 0; }
                          else if( point < 800 ){		charID[1]  = 34;	charID[0]  = charID[2]  = 18;		return 2;  }
                          else if( point < 900 ){		charID[1]  = 34;	return 7; }
                          else {						charID[1]  = 35;	return 7; }
                  }else if( point > 400 )
				 {			
                         moveFlg[0] = moveFlg[2] = 2;
                         moveFlg[1] = 3;
                         charID[0]  = charID[1]  = charID[2]  = 19;
                         //PlaySound( 7,	1 );
                         AcNotice = 2;
                         bonus = 3 + (6-setup);
                 }else if( point > 120 )
			     {			
                         moveFlg[0] = moveFlg[1] = moveFlg[2] = 1;
                         charID[0]  = charID[1]  = charID[2]  = 34;
                         //PlaySound( 3,	1 );
                         AcNotice = 3;
                         point = ((ran.nextInt()&0x7FFFFFFF)%1000) - 4 * setup;
                         if( point < 0 ){			return 2; }
                         else if( point < 23 ){		return 0; }
                         else if( point < 30 ){		return 1; }
                         else{
                                        if( point < 45 )			AcNotice = 33;
                                        else if( point < 750 )		AcNotice = 32;
                                        else if( point < 920 )		AcNotice = 31;
                                        else						AcNotice = 30;
                                        return 7;
                                }
                 }else if( point > 0 )
				{		
                          moveFlg[0] = 1;
                         moveFlg[1] = 2;
                        moveFlg[2] = 3;
                        charID[0] = 19;
                       charID[1] = 34;
                        charID[2] = 35;
                        //PlaySound( 3,	1 );
                        AcNotice = 4;
                        point = ((ran.nextInt()&0x7FFFFFFF)%1000) - setup;
                        if(      point < 13 )		return 0;
                        else if( point < 15 )		return 2;
                        else						return 5;
                 }
           }else {  //PlaySound( 2, 		1 );
		   }
			
			if( ((ran.nextInt()&0x7FFFFFFF)%5) < 4 )
			{
                        if( reach == 1 )			return 0;
                        else if( reach == 2 )	return 1;
                        else if( reach == 3 )	return 2;
             }

            point = ((ran.nextInt()&0x7FFFFFFF)%993) + (((ran.nextInt()&0x7FFFFFFF)%5) * bonus) + setup;
			
                
				if( point < 6 )			point += 10 * bonus;

                if( point > 996 )			return 0;
                else if( point > 992 )	return 1;
                else if( point > 880 )		return 3;
                else if( point > 610 )		return 4;
                else if( point > 607 )		return 5;
                else if( point > 400 )		return 6;
                else						return 7;


				


		
    }


	private void reelStop( int button )
	{
       int		i;
       int		slip;				
       byte	offs;				
       byte	bkreel;				
	  long	thisTm;
      long	nextTm = 0;
		
	if( reelStop[ button ] )	
	return;
    //PlaySound( 4, 1 );
    reelStop[button] = true;
    sstep++;
	
	 if( AcNotice == 3 || 30 <= AcNotice )
	 {
           if( sstep == 2 )
		  {
                if( AcNotice == 3 || AcNotice >= 31 )
				{
                         moveY[0]   = moveY[1]   = moveY[2]   = -20;
                         charID[0]  = charID[1]  = charID[2]  = 35;
                }
          }else if( sstep == 3 )
		 {
                 if( AcNotice == 3 || AcNotice >= 32 )
				{
                         moveY[0]   = moveY[1]   = moveY[2]   = -20;
                         charID[0]  = charID[1]  = charID[2]  = 19;
                          if( AcNotice == 33 )
						  {
                                    moveFlg[1] = 4;
                                    charID[1]  = 20;
                          }else if( AcNotice != 3 )
						 {
                                    moveFlg[1] = 99;
                         }
                  }
         }
    }
	i = 0;
	
	do{
          slip = denialSlip( button );
          reelSlip( button, slip );				

⌨️ 快捷键说明

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