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

📄 basicgizmo.java

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

package gizmos;
import gizmoball_demo.*;
/**
 *
 * @author ICE
 */
//BasicGizmo represents a mutable 1x1 Gizmo that acts as a bumper and does not move. 
public abstract class BasicGizmo extends Gizmo{
    
    /** Creates a new instance of BasicGizmo */
    private AnimationWindow win;
    protected int x;
    protected int y;
    protected int pressX, pressY; 
    protected int releaseX, releaseY;
   
    public BasicGizmo() {
    }
    
    public void setPosition(int x,int y){
        this.x=x;
        this.y=y;
    }
    public int getX()
    {
        return x;  
    }
    public int getY()
    {
        return y;
    }
    public boolean overSector(int sectorX,int sectorY)
    {
        return  ((x<sectorX)&&(y<sectorY));
        
    }
    
    /*监听鼠标的按下事件
    public void mousePressed(MouseEvent e){
        pressX = e.getX();
        pressY = e.getY();
        if(pressX >= (this.getX()-this.getDis()) && pressX <= (this.getX()+this.getDis())){
            
        }
    }
    
   //监听鼠标的释放事件
    public void mouseReleased(MouseEvent e){
       releaseX = e.getX();
       releaseY = e.getY();
       setPosition(releaseX,releaseY);
       win.repaint();
    }*/
    
    //Get all of the sectors a BasicGizmo is over.
    /*public java.lang.Iterable<BoardSector> getSectors()
    {
        
        while(overSector(x,y))
        {
        }
    
    }*/
    /**
     * Throws:java.lang.IllegalArgumentException - if ball is null.
     * Returns:The number of seconds until ball collides with this Gizmo if they will collide,Double.POSITIVE_INFINITY otherwise
    **/
    /*public double collisionTime(BouncingBall ball)
    {
        
    }*/
    
    /**
        Throws:java.lang.IllegalArgumentException - if b == null
        Effects:if b will collide with g in secs seconds then make the Gizmo active, make the Gizmo’s target (ifany) active, set the reflected velocity of b.
        Modifies:this, b
        Returns:true if Ball b will collide with this gizmo in msecs milliseconds or less, false otherwise
     **/
    public boolean collide(BouncingBall ball)
    {
        if(ball==null) throw new java.lang.IllegalArgumentException("Ball "+ball+" does not exist..."); 
        int minDist = ball.getRadius()+getDis();
        int dx = ball.getX() - this.getX();
        int dy = ball.getY() - this.getY();
	//int radius = ball.getRadius();
        return minDist*minDist >= dx*dx+dy*dy; 
    }

    
    public void drawBB(java.awt.Graphics2D g,java.awt.Color c)
    {
        
    }
    public int getDis(){return 0;}
    
    
}

⌨️ 快捷键说明

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