资源简介

大二的Java课课程设计,开发文档就不放上来了,这里只有源代码,整个工程都完整地在里面了!

资源截图

代码片段和文件信息

package cn.bit.edu.cs.futurestudio;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.geom.AffineTransform;

public class Bird {

    public int x;
    public int y;
    public int width;
    public int height;

    public boolean death;

    public double ySpeed;
    public double gravity;

    private int jumpDelay;//控制相邻两次跳跃的最小间隔
    private double rotation;

    private Image image;
    private Keyboard keyboard;
    //固有属性
    public Bird() {
        //起始坐标
     x = 70;
        y = 210;
        //垂直速度,鸟图片属性,重力加速度
        ySpeed = 0;
        width = 40;
        height = 40;
        gravity = 0.5;
        jumpDelay = 0;//控制相邻两次跳跃的间隔
        rotation = 0.0;
        death = false;
        keyboard = Keyboard.getSample();
    }
    
    //更新图片角度达到旋转
    public Drawer getDrawer() {
        Drawer r = new Drawer();
        r.x = x;
        r.y = y;
//
        if (image == null) {
            image = ImageLoader.loadImage(“lib/bird.png“);     
        }
        r.image = image;
//
        rotation = (90 * (ySpeed + 20) / 20) - 90;
        rotation = rotation * Math.PI / 180;
        //向下旋转不能超过90度!!
        if (rotation > Math.PI / 2)
            rotation = Math.PI / 2;
//        
        r.transform = new AffineTransform();
        r.transform.translate(x + width / 2 y + height / 2);
        r.transform.rotate(rotation);
        r.transform.translate(-width / 2 -height / 2);

        return r;
    }
    
  //更新鸟的位置
    public void update() {
     if(y>=390) {
         y = 390;
         return;
        }
     if(ySpeed<0&&death) {
     ySpeed = 0;
     }
        ySpeed += gravity;
        
        if (jumpDelay > 0)
            jumpDelay--;

        if (!death && keyboard.Pushed(KeyEvent.VK_SPACE) && jumpDelay <= 0) {
            //由于按了SPACE竖直方向速度变为-10
         ySpeed = -10;
            jumpDelay = 2; 
        }
        
        y += (int)ySpeed;
        if(y<0) {
         y = 0;
         ySpeed = 0;
        }
        
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        397  2018-12-15 23:55  AngryBird\.classpath

     文件        385  2018-12-15 23:53  AngryBird\.project

     文件        598  2018-12-15 23:53  AngryBird\.settings\org.eclipse.jdt.core.prefs

     文件       1995  2018-12-16 20:58  AngryBird\bin\cn\bit\edu\cs\futurestudio\Bird.class

     文件        737  2018-12-16 18:14  AngryBird\bin\cn\bit\edu\cs\futurestudio\Drawer.class

     文件       1285  2018-12-16 20:58  AngryBird\bin\cn\bit\edu\cs\futurestudio\ImageLoader.class

     文件       1152  2018-12-16 18:14  AngryBird\bin\cn\bit\edu\cs\futurestudio\Keyboard.class

     文件       1333  2018-12-16 18:14  AngryBird\bin\cn\bit\edu\cs\futurestudio\Main.class

     文件       4245  2018-12-16 20:58  AngryBird\bin\cn\bit\edu\cs\futurestudio\MainGame.class

     文件       2654  2018-12-16 20:59  AngryBird\bin\cn\bit\edu\cs\futurestudio\Panel.class

     文件       1928  2018-12-16 20:58  AngryBird\bin\cn\bit\edu\cs\futurestudio\Tube.class

     文件      82353  2018-12-15 20:40  AngryBird\lib\background.png

     文件       4362  2018-12-15 21:13  AngryBird\lib\bird.png

     文件      23364  2018-12-15 20:26  AngryBird\lib\pipe-north.png

     文件      23345  2018-12-15 20:26  AngryBird\lib\pipe-south.png

     文件       2068  2018-12-16 20:58  AngryBird\src\cn\bit\edu\cs\futurestudio\Bird.java

     文件        403  2018-12-16 00:47  AngryBird\src\cn\bit\edu\cs\futurestudio\Drawer.java

     文件        681  2018-12-16 20:58  AngryBird\src\cn\bit\edu\cs\futurestudio\ImageLoader.java

     文件       1012  2018-12-16 00:36  AngryBird\src\cn\bit\edu\cs\futurestudio\Keyboard.java

     文件       1265  2018-12-16 00:36  AngryBird\src\cn\bit\edu\cs\futurestudio\Main.java

     文件       4368  2018-12-16 20:58  AngryBird\src\cn\bit\edu\cs\futurestudio\MainGame.java

     文件       1663  2018-12-16 20:59  AngryBird\src\cn\bit\edu\cs\futurestudio\Panel.java

     文件       1497  2018-12-16 20:57  AngryBird\src\cn\bit\edu\cs\futurestudio\Tube.java

     目录          0  2018-12-16 21:12  AngryBird\bin\cn\bit\edu\cs\futurestudio

     目录          0  2018-12-16 21:12  AngryBird\src\cn\bit\edu\cs\futurestudio

     目录          0  2018-12-16 21:12  AngryBird\bin\cn\bit\edu\cs

     目录          0  2018-12-16 21:12  AngryBird\src\cn\bit\edu\cs

     目录          0  2018-12-16 21:12  AngryBird\bin\cn\bit\edu

     目录          0  2018-12-16 21:12  AngryBird\src\cn\bit\edu

     目录          0  2018-12-16 21:12  AngryBird\bin\cn\bit

............此处省略11个文件信息

评论

共有 条评论