亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? footballgamecanvas.java

?? netbean下開發的
?? JAVA
字號:
/*
 * FootballGameCanvas.java
 *
 * Created on 2007年6月3日, 下午10:16
 */

package hello;

import java.util.Timer;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
import java.io.IOException;
import javax.microedition.lcdui.game.*;
import javax.microedition.media.*;
import javax.microedition.media.control.ToneControl;
import java.io.InputStream;
import javax.microedition.lcdui.game.Sprite;
import java.lang.Thread;
/**
 *
 * @author  FXB
 * @version
 */
public class FootballGameCanvas extends Canvas implements CommandListener,Runnable{

    /**
     * constructor
     */
    //如果人沒有跳起來,人對球的作用力,可以為負
    private float peopleforce = 0 ;
    //人的腳離屏幕低端的高度
    private int peopleheight = 10;
     //幀的刷新時間間隔
    private int timeDelay;    
//private Image FootballImage;
    private Image footballImage;
    private Image paopleImage;
    private HelloMidlet Midlet;

    private float peaklength =4f;    //人的跳躍時的初時兩幀的間隔
    
    private  float maxHeigh = 160;  //人對球加正力(就是給球加上一定的速度)的最高距離
    private float BL = 20;  //人高度與人對球的力的比例

    private Sprite Football ;   //足球精靈
    private Sprite WallRight;
    private Sprite WallLeft;
    private Sprite People;      //人的精靈
    private Sprite Sky;
    private Sprite Grass;
    private Image backGround;
        //屏幕的高和寬,為了盡量適應各種屏幕寬度
    private int height;
    private int width;
        //繪制圖形的類型,主要用來避免有些圖象的重復繪制
    //private int PaintType = 0;      //0為初始化時,繪制所有畫布對象到初時位置
                                     //1為對足球進行重新繪制
                                     //2為對足球和人都進行重新繪制(因為人有可能不動,但足球卻是每時每刻都在動)    
    
    private int PeopleDirection = 0;    //標記人的走向,以便刷新人精靈,1為左,2為右
    private double GSpeed =0.3;        //重力加速度的大小
    private double Resistance_air = 0.1; //空氣阻力的大?。▽嶋H上就是考慮空氣對兩幀的距離的影響)
    private int PeopleSpd = 3;
    
    private Command ExitCmd = new Command("Exit", Command.EXIT, 1);
    private Command PauseCmd = new Command("Pause",Command.STOP,1);
    
