Asteroid.java
上传用户:haoxsx
上传日期:2022-03-22
资源大小:20k
文件大小:1k
源码类别:

Applet

开发平台:

Java

  1. package asteroids;
  2. import java.awt.Polygon;
  3. import java.awt.Rectangle;
  4. public class Asteroid extends BaseVectorShape {
  5. private int[] astx={-20,-13,0,20,22,20,12,2,-10,-22,-16};
  6. private int[] asty={20,23,17,20,16,-20,-22,-14,-17,-20,-5};
  7. protected double rotVel;
  8. public double getRotationVelocity(){return rotVel;}
  9. public void setRotationVelocity(double v){rotVel=v;}
  10. public Rectangle getBounds(){
  11. Rectangle r;
  12. r=new Rectangle((int)getX()-20,(int)getY()-20,40,40);
  13. return r;
  14. }
  15. public Asteroid() {
  16. // TODO Auto-generated constructor stub
  17. setShape(new Polygon(astx,asty,astx.length));
  18. setAlive(true);
  19. setRotationVelocity(0.0);
  20. }
  21. }