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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? footballgamecanvas.java

?? netbean下開發(fā)的
?? 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;
        //屏幕的高和寬,為了盡量適應(yīng)各種屏幕寬度
    private int height;
    private int width;
        //繪制圖形的類型,主要用來避免有些圖象的重復(fù)繪制
    //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) {
        //初始化程序?qū)ο?/
        
        //每一幀之間的時延
        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 {
            //載入各種精靈,并對其進行相應(yīng)的設(shè)置
            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);   //監(jiān)聽按鍵
            
            //添加各種畫布按鍵
            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;
//           }
           
           
           /*此處實現(xiàn)人的軌跡為連續(xù)的而不是跳躍的*/
       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;
//        }
        /*此處為功能的結(jié)束處*/  

       //this.FootballManage.test();
        
        //檢測是否有碰撞,因為碰撞只可能是一種類型,所以,利用條件語句,首先對碰撞幾率比較大的情況進行檢測
        //注意:?。。】梢钥紤]增加一個條件判斷,只有足球到達一定的范圍內(nèi)才進行碰撞檢測
            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();}    //與右側(cè)墻進行碰撞檢測
                        else                
                        if(this.FootballManage.isStrike(this.WallLeft,1)){this.Updata();} //與左側(cè)墻的碰撞檢測
                            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;
    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一级精品视频在线观看| 在线观看91视频| 久久国产乱子精品免费女| 一区二区三区在线观看动漫| 日韩一区在线播放| 一区二区高清免费观看影视大全| 亚洲人妖av一区二区| 偷窥少妇高潮呻吟av久久免费| 日韩美女啊v在线免费观看| 国产精品短视频| 亚洲欧美日韩国产成人精品影院| 中文字幕色av一区二区三区| 亚洲精品国产无套在线观| 亚洲影视在线观看| 婷婷国产v国产偷v亚洲高清| 奇米色777欧美一区二区| 激情五月播播久久久精品| 国产乱子轮精品视频| 99久久久无码国产精品| 一本色道久久综合亚洲91| 欧美日韩五月天| 久久女同性恋中文字幕| 中文无字幕一区二区三区| 国产精品色一区二区三区| 亚洲码国产岛国毛片在线| 亚洲成人一区在线| 久久疯狂做爰流白浆xx| 不卡的电视剧免费网站有什么| 91精品1区2区| 精品国产一区久久| 亚洲精品中文在线观看| 人人超碰91尤物精品国产| 成人av小说网| 日韩一区二区三区三四区视频在线观看| wwww国产精品欧美| 亚洲国产精品影院| 成熟亚洲日本毛茸茸凸凹| 欧美午夜电影网| 亚洲国产精品精华液ab| 亚洲福利一二三区| 99re成人在线| 久久久综合九色合综国产精品| 亚洲一二三四久久| 成人永久免费视频| 欧美日韩精品福利| 亚洲视频 欧洲视频| 精品一区二区在线播放| 欧美三级电影网| 国产精品欧美一区喷水| 麻豆一区二区三区| 欧美日本韩国一区二区三区视频| 中文字幕成人av| 激情综合色丁香一区二区| 欧美三级蜜桃2在线观看| 中文字幕一区二区三区视频| 韩国三级在线一区| 欧美精品一二三四| 夜夜精品浪潮av一区二区三区| 粉嫩aⅴ一区二区三区四区 | 亚洲午夜影视影院在线观看| 国产sm精品调教视频网站| 日韩无一区二区| 亚洲国产一区在线观看| 91在线观看污| 国产精品久久久久久久久果冻传媒| 国产一区二区网址| 日韩欧美成人一区二区| 日韩国产精品大片| 在线综合+亚洲+欧美中文字幕| 亚洲午夜成aⅴ人片| 91成人在线免费观看| 亚洲蜜臀av乱码久久精品| 99re6这里只有精品视频在线观看| 国产欧美一区二区三区网站| 国产二区国产一区在线观看| 久久久一区二区三区捆绑**| 韩国精品免费视频| 国产无一区二区| 成人午夜激情视频| 亚洲欧美综合另类在线卡通| 一本到一区二区三区| 亚洲无人区一区| 欧美日韩久久一区| 蜜臀精品久久久久久蜜臀| 精品欧美一区二区在线观看| 韩国三级中文字幕hd久久精品| 久久久亚洲国产美女国产盗摄 | 岛国一区二区三区| 日韩一区在线免费观看| 91麻豆国产福利精品| 亚洲精品视频在线观看网站| 欧洲中文字幕精品| 麻豆91精品91久久久的内涵| 精品国产乱码久久久久久闺蜜| 国产成人精品www牛牛影视| 综合久久久久综合| 欧美日韩国产片| 国产一区二区三区在线观看免费视频| 久久久影视传媒| 一本大道久久a久久综合| 亚洲图片自拍偷拍| 久久久99精品久久| 欧洲精品在线观看| 精东粉嫩av免费一区二区三区| 国产精品情趣视频| 欧美高清你懂得| 成人app软件下载大全免费| 亚洲电影你懂得| 久久久午夜电影| 在线观看日韩av先锋影音电影院| 另类调教123区| 亚洲色欲色欲www在线观看| 91麻豆精品国产91久久久更新时间| 国产一区二区三区四区在线观看| 亚洲视频免费在线观看| 26uuu国产电影一区二区| 色88888久久久久久影院按摩| 老司机一区二区| 亚洲人成精品久久久久久 | 国产精品夫妻自拍| 欧美精品日韩一区| 99久久综合色| 国产一区不卡视频| 日韩高清国产一区在线| |精品福利一区二区三区| 精品国产91久久久久久久妲己| 91福利视频久久久久| 成人午夜激情片| 国产精品中文字幕日韩精品| 日韩中文字幕亚洲一区二区va在线| 国产精品传媒视频| 国产人成一区二区三区影院| 日韩女优制服丝袜电影| 欧美视频在线一区二区三区 | 亚洲蜜臀av乱码久久精品| 久久久久久**毛片大全| 日韩欧美一区在线观看| 欧美在线小视频| 91捆绑美女网站| 99精品视频在线观看| 懂色av一区二区三区蜜臀| 国内精品国产成人国产三级粉色| 亚洲地区一二三色| 一区二区三区不卡视频在线观看| 国产精品久久久久7777按摩| 亚洲国产精品二十页| 久久久www免费人成精品| 国产亚洲一二三区| 久久久久综合网| 国产欧美日韩另类视频免费观看 | 99久久99久久综合| 成人精品在线视频观看| 国产69精品一区二区亚洲孕妇| 国产精品资源在线| 成人黄色免费短视频| 国产盗摄视频一区二区三区| 经典三级一区二区| 国产精品综合二区| 国产99精品国产| 91浏览器打开| 欧美日本在线看| 日韩欧美高清在线| 国产午夜精品久久久久久久| 国产欧美一区二区精品婷婷| 国产精品对白交换视频 | 国产aⅴ综合色| 成人黄色网址在线观看| 色嗨嗨av一区二区三区| 欧美日韩卡一卡二| 精品国产一区二区三区久久久蜜月| 日韩精品一区二区在线| 久久综合色天天久久综合图片| 国产欧美久久久精品影院| 亚洲精品免费一二三区| 日韩黄色在线观看| 国产成人免费在线| 色悠久久久久综合欧美99| 欧美疯狂性受xxxxx喷水图片| 欧美成人性福生活免费看| 国产精品久久久久天堂| 午夜精品影院在线观看| 激情图片小说一区| 在线一区二区三区| 久久久久9999亚洲精品| 亚洲一区二区3| 国产乱码精品一区二区三区av | 成人av综合一区| 欧美日韩1234| 国产欧美精品在线观看| 午夜精品久久久久久久久久| 激情深爱一区二区| 在线精品视频免费观看| 精品少妇一区二区三区免费观看| 国产精品色在线| 久久精品国产亚洲aⅴ| 91老司机福利 在线| 久久九九国产精品| 免费成人在线播放| 欧美视频在线播放| 国产精品色哟哟|