    private FootballClass FootballManage; //定義一個足球的實例,主要用來通過控制精靈的對齊點來操縱足球精靈的動作
                                    //(注意:足球被頂高的力度也包含在這個類中)
    private PeopleClass PeopleManage; //定義一個人的實例,用來通過鍵盤的輸入來判斷和控制人的運動
    
    
    public FootballGameCanvas(HelloMidlet Midlet) {
        //初始化程序對象//
        
        //每一幀之間的時延
        this.timeDelay = 10;
        this.Midlet = Midlet;
        //System.out.println((float)this.Resistance_air);
        //得到屏幕的高度和寬度
        this.height = this.getHeight();
        this.width = this.getWidth();

        try {
            footballImage = Image.createImage("/hello/fb.png");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        try {
            //載入各種精靈,并對其進行相應的設置
            this.Football = new Sprite(footballImage,footballImage.getWidth()/6,footballImage.getHeight());
            this.Football.setPosition(width/2-10,height/2-10);
           // System.out.println(width/2-10);
           // System.out.println(height/2-10);
            this.Football.defineReferencePixel(this.Football.getWidth()/2, this.Football.getHeight()/2);
            
            this.WallRight = new Sprite(Image.createImage("/hello/wall.png"));
            this.WallRight.setPosition((10-this.WallRight.getWidth()),-10);
            this.WallLeft = new Sprite(Image.createImage("/hello/wall.png"));
            this.WallLeft.setPosition(this.width-10,-10);
            
            this.paopleImage = Image.createImage("/hello/pp.png");
            
            this.People = new Sprite(this.paopleImage,this.paopleImage.getWidth()/2,this.paopleImage.getHeight()); 
            this.People.setPosition(width/2,(height-this.People.getHeight()-this.peopleheight));
            this.People.defineReferencePixel(this.People.getWidth()/2, this.People.getWidth()/2);
            this.People.setRefPixelPosition(this.People.getRefPixelX(),
                    height-this.People.getHeight()/2-this.peopleheight);
            this.Grass = new Sprite(Image.createImage("/hello/grass.png"));
            this.Grass.setPosition(0,height-5);
            this.Sky = new Sprite(Image.createImage("/hello/sky.png"));
            this.Sky.setPosition(0,0);
            this.backGround = Image.createImage("/hello/bg.png");
            
            // Set up this canvas to listen to command events
            setCommandListener(this);   //監聽按鍵
            
            //添加各種畫布按鍵
            this.addCommand(ExitCmd);   
            this.addCommand(PauseCmd);

        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("Can't Load fb.png");
        }
        
        //建立足球精靈處理實例,方便以后對足球運動的管理
        FootballManage = new FootballClass(this.Football, this.Football.getRefPixelX(), this.Football.getRefPixelY(),
                this.GSpeed,(float)this.Resistance_air,this.timeDelay,this);
        
        //建立人精靈的處理實例,方便以后對人的運動的控制管理
        this.PeopleManage = new PeopleClass(this.People,this.PeopleSpd);
        
        Thread t = new Thread(this);    //  建立畫布的新線程
        t.start();                      //啟動線程
    }
    
    /**
     * paint
     */
    public void paint(Graphics g) {
//        g.drawString("Sample Text",0,0,Graphics.TOP|Graphics.LEFT);
        g.drawImage(backGround, 0, 0, Graphics.TOP|Graphics.LEFT);
        Football.paint(g);
        WallRight.paint(g);
        WallLeft.paint(g);
        this.People.paint(g);
        Grass.paint(g);
        Sky.paint(g);
    }
//    private int a=0;
//    private int b=0;
    private int roll = 0;
    private int TimeM = 0;
    
    public void run(){

            //this.PaintType = 0;
       while(true){
//        this.Football.setRefPixelPosition(a,b);
//        a++;
//        b++;
//           if(this.PeopleDirection != 0){
//               this.repaint();
//               this.PeopleDirection =0;
//           }
           
           
           /*此處實現人的軌跡為連續的而不是跳躍的*/
       if(this.People.getX()>10 &&this.PeopleDirection == 1){
           this.PeopleManage.moveleft();
            
            if(this.TimeM * this.timeDelay >40){
            this.People.nextFrame();
            this.TimeM = 0;
            }
            this.TimeM++;
//           roll+=2;
       }
       else
           if( this.People.getX()<(this.width-this.People.getWidth()-10) && this.PeopleDirection == 2){
                this.PeopleManage.moveright();
                
            if(this.TimeM * this.timeDelay >40){
            this.People.prevFrame();
            this.TimeM = 0;
            }
            this.TimeM++;
            }


//        if(roll > this.PeopleSpd){
//           this.PeopleDirection=0;
//           roll = 0;
//        }
        /*此處為功能的結束處*/  

       //this.FootballManage.test();
        
        //檢測是否有碰撞,因為碰撞只可能是一種類型,所以,利用條件語句,首先對碰撞幾率比較大的情況進行檢測
        //注意:?。?!可以考慮增加一個條件判斷,只有足球到達一定的范圍內才進行碰撞檢測
            if(this.FootballManage.isStrike(this.People,4)){
                        System.out.println(this.People.getRefPixelY());
                                            System.out.println(height-this.People.getHeight()/2-this.peopleheight);
                    if(this.People.getRefPixelY() == height-this.People.getHeight()/2-this.peopleheight){
                        System.out.println("rrrrrrrrrrrrrrrrrrrrrrrrrr");
                        this.FootballManage.setForce(this.peopleforce);
                    }else
                    {this.FootballManage.setForce((this.maxHeigh -(this.height-this.People.getRefPixelY()))/this.BL );}

                    this.Updata();
            }   //與人頭的碰撞檢測
            else
            if(this.FootballManage.isStrike(this.Grass,3)){this.Updata();}    //與地面進行碰撞檢測
                    else
                    if(this.FootballManage.isStrike(this.WallRight,2)){this.Updata();}    //與右側墻進行碰撞檢測
                        else                
                        if(this.FootballManage.isStrike(this.WallLeft,1)){this.Updata();} //與左側墻的碰撞檢測
                            else {
                                this.FootballManage.strikeNo();     //計算下一步的足球精靈的位置
                                this.Updata();
                            }
//                                if(this.FootballManage.isStrike(this.Sky,0)){
//                                    this.Updata();   //與天花板進行碰撞檢測
//                                }
              
       //這里使人能彈跳起來,并且落在地上靜止
       if(this.peak==1){
           this.PeopleManage.moveup();
           if(this.People.collidesWith(this.Grass,true)){

               this.People.setRefPixelPosition(this.People.getRefPixelX(),
                       (height-this.People.getHeight()/2-this.peopleheight));
               
               this.PeopleManage.setPeopleYY((height-this.People.getHeight()/2-this.peopleheight),
                       (height-this.People.getHeight()/2-this.peopleheight));
               this.peak = 0;
           }
       }
       
       
        //此時,所有的碰撞可能都檢測完畢,
        if(!this.FootballManage.state){
            this.Midlet.exitMIDlet();
        }
       

        
       }

    }

    public void Updata(){
        this.FootballManage.displayFootball();
        

        
        this.repaint();
        try {
            Thread.sleep(timeDelay);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
    }
    
    /**
     * Called when a key is pressed.
     */
    private boolean circle = true;
    private int peak=0;
    protected  void keyPressed(int keyCode) {
        int action = getGameAction(keyCode);

	    switch (action) { 
	    case Canvas.LEFT:
                this.PeopleDirection = 1;
                
		break;
	    case Canvas.RIGHT:

                this.PeopleDirection = 2;

                break;
	    case Canvas.DOWN:
		break;
	    case Canvas.UP:
                if(this.peak ==0){
                this.peak =1;
                this.PeopleManage.setPeopleYY((float)this.People.getRefPixelY(),
                        (float)this.People.getRefPixelY()+this.peaklength);
                }
		break;
		// case 0: // Ignore keycode that don't map to actions.
	    default:
		return;
            }
    }
    /**
     * Called when a key is released.
     */

    protected  void keyReleased(int keyCode) {
        
                int action = getGameAction(keyCode);

	    switch (action) { 
	    case Canvas.LEFT:
                this.PeopleDirection = 0;
                
		break;
	    case Canvas.RIGHT:
                this.PeopleDirection = 0;
                break;
	    case Canvas.DOWN:
		break;
	    case Canvas.UP:
                
		break;
		// case 0: // Ignore keycode that don't map to actions.
	    default:
		return;
            }
        
    }
    
    /**
     * Called when a key is repeated (held down).
     */

    protected  void keyRepeated(int keyCode) {
        System.out.println("按下鍵changshijian了?。?!");


    }
    
    /**
     * Called when the pointer is dragged.
     */
    protected  void pointerDragged(int x, int y) {
    }
    
    /**
     * Called when the pointer is pressed.
     */
    protected  void pointerPressed(int x, int y) {
    }
    
    /**
     * Called when the pointer is released.
     */
    protected  void pointerReleased(int x, int y) {
    }
    
    /**
     * Called when action should be handled
     */
    public void commandAction(Command command, Displayable displayable) {
        if(command == this.ExitCmd) {
            
            this.Midlet.exitMIDlet();
        }else if(command == this.PauseCmd) {
            
        }
    }
    public int  getmyHeight(){
        return this.height;
    }
    public int getmyWidth(){
        return this.width;
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成+人+日韩+欧美+亚洲| 日韩美女精品在线| 色综合婷婷久久| 亚洲国产日韩精品| 亚洲欧美日韩国产中文在线| 欧美精三区欧美精三区| 成人av电影免费在线播放| 秋霞电影一区二区| 视频一区欧美日韩| 一区二区三区精品| 欧美国产国产综合| 国产色91在线| 久久久久久麻豆| 欧洲日韩一区二区三区| 91日韩精品一区| 99精品视频免费在线观看| 不卡视频一二三四| 粉嫩高潮美女一区二区三区 | 久久精品综合网| www激情久久| 国产色婷婷亚洲99精品小说| 久久免费的精品国产v∧| 在线不卡一区二区| 91精品国产综合久久久久久久 | 一区二区三区在线播放| 综合色天天鬼久久鬼色| 亚洲私人黄色宅男| 国产午夜精品在线观看| 国产蜜臀av在线一区二区三区| 国产欧美日韩精品一区| 最新久久zyz资源站| 久久久欧美精品sm网站| 国产色一区二区| 亚洲欧美一区二区三区国产精品 | 日韩精品一区二区三区蜜臀| 欧美电视剧在线观看完整版| 久久这里只有精品首页| 国产精品久久免费看| 久久亚洲一区二区三区明星换脸| 久久久久久**毛片大全| 中文字幕亚洲成人| 一区二区三区四区在线| 亚洲成av人**亚洲成av**| 久久精品国产秦先生| 国产伦精品一区二区三区在线观看| 懂色av一区二区三区蜜臀| 欧美综合久久久| 欧美久久婷婷综合色| 2020国产精品| 亚洲黄色录像片| 久久99久国产精品黄毛片色诱| 大白屁股一区二区视频| 欧美日韩精品一区二区三区四区| 欧美成人a∨高清免费观看| 亚洲国产成人一区二区三区| 亚洲高清一区二区三区| 精品一区二区三区视频 | 精品电影一区二区三区 | 中文字幕一区在线观看| 一区二区三区在线播放| 国产剧情一区二区| 在线观看国产91| 国产情人综合久久777777| 一区二区三区.www| 97久久精品人人做人人爽50路| 国产亚洲短视频| 激情小说欧美图片| 日韩一级视频免费观看在线| 午夜精品福利一区二区蜜股av | 亚洲婷婷在线视频| 国产福利精品一区| 精品国产123| 国产一区二区三区观看| 欧美成人r级一区二区三区| 麻豆成人综合网| 91麻豆精品91久久久久同性| 天天综合日日夜夜精品| 91精品国产综合久久福利软件| 调教+趴+乳夹+国产+精品| 欧美日韩成人激情| 五月激情综合色| 69久久99精品久久久久婷婷| 视频一区二区三区在线| 91精品国产一区二区三区| 久久精品国内一区二区三区| 久久久久国产精品厨房| 成人一区二区视频| 亚洲精品国产视频| 在线成人av网站| 国产一区二区三区观看| 一色屋精品亚洲香蕉网站| 91网站在线观看视频| 亚洲精品免费一二三区| 在线综合视频播放| 国内成+人亚洲+欧美+综合在线| 国产三级欧美三级日产三级99| 国产jizzjizz一区二区| 一区二区三区中文免费| 欧美精品成人一区二区三区四区| 久久成人免费日本黄色| 国产婷婷色一区二区三区四区 | 国产成a人亚洲| 一区二区激情小说| 精品精品欲导航| 99久久夜色精品国产网站| 亚洲国产日韩综合久久精品| 精品处破学生在线二十三| 大桥未久av一区二区三区中文| 亚洲国产精品久久久久秋霞影院 | 99久免费精品视频在线观看| 亚洲欧美激情一区二区| 欧美一区二区国产| 成人精品gif动图一区| 亚洲一区免费视频| 国产午夜久久久久| 欧美在线免费观看视频| 国产精品香蕉一区二区三区| 亚洲国产裸拍裸体视频在线观看乱了 | 日韩成人伦理电影在线观看| 国产精品免费网站在线观看| 91精品国产综合久久福利| 色婷婷精品久久二区二区蜜臂av | 久久伊人蜜桃av一区二区| 91麻豆精东视频| 捆绑调教美女网站视频一区| 国产精品白丝在线| 久久久久国产一区二区三区四区| 欧美日韩国产精品成人| 成人黄色综合网站| 韩国成人精品a∨在线观看| 午夜私人影院久久久久| 亚洲欧美自拍偷拍| 久久综合成人精品亚洲另类欧美 | 国产suv精品一区二区三区| 欧美aaa在线| 亚洲成人在线免费| 一区二区日韩av| 中文字幕亚洲视频| 欧美激情中文不卡| 精品国产精品一区二区夜夜嗨| 88在线观看91蜜桃国自产| 欧美在线免费观看视频| 日本久久一区二区| 99国产欧美另类久久久精品| 高清在线成人网| 国产成人在线色| 国产麻豆视频精品| 夜夜爽夜夜爽精品视频| 成人av在线网| 日韩一区精品字幕| 国产日韩欧美a| 麻豆国产欧美一区二区三区| 91黄色免费版| 国产精品美女久久久久久久网站| 国产jizzjizz一区二区| 不卡的电影网站| 国产日韩欧美不卡在线| av激情亚洲男人天堂| 亚洲三级在线看| 日韩高清不卡在线| 福利一区二区在线观看| 欧美国产精品一区| 国产成人丝袜美腿| 日韩欧美国产综合一区| 亚洲日本在线天堂| 91久久免费观看| 亚洲国产中文字幕| 免费精品99久久国产综合精品| 青椒成人免费视频| 国产一区二区精品在线观看| 床上的激情91.| 一本色道久久综合精品竹菊 | 91小视频在线免费看| 色婷婷av一区二区三区软件| 欧美日韩免费视频| 精品久久久久久久久久久久久久久 | 国产精品美女www爽爽爽| 国产欧美一区在线| 亚洲精品视频免费看| 婷婷国产v国产偷v亚洲高清| 激情图片小说一区| 粉嫩欧美一区二区三区高清影视| 91福利国产成人精品照片| 欧美三级三级三级爽爽爽| 欧美精品一区二区在线观看| 国产精品免费网站在线观看| 亚洲国产精品一区二区www在线| 日本成人中文字幕| 99久久伊人网影院| 91精品国产综合久久久蜜臀图片 | 日韩精品欧美精品| 成人一区在线看| 欧美日韩精品欧美日韩精品| 久久久久久一二三区| 亚洲成人黄色影院| 不卡一区二区三区四区| 日韩免费电影网站| 亚洲精品乱码久久久久| 国产一区欧美一区| 欧美日韩电影一区|