Java製作案頭彈球下載版 使用如鵬遊戲引擎製作 包含2個精靈球同時彈動,彈球

來源:互聯網
上載者:User

Java製作案頭彈球下載版 使用如鵬遊戲引擎製作 包含2個精靈球同時彈動,彈球

package com.swift;import com.rupeng.game.GameCore;public class DesktopBouncingBall implements Runnable {    public static void main(String[] args) {        GameCore.start(new DesktopBouncingBall());    }    @Override    public void run() {        GameCore.setGameSize(800, 450);        GameCore.setGameTitle("案頭彈球");        GameCore.loadBgView("little.jpg");        GameCore.createSprite(0, "ball1");        GameCore.createSprite(1, "ball2");        GameCore.playSpriteAnimate(0, "rotate", true);        GameCore.playSpriteAnimate(1, "rotate", true);        int vx=2;        int vy=5;        int x=0;        int y=200;        int vx2=2;        int vy2=1;        int x2=300;        int y2=0;        for (;;) {            x=x+vx;            y=y+vy;            x2=x2+vx2;            y2=y2+vy2;            GameCore.setSpritePosition(0, x, y);            GameCore.setSpritePosition(1, x2, y2);            GameCore.pause(10);            if(x<=0||x>=780) {                vx=-vx;            }            if(x2<=0||x2>=780) {                vx2=-vx2;            }            if(y<=0||y>=400) {                vy=-vy;            }            if(y2<=0||y2>=400) {                vy2=-vy2;            }            System.out.println(vx+" "+vy+" "+x+" "+y);        }    }}

上邊是源碼,下邊是打包好的程式,下載解壓後雙擊start檔案可以運行(不需安裝jre)

連結: https://pan.baidu.com/s/1eSyArOe 密碼: nb28

效果如:

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.