⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flipper.java

📁 基于JAVA的跳球游戏
💻 JAVA
字号:
/*
 * Flipper.java
 *
 * Created on 2008年5月11日, 下午8:35
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package gizmos;
import java.awt.geom.*;
import gizmoball_demo.*;
import java.awt.Color;
/**
 *
 * @author ICE
 */
public abstract class Flipper extends Gizmo {
    protected int x = 300;   //矩形边框左上角的横坐标
    protected int y = 100;    //矩形边框左上角的横坐标
    protected int width = 10;
    protected int length = 40;
    protected static double arcWidth=15;
    protected static double arcHeight=15;
    protected int startAngle;
    protected int endAngle;
    protected double FLIPPER_VELOCITY = 1080; // degrees/sec
    
    private Color color = new Color(255, 0, 255);
    private AnimationWindow win;

    /** Creates a new instance of Flipper */
    public Flipper(){};
    public Flipper(AnimationWindow win,java.lang.String name,int x,int y,int startAngle,int endAngle)
    {
        this.win = win;
        this.name=name;
        this.x=x;
        this.y=y;
        this.startAngle=startAngle;
        this.endAngle=endAngle;
        
    }
    public void setPosition(int x,int y)
    {
         this.x=x;
         this.y=y;
    }
    public void reset()
    {
       // Flipper f=new Flipper(name,x,y,startAngle,endAngle);
    }
    public int getX()
    {
        return x;
    }
    public int getY()
    {
        return y;
    }
    
    public int getWidth()
    {
        return width;
    }
    public int getLength()
    {
        return length;
    }
    
    //The x coord of the center of the gizmo
    public double getCenterX()
    {
        return (double)x/2;
    }
    //The y coord of the center of the gizmo
    public double getCenterY()
    {
        return (double)y/2;
    }
   // public java.lang.Iterable<BoardSector> getSectors()
    //{
        
   // }
    public boolean isRotatable()
    {
        return true;
    }
    /*public boolean overlapsWith(Ball ball)
    {
        
    }
    public double collisionTime(Ball ball)
    {
        
    }*/
    //
    public boolean collide(BouncingBall ball)
    {
      return true;  
        
    }
    //public boolean overSector(int sx,int sy){}
    public void doAction(){}
    //public void update(double secs,Environment env){}
    //draw a flipper
    public void draw(java.awt.Graphics2D g)
    {
        //前两个参数表示矩形边框的左上角,最后两个参数分别表示椭圆边界弧形的中心到末端之间的横向和纵向距离
           RoundRectangle2D flipper=new RoundRectangle2D.Double(this.getX(),this.getY(),this.getWidth(),
                   this.getLength(),this.arcWidth,this.arcHeight);       
           g.setColor(color);
           g.fill(flipper);
    }
    public void drawBB(java.awt.Graphics2D g,java.awt.Color c)
    {
        RoundRectangle2D flipperBox=new RoundRectangle2D.Double(this.getX(),this.getY(),this.getWidth()+2,
                   this.getLength()+2,this.arcWidth+2,this.arcHeight+2);
        g.setColor(c);
        g.fill(flipperBox);
    }
    
    
    
    
    
    
    
    
    
    
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -