正文

J2ME 自写的七星彩模拟程序1.0版本2006-11-21 09:30:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/sword2008/20551.html

分享到:

/*

*http://blog.programfan.com/blog.asp?author=qq14923349

*程序之巢制作  @@七星彩模拟程序1.0版本

*如果有图片

*图片存在rec目录下,记得在存之前把格式转换成png,具体方法是:

1,点击开始

2,附件

3,图画板

4,打开图片

5,另存为(可以存作PNG了,不要改后续名,否则运行不了)

6,其他工具,可以选用PS,或者ACDSEE等等改

*/

import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.*;
import java.util.*;

public class Qixingcai extends MIDlet
{
 
 
 public void startApp(){
 
 new Wave(Display.getDisplay(this)).start();
         }

 public void pauseApp(){}

 public void destroyApp(boolean e){}


 class Wave extends GameCanvas implements Runnable{
 
 private Display display;
 private int number[]=new int[7];
 private Random rand;
 private int Xbackground,Ybackground;
 private boolean Runonce=true;

 public Wave(Display d){

 super(true);
 
 display=d;
 
 display.setCurrent(this);
         }

 

 private void start(){
 try{
 rand=new Random();
 
    }
 catch(Exception e){
     }
 
 Thread t=new Thread(this);
 t.start();

       }

 


 public void run(){
 Graphics g=getGraphics();

 while(Runonce){
 update();
 
 shake(); 
 
 draw(g);
 
 Runonce=false;
 
 try{
 Thread.sleep(100);
 
    }
 catch(Exception e){}
     }
    }

 private void update()
 {
 
 
 int keyState=getKeyStates();
 
 if((keyState&LEFT_PRESSED)!=0)
 {
 Runonce=true;
 }
 else if((keyState&RIGHT_PRESSED)!=0)
 {
 Runonce=true;
 }
 if((keyState&FIRE_PRESSED)!=0)
 {
 Runonce=true;
 }
 
 }
//--------------------------------
 private void shake(){
 for(int i=0;i<7;i++){
 number[i]=Math.abs(rand.nextInt())%10;
  System.out.println(""+number[i]);
       }
 
       }
//--------------------------------
 private void draw(Graphics g){

 g.setColor(0xffffff);
 g.fillRect(0,0,getWidth(),getHeight());
 
 g.setColor(0x000000);
 g.drawString("海南私彩开奖模拟程序",20,20,Graphics.TOP|Graphics.LEFT);
 for(int i=0;i<7;i++)
 {
 g.drawString(" "+number[i],10+i*10,40,Graphics.TOP|Graphics.LEFT);
 }

 g.setColor(0x00ff00);
 g.drawString("本程序由剑2008制作",20,60,Graphics.TOP|Graphics.LEFT);
 g.drawString("qq14923349",20,80,Graphics.TOP|Graphics.LEFT);

 g.drawString("v1.0版本",20,100,Graphics.TOP|Graphics.LEFT);

 flushGraphics();
         }

 
               }

}

 

//程序之巢制作  @@七星彩模拟程序1.0版本

阅读(4681) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